Testland
Browse all skills & agents

buf-cli-lint-breaking-build

Wraps the buf CLI for protobuf PR gating: `buf build` (compile .proto), `buf lint` (STANDARD rules: snake_case fields, Service suffix), `buf breaking --against {ref}` (detect wire/codegen breakage vs a git/BSR baseline), and `buf format`. Use as the CI proto-lint + breaking-change gate, or to debug a breaking failure by rule ID (e.g. FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED) and pick the FILE/PACKAGE/WIRE_JSON/WIRE ruleset per consumer. This is the detection TOOL that enforces the rules and carries the catalog of what is breaking and why (field-number reservation, wire-safe vs wire-incompatible changes, oneof/map constraints, the four buf categories) in references/versioning-strategy.md; for cross-service schema contract testing use protobuf-compat-checking - not this.

Install with skills.sh (any agent)

npx skills add testland/qa --skill buf-cli-lint-breaking-build
View source

buf-cli-lint-breaking-build

Overview

Wraps three buf CLI commands - build, lint, breaking - as the proto-PR gate, per buf.build/docs/cli/quickstart/ (opens in new window). The catalog of what counts as breaking and why lives in references/versioning-strategy.md (+ references/buf-breaking-rules.md).

When to use

  • Adding buf as the proto lint + breaking-change gate on a new repo.
  • A PR changes .proto files - need to gate the merge.
  • Investigating a buf breaking failure - what rule fired?
  • Configuring buf for a monorepo with multiple proto modules.

Authoring

Install

Per buf docs, install via Homebrew, Go install, or release binary. Version 1.32.0 or higher is required. Verify:

buf --version
# 1.32.0 or higher

Configure buf.yaml

The v2 format per buf.build/docs/cli/quickstart/ (opens in new window):

version: v2
modules:
  - path: proto
lint:
  use:
    - STANDARD
breaking:
  use:
    - FILE          # default; choose per references/versioning-strategy.md

STANDARD is the recommended lint rule set; it enforces conventions like "Field name should be lower_snake_case" and "Service name should be suffixed with Service".

The choice of breaking.use (FILE / PACKAGE / WIRE_JSON / WIRE) follows the per-deployment-model logic in references/versioning-strategy.md.

Configure buf.gen.yaml (codegen)

version: v2
managed:
  enabled: true
plugins:
  - remote: buf.build/protocolbuffers/go
    out: gen
    opt: paths=source_relative

managed: enabled: true automatically sets file options without hand-coding (e.g., go_package).

Running

Local validation pipeline

buf build && buf lint && buf breaking --against ".git#branch=main"

Three gates in order: compile, lint, breaking. All three must pass before merge.

buf build

buf build
# Silent exit on success

Compiles every .proto in the workspace. Silent → success. Any output → error. Equivalent to protoc compilation but reads buf.yaml for paths.

buf lint

buf lint
# Emits violations as: <file>:<line>:<col>:<msg>

Validates against the configured rule set. Common failures:

FailureRuleFix
Field name "userId" should be lower_snake_caseFIELD_LOWER_SNAKE_CASERename to user_id
Service "Users" should be suffixed with "Service"SERVICE_SUFFIXRename to UsersService
Message "user_data" should be UpperCamelCaseMESSAGE_UPPER_CAMEL_CASERename to UserData
Enum value should be SCREAMING_SNAKE_CASEENUM_VALUE_UPPER_SNAKE_CASERename

buf breaking

buf breaking --against ".git#branch=main"
# Compares working tree against main branch

Baselines (per buf docs (opens in new window)):

BaselineUse
".git#branch=main"Compare against main branch (CI default)
".git#tag=v1.0.0"Compare against a release tag
".git#subdir=path/to/proto"Sub-directory baseline (monorepo)
"path/to/image.bin"Pre-built buf build image file
"buf.build/owner/module"Compare against published BSR image

Output on violation:

proto/foo.proto:42:5: Field "old_name" with type "string" no longer exists (rule FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED).

Per buf breaking rules (opens in new window): each violation cites the rule that fired so you know which category constraint was violated.

Parsing results

CLI output (text, default)

Each violation: <file>:<line>:<col>: <message> (rule <RULE_ID>).

Pipe to grep / awk for counts:

buf breaking --against ".git#branch=main" 2>&1 | tee buf-breaking.log
wc -l buf-breaking.log

Machine-readable output

buf lint --error-format=json
# Emits: [{"path":"...","start_line":...,"start_col":...,"end_line":...,"type":"FIELD_LOWER_SNAKE_CASE","message":"..."}]

buf breaking --against ".git#branch=main" --error-format=json

For consumption by a unified reporter.

CI integration

Gate buf build / lint / breaking on PRs that touch .proto, buf.yaml, or buf.gen.yaml. Key gotcha: fetch-depth: 0 so git has the baseline commit available. Full GitHub Actions workflow plus the failure PR-comment: references/ci-integration.md.

Anti-patterns

Anti-patternWhy it failsFix
Skipping buf breaking on PRSubtle wire breakage merges; consumers crash at deploy timeAlways gate; never --ignore blanket
Comparing against the PR's own merge baseSelf-baseline; no detectionUse ".git#branch=main"
fetch-depth: 1 in CIgit can't reach baseline → buf errorsfetch-depth: 0
breaking.use: WIRE for codegen consumersGenerated code break (rename) passes; consumer build failsUse FILE or PACKAGE per references/versioning-strategy.md
Adding --ignore to suppress a real violationSilent regressionUse proper reserved + deprecation instead
Lint set MINIMAL for new projectsMisses snake_case + service-suffix conventions earlyUse STANDARD from day 1
One buf.yaml per proto fileDoesn't compose; lint runs N timesOne buf.yaml at module root
Inconsistent baselines (main vs tag)Different reviewers see different verdictsPick one CI baseline; document

Limitations

  • Semantic vs wire breakage. Per references/versioning-strategy.md, buf detects binary/codegen breakage. Semantic meaning changes ("field now means net price, not gross") are undetectable.
  • No cross-service compatibility. This is single-service schema lint. For service-to-service contract testing see protobuf-compat-checking.
  • BSR features require auth. Remote plugins, registry pushes, and buf.build/... baselines need a BSR account.
  • JSON-name detection is in WIRE_JSON only. Services that use only binary won't see JSON name changes detected.
  • Doesn't generate code automatically. buf generate is a separate step; this skill scopes to gating.

References

buf breaking-rule tables and worked evolution patterns

View source (opens in new window)

buf breaking-rule tables and worked evolution patterns

Full rule-ID tables for buf's four breaking categories, plus worked proto-evolution diffs. Sources: buf.build/docs/breaking/rules (opens in new window) and protobuf.dev/programming-guides/proto3/ (opens in new window).

FILE (default)

RuleDetects
ENUM_NO_DELETERemoved enum
MESSAGE_NO_DELETERemoved message
SERVICE_NO_DELETERemoved service
FILE_NO_DELETERemoved file
FIELD_SAME_NAMERenamed field
FIELD_SAME_TYPEType change
FIELD_SAME_CARDINALITYsingular <-> repeated

PACKAGE

RuleDetects
PACKAGE_NO_DELETERemoved package
PACKAGE_ENUM_NO_DELETEEnum deletion across files in package
PACKAGE_MESSAGE_NO_DELETEMessage deletion across files

WIRE_JSON

RuleDetects
ENUM_VALUE_NO_DELETE_UNLESS_NUMBER_RESERVEDDeleted enum value without reserve
FIELD_NO_DELETE_UNLESS_NUMBER_RESERVEDDeleted field without reserve
FIELD_SAME_JSON_NAMEJSON field name change

WIRE (most lenient)

RuleDetects
FIELD_WIRE_COMPATIBLE_TYPEType change incompatible at wire level (allows int32->int64 etc.)
FIELD_WIRE_COMPATIBLE_CARDINALITYCardinality change incompatible at wire

Worked evolution patterns

Adding an optional field

Safe (always):

 message User {
   string name = 1;
+  string nickname = 2;
 }

Renaming a field

Add new, deprecate + reserve old:

 message User {
   string name = 1;
-  string nickname = 2;
+  string display_name = 3;
+  reserved 2;
+  reserved "nickname";
 }

Consumers must migrate from nickname to display_name. The wire format reads either; the codegen forces consumers to update.

Promoting int32 to int64

Wire-compatible per protobuf3 docs:

 message Counter {
-  int32 count = 1;
+  int64 count = 1;
 }

Old clients writing int32 still parse correctly. Old clients reading new int64 data truncate silently if the value exceeds int32 range.

Adding a field to a oneof

ALWAYS BREAKING. Don't.

 message Event {
   oneof body {
     string text = 1;
     bytes binary = 2;
+    string emoji = 3;  // BREAKS old parsers
   }
 }

Mitigation: add the new variant as a non-oneof field; promote later in a separate proto file/package.

buf CI integration

Gate buf build, buf lint, and buf breaking on every PR that touches .proto, buf.yaml, or buf.gen.yaml. All three must pass before merge.

GitHub Actions workflow

# .github/workflows/proto-gate.yml
name: proto-gate
on:
  pull_request:
    paths:
      - "**/*.proto"
      - "buf.yaml"
      - "buf.gen.yaml"

jobs:
  buf:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0   # Required for `--against ".git#branch=main"`
      - uses: bufbuild/buf-setup-action@v1
        with:
          buf_user: ${{ secrets.BUF_USER }}
          buf_api_token: ${{ secrets.BUF_API_TOKEN }}
      - run: buf build
      - run: buf lint
      - run: buf breaking --against ".git#branch=main"

Key: fetch-depth: 0 so git has the baseline commit available. fetch-depth: 1 makes buf error because it cannot reach the baseline.

The official bufbuild/buf-setup-action and bufbuild/buf-breaking-action are convenient but the raw CLI calls above work without them.

Per-PR failure comment

      - if: failure()
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: proto-gate
          message: |
            ❌ `buf breaking` failed. See log:
            ```
            ${{ steps.breaking.outputs.stdout }}
            ```
            Consult
            references/versioning-strategy.md
            for whether this change is genuinely required and how
            to do it safely (reserve, add new, deprecate old).

Protobuf versioning + breaking-change rules

View source (opens in new window)

Protobuf versioning + breaking-change rules

Protobuf3 schema evolution is a wire-format problem first and a codegen problem second. The field number is the only durable identifier - every breaking-change rule derives from preserving field-number → type binding.

Per protobuf.dev/programming-guides/proto3/ (opens in new window): "This number cannot be changed once your message type is in use because it identifies the field in the message wire format."

This is the catalog of what is breaking and why; the host SKILL.md is the detection workflow (buf breaking in CI).

When to use

  • Designing a proto change - is this safe?
  • Auditing an existing schema for risky patterns (un-reserved deleted fields, oneof-conversion footguns).
  • Configuring buf breaking - which category fits the deployment model?
  • PR review of .proto changes.

Field-number rules

RangeUse
1..15Single-byte encoded; reserve for hot fields (frequently set)
16..2047Two-byte encoded; general use
2048..536,870,911Higher-byte encoded; rare-use fields
19,000..19,999Reserved for Protocol Buffers implementation; never use

When deleting a field, reserve its number:

message User {
  reserved 4, 7, 10 to 12;
  reserved "deprecated_email";

  string name = 1;
  // ...
}

Per the spec: "If you do not reserve the field number, it is possible for a developer to reuse that number in the future." Reuse → semantic corruption: old clients interpret bytes as the old type.

Binary wire-safe changes

Fully safe - old code parses new messages and vice versa with no loss:

ChangeWhy safe
Adding fieldsUnknown fields preserved (proto3 since 3.5)
Removing fields with reservationNumber recycling prevented
Adding enum valuesUnknown values pass through
Converting single explicit-presence field into a one-field oneofWire format identical

Wire-compatible changes (conditionally safe)

These preserve wire compatibility but may be lossy or surprising:

Type changeNotes
int32uint32int64uint64boolInteger types interchangeable; negative values may round-trip oddly for unsigned
sint32sint64Compatible only with each other, not with the unsigned family
fixed32sfixed32Same fixed-width family
fixed64sfixed64Same fixed-width family
stringbytesCompatible only if bytes are valid UTF-8
enumint32 / uint32 / int64 / uint64Enum is wire-encoded as varint

The catch: a parser reading int64 data with int32 will silently truncate. The wire is "compatible" but the data may be lost.

Wire-incompatible changes (always breaking)

  • Changing field numbers is equivalent to deleting and re-adding. Always breaks.
  • Moving fields into an existing oneof is not safe.
  • Changing map<k,v> key or value type.
  • Changing field cardinality from singular to repeated (or vice versa) outside the wire-compatible paths.

Oneof constraints

Per protobuf.dev (opens in new window):

  • Oneof fields cannot be repeated or map.
  • "If multiple values are set, the last set value as determined by the order in the proto will overwrite all previous ones."
  • Adding a field to an existing oneof is always breaking - old code can't represent the new variant; new data crashes old parsers.
  • Removing a field from a oneof is breaking for the same reason.
  • Converting a singular field into a single-field oneof: safe.
  • Converting a single-field oneof back to singular: safe.

Map constraints

Per protobuf3 docs:

  • Maps cannot be repeated.
  • Key types: integral and string scalars only. "neither enum nor proto messages are valid for key_type."
  • Changing a map's key or value type is breaking.

buf breaking-change taxonomy

Per buf.build/docs/breaking/rules (opens in new window), buf organises detection into four categories, strictest to most lenient. Full rule-ID tables: buf-breaking-rules.md (opens in new window).

  • FILE (default) - "changes that move generated code between files, breaking generated source code on a per-file basis" (e.g. MESSAGE_NO_DELETE, FIELD_SAME_TYPE, FIELD_SAME_CARDINALITY). Choose when codegen consumers import per-file (most JVM, .NET, generated stubs in a monorepo).
  • PACKAGE - breakage at package level; permits file relocations inside a package (e.g. PACKAGE_MESSAGE_NO_DELETE). Choose when consumers import by package (Go, Python).
  • WIRE_JSON - "changes that break wire (binary) or JSON encoding" (e.g. FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED, FIELD_SAME_JSON_NAME). Choose when consumers use both binary and JSON encoding (REST gateway + grpc).
  • WIRE (most lenient) - only changes "compromising binary wire format compatibility" (e.g. FIELD_WIRE_COMPATIBLE_TYPE, allowing int32->int64). Choose when only wire format matters (binary-only protocols between server fleets you control).

Choosing the category

# buf.yaml
version: v2
breaking:
  use:
    - FILE        # most strict (default)
# OR
    - PACKAGE     # codegen friendly within-package
# OR
    - WIRE_JSON   # wire + JSON
# OR
    - WIRE        # wire only

CI invocation:

buf breaking --against ".git#branch=main"
# Compares the working tree against the main branch as baseline

Common patterns

Removing a field

Always reserve the number and the name:

 message User {
+  reserved 2;
+  reserved "nickname";
   string name = 1;
-  string nickname = 2;
 }

More worked diffs - adding an optional field, renaming, promoting int32 to int64, and the oneof footgun: buf-breaking-rules.md (opens in new window).

Anti-patterns

Anti-patternWhy it failsFix
Delete field without reserveFuture developer reuses number; semantic corruptionAlways reserved <n>; and reserved "name";
Change field number to be more compactWire incompatibility - equivalent to delete+re-addNever; keep numbers stable
Add field to existing oneofOld parsers crash on unknown variantAdd outside the oneof; integrate later via wrapper
Rename without deprecatingCodegen consumers break at compile timeAdd new field, reserve old name
Use enum value 0 for UNKNOWN and re-purposeHidden meaning changeReserve enum value 0 explicitly for UNSPECIFIED
Treat string ↔ bytes as always safeUTF-8 invariant requiredVerify the data is UTF-8 valid first
Skip buf breaking on PRManual review misses subtle breakagebuf breaking --against main in CI
Use WIRE category for codegen consumersGenerated code breaks on field rename even if wire OKUse FILE / PACKAGE
One global proto fileAll consumers locked to single evolution pathPer-bounded-context proto files

Limitations

  • buf categories cover binary breakage. Semantic breakage (a field's meaning changes) is not detectable. Document semantic changes in commit messages.
  • JSON name changes (camelCase ↔ snake_case) detected only in WIRE_JSON.
  • No transitive analysis. A message field whose type is an imported message: buf doesn't follow the import.
  • Doesn't enforce naming conventions. buf lint is separate from buf breaking.

References

Related skills

ghz-load

Wraps ghz, the gRPC load testing tool, for throughput and latency benchmarking. Covers test invocation (--proto + --call + host:port; or --protoset for compiled descriptors), load parameters (-n total requests, -c concurrency, -r RPS rate limit, -z duration), output formats (json/csv/html/influx-summary for CI consumption), the metrics reported (RPS achieved, latency p50/p95/p99, status-code distribution, errors), and CI integration patterns for regression gating. Use when benchmarking a gRPC service's throughput or detecting latency regressions in CI.

grpc-mock

Wraps gRPC server-mocking patterns for client-side tests: Go bufconn (in-memory net.Listener via google.golang.org/grpc/test/bufconn) + mockgen-generated interface mocks, Python pytest-grpc fixtures + unittest.mock patching of stubs, JVM grpc-mock library / in-process gRPC server (InProcessServerBuilder), Node @grpc/grpc-js fake server with NewServer-on-port-0. Also carries the interceptor-layer test patterns (Go / Java / grpc-js auth, retry, logging, error-mapping, chained ordering via a spy handler) in references/interceptors.md. Use when writing client-side tests that need a controllable gRPC server response (success cases, error cases, timeouts, single-response error injection) without spinning up a real backend, or when testing a gRPC interceptor. For multi-message streaming-sequence tests (server-streaming, bidi), use grpc-streaming-test-author instead. Distinct from grpcurl-cli (ad-hoc CLI invocation against a real server) and ghz-load (perf against a real server).

grpc-streaming-test-author

The single gRPC-streaming test home: builds streaming-RPC test suites from a proto definition. Classifies each RPC by pattern (unary, server-streaming, client-streaming, bidi), then emits the required categories per pattern - ordering preservation, completion semantics (server close after stream end, client half-close), cancellation, deadline handling, partial-stream failure. Produces skeletons for Go (bufconn + Send/Recv), Python (iterators), JVM (StreamObserver), Node (call.write/end); carries the 17-code gRPC status catalog (retry semantics per AIP-194, grpc-gateway HTTP mapping) in references/status-codes.md and the wire-level / live-server streaming patterns (deadline propagation, server-side cancellation, metadata, ghz load) in references/wire-level-testing.md. Use when adding tests for a new or existing streaming RPC, auditing a suite for uncovered categories, or asserting status-code behavior. Different test surface from grpc-mock (the in-process harness itself).

grpcurl-cli

Wraps grpcurl, the curl-equivalent CLI for gRPC. Covers descriptor sources (server reflection default, --import-path + --proto for proto files, --protoset for compiled descriptor sets), service discovery (`list`, `describe`), invoking unary RPCs (`-d '{...}'`, `-d @file.json`, `-d @` for stdin), streaming RPCs (newline-delimited JSON via stdin), TLS configuration (--cacert, --cert, --key, --insecure, --plaintext), header injection (-H 'Authorization: Bearer ...'), and exit codes. Use for ad-hoc gRPC debugging, smoke testing, scriptable PR-time gates, and CLI-based interaction with reflective gRPC services.