Use when working with Protocol Buffer (.proto) files, buf.yaml, buf.gen.yaml, or buf.lock...
.proto filesbuf.yaml or buf.gen.yamlBefore writing proto code, review existing .proto files in the project.
Match conventions for naming, field ordering, structural patterns, validation, and documentation style.
If none exists, ask the user what style should be used or an existing library to emulate.
Always run after making changes:
buf format -w && buf lint
Check for a Makefile firstβmany projects use make lint or make format.
Fix all errors before considering the change complete.
| Task | Reference |
|---|---|
| Field types, enums, oneofs, maps | quick_reference.md |
| Schema evolution, breaking changes | best_practices.md |
| Validation constraints | protovalidate.md |
| Complete service examples | examples.md, assets/ |
| buf CLI, buf.yaml, buf.gen.yaml | buf_toolchain.md |
| Migrating from protoc | migration.md |
| Lint errors, common issues | troubleshooting.md |
Create directory structure:
proto/
βββ buf.yaml
βββ buf.gen.yaml
βββ company/
βββ domain/
βββ v1/
βββ service.proto
Use assets/buf.yaml as starting point
Use assets/buf.gen.*.yaml for code generation config
| Template | Use For |
|---|---|
buf.gen.go.yaml |
Go with gRPC |
buf.gen.go-connect.yaml |
Go with Connect |
buf.gen.ts.yaml |
TypeScript with Connect |
buf.gen.python.yaml |
Python with gRPC |
buf.gen.java.yaml |
Java with gRPC |
Located in assets/proto/example/v1/:
| Template | Description |
|---|---|
book.proto |
Entity message, BookRef oneof, enum |
book_service.proto |
Full CRUD with batch ops, pagination, ordering |
buf format -w && buf lintreserved 4;
reserved "old_field_name";
buf breaking --against '.git#branch=main' to verifySee protovalidate.md for constraint patterns:
(buf.validate.field).required = true.string.uuid, .string.email, .string.uri.int32.gt, .uint32.lte.repeated.min_items, .repeated.max_itemsAfter making changes:
buf format -w (apply formatting)buf lint (check style rules)buf breaking --against '.git#branch=main' (if modifying existing schemas)