protobuf — скилл для Claude Code: proto, buf и gRPC
Помогает писать и проверять .proto-файлы, настраивать buf и разбирать ошибки линтера. Пригодится, если проект уже на Protocol Buffers.
npx skills add bufbuild/claude-plugins --skill protobuf -a claude-codeЧто делает protobuf
Скилл включается, когда в работе появляются .proto, buf.yaml, buf.gen.yaml или buf.lock. Он закрывает проектирование схем, сервисы gRPC и Connect, ограничения protovalidate и разбор ошибок buf lint и breaking changes.
Внутри набор справочников: быстрый обзор типов полей и oneof, best practices по эволюции схемы, шаблоны buf.gen.*.yaml под Go, TypeScript, Python и Java, примеры сервисов и чек-лист ревью proto API. Перед написанием кода скилл советует посмотреть существующие .proto в проекте и повторить их стиль; если файлов нет, он спросит у вас, на что ориентироваться.
После правок он прогоняет buf format -w && buf lint, а при изменении существующей схемы добавляет buf breaking --against '.git#branch=main'. Сначала стоит проверить, нет ли в проекте Makefile с make lint или make format. Для production-API скилл требует ограничения protovalidate на каждое поле — без них проверка не считается законченной.
Какие задачи решает
- написать
.protoв стиле, принятом в проекте - поднять
buf.yamlиbuf.gen.yamlс нуля - добавить ограничения protovalidate на поля
- разобрать ошибки
buf lintи breaking changes - удалить поле, не сломав совместимость схемы
Примеры запросов агенту
- добавь поле в
service.protoи поставь ограничения protovalidate - почему падает
buf lintв этом файле - сгенерируй конфиг кодогенерации под Go с Connect
Как установить protobuf
1Через Skills CLI (Vercel)
npx skills add bufbuild/claude-plugins --skill protobuf -a claude-code2Вручную: положить файлы
~/.claude/skills/protobuf/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/protobuf/
1Через Skills CLI (Vercel)
npx skills add bufbuild/claude-plugins --skill protobuf -a codex2Вручную: положить файлы
.agents/skills/protobuf/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add bufbuild/claude-plugins --skill protobuf -a cursor2Вручную: положить файлы
.cursor/skills/protobuf/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install bufbuild/claude-plugins protobuf2Вручную: положить файлы
.github/skills/protobuf/SKILL.md1Через Skills CLI (Vercel)
npx skills add bufbuild/claude-plugins --skill protobuf -a gemini-cli2Командой платформы
gemini skills install https://github.com/bufbuild/claude-plugins --path plugins/protobuf/skills/protobufВручную: положить файлы
.devin/skills/protobuf/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add bufbuild/claude-plugins --skill protobuf -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о protobuf
Как установить protobuf в Claude?
Выполните npx skills add bufbuild/claude-plugins --skill protobuf -a claude-code. Скилл окажется в ~/.claude/skills/protobuf/SKILL.md.
Что делает скилл protobuf?
Помогает проектировать .proto-схемы, настраивать buf, добавлять ограничения protovalidate и чинить ошибки линтера и breaking changes.
Какие инструменты нужны для работы скилла?
Он опирается на buf CLI: команды buf format, buf lint, buf breaking и buf dep update. Для кодогенерации берутся шаблоны buf.gen.*.yaml из комплекта.
Исходный текст
SKILL.md · Apache-2.0
---
name: protobuf
description: >-
Use when working with Protocol Buffer (.proto) files, buf.yaml, buf.gen.yaml,
or buf.lock. Covers proto design, buf CLI, gRPC/Connect services, protovalidate
constraints, schema evolution, and troubleshooting lint/breaking errors.
filePatterns:
- "**/*.proto"
- "**/buf.yaml"
- "**/buf.*.yaml"
- "**/buf.gen.yaml"
- "**/buf.gen.*.yaml"
- "**/buf.lock"
---
# Protocol Buffers
## When You Need This Skill
- Creating or editing `.proto` files
- Setting up `buf.yaml` or `buf.gen.yaml`
- Designing gRPC or Connect services
- Adding protovalidate constraints
- Troubleshooting buf lint or breaking change errors
## Core Workflow
### 1. Match Project Style
Before 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.
### 2. Write Proto Code
- Apply universal best practices from [best_practices.md](references/best_practices.md)
- Add [protovalidate](references/protovalidate.md) constraints to every field—this is not optional for production APIs
- For service templates, see [assets/](assets/)
### 3. Verify Changes
**Always run after making changes:**
```bash
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.
## Quick Reference
| Task | Reference |
|------|-----------|
| Field types, enums, oneofs, maps | [quick_reference.md](references/quick_reference.md) |
| Schema evolution, breaking changes | [best_practices.md](references/best_practices.md) |
| Validation constraints | [protovalidate.md](references/protovalidate.md) |
| Complete service examples | [examples.md](references/examples.md), [assets/](assets/) |
| buf CLI, buf.yaml, buf.gen.yaml | [buf_toolchain.md](references/buf_toolchain.md) |
| Migrating from protoc | [migration.md](references/migration.md) |
| Lint errors, common issues | [troubleshooting.md](references/troubleshooting.md) |
| Proto API review checklist | [review_checklist.md](references/review_checklist.md) |
## Project Setup
### New Project
1. Create directory structure:
```
proto/
├── buf.yaml
├── buf.gen.yaml
└── company/
└── domain/
└── v1/
└── service.proto
```
2. Use `assets/buf.yaml` as starting point
3. Add `buf.build/bufbuild/protovalidate` as a dependency in `buf.yaml` and run `buf dep update`
4. Use `assets/buf.gen.*.yaml` for code generation config
### Code Generation Templates
| 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 |
### Proto File Templates
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 |
## Common Tasks
### Add a new field
1. Use next sequential field number
2. Add [protovalidate](references/protovalidate.md) constraints: every field should have validation appropriate to its type (format validators, length bounds, numeric ranges, enum constraints, etc.)
3. Document the field
4. Run `buf format -w && buf lint`
### Remove a field
1. Reserve the field number AND name:
```protobuf
reserved 4;
reserved "old_field_name";
```
2. Run `buf breaking --against '.git#branch=main'` to verify
### Add protovalidate constraints
Every field in a production API should have appropriate validation.
See [protovalidate.md](references/protovalidate.md) for the full reference.
Common constraints:
- String formats: `.string.uuid`, `.string.email`, `.string.uri`, `.string.pattern`
- String bounds: `.string.min_len`, `.string.max_len`
- Numeric bounds: `.int32.gte`, `.uint32.lte`
- Enum validation: `.enum.defined_only`, `.enum.not_in = 0`
- Repeated bounds: `.repeated.min_items`, `.repeated.max_items`
- Required fields: `(buf.validate.field).required = true`
- Oneof required: `(buf.validate.oneof).required = true`
## Verification Checklist
After making changes:
- [ ] Every field has appropriate protovalidate constraints
- [ ] `buf format -w` (apply formatting)
- [ ] `buf lint` (check style rules)
- [ ] `buf breaking --against '.git#branch=main'` (if modifying existing schemas)
© bufbuild · Apache-2.0 · bufbuild/claude-plugins