protobuf
БесплатноБез исполняемых скриптовНе проверенDefine data schemas with Protocol Buffers (protobuf), Google's language-neutral binary serialization format, and generate typed code for TypeScript, Go…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Protocol Buffers — Efficient Binary Serialization
Overview
Protocol Buffers describe data in .proto files; a compiler generates classes for your language, and messages are encoded in a compact binary format identified by field numbers, not names. Payloads are usually much smaller than JSON and parsing is faster, and the schema is a checked contract between services. The same files define gRPC services. Current releases at the time of writing: protoc/protobuf v36.2 (September 2026), buf 1.73, @bufbuild/protobuf and protoc-gen-es 2.16. Schemas start with syntax = "proto3"; (still fully supported) or the newer edition = "2023"; / "2024", which replaces syntax and makes behaviours such as field presence a per-file or per-field feature.
Instructions
1. Install the tools
# Compiler (check the version: package managers can be old)
sudo apt install -y protobuf-compiler # Debian/Ubuntu
brew install protobuf # macOS
winget install protobuf # Windows
protoc --version # should be 33 or newer
# buf: linting, breaking-change detection, code generation
brew install bufbuild/buf/buf # or: npm install --save-dev @bufbuild/buf
Binary releases of protoc (zip files per OS) are on the GitHub releases page of protocolbuffers/protobuf.
2. Write the schema
Use one directory per package, e.g. proto/myapp/v1/user.proto. Every RPC gets its own request and response message (buf's STANDARD lint rules require it).
syntax = "proto3";
package myapp.v1;
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/northwind/api/gen/myapp/v1;myappv1";
enum Role {
ROLE_UNSPECIFIED = 0;
ROLE_USER = 1;
ROLE_ADMIN = 2;
}
message User {
reserved 4, 7; // numbers of deleted fields
reserved "old_field_name";
string id = 1;
string name = 2;
string email = 3;
Role role = 5;
repeated string tags = 6;
map<string, string> metadata = 8;
google.protobuf.Timestamp created_at = 9;
oneof contact { // at most one is set
string phone = 10;
string slack_id = 11;
}
optional string bio = 12; // has explicit presence: unset differs from ""
}
message GetUserRequest { string id = 1; }
message GetUserResponse { User user = 1; }
message UpdateUserRequest {
User user = 1;
google.protobuf.FieldMask update_mask = 2; // which fields to change
}
message UpdateUserResponse { User user = 1; }
service UserService {
rpc GetUser(GetUserRequest) returns (GetUserResponse);
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
}
Return google.protobuf.Empty only if you accept lint warnings: it needs import "google/protobuf/empty.proto";, and buf recommends a dedicated empty response message.
In an edition file the first line is edition = "2023";, optional and required are not used (fields have explicit presence by default; write features.field_presence = IMPLICIT to get proto3 behaviour), and everything else above looks the same.
3. Generate code with buf
buf.yaml (module and rules) and buf.gen.yaml (plugins) live next to the proto directory:
# buf.yaml
version: v2
modules:
- path: proto
lint:
use: [STANDARD]
breaking:
use: [FILE]
# buf.gen.yaml — TypeScript with protobuf-es; the plugin comes from npm
version: v2
plugins:
- local: node_modules/.bin/protoc-gen-es
out: src/gen
opt: target=ts
npm install @bufbuild/protobuf
npm install --save-dev @bufbuild/protoc-gen-es @bufbuild/buf
npx buf lint
npx buf generate # writes src/gen/myapp/v1/user_pb.ts
With plain protoc: protoc -Iproto --python_out=gen --go_out=gen --go_opt=paths=source_relative proto/myapp/v1/user.proto (Go also needs go install google.golang.org/protobuf/cmd/protoc-gen-go@latest, and protoc-gen-go-grpc for services).
4. Use the generated code (TypeScript)
protobuf-es v2 generates plain types plus a schema object per message; there are no getters and setters.
import { create, toBinary, fromBinary, toJsonString } from "@bufbuild/protobuf";
import { timestampFromDate } from "@bufbuild/protobuf/wkt";
import { UserSchema, Role } from "./gen/myapp/v1/user_pb";
const user = create(UserSchema, {
id: "usr_8421",
name: "Maria Santos",
email: "[email protected]",
role: Role.ADMIN,
createdAt: timestampFromDate(new Date("2026-03-01T10:00:00Z")),
contact: { case: "slackId", value: "U02ABC" }, // oneof is a { case, value } object
});
const bytes = toBinary(UserSchema, user); // Uint8Array
const same = fromBinary(UserSchema, bytes);
console.log(toJsonString(UserSchema, same)); // canonical protobuf JSON
For RPC from TypeScript use Connect (@connectrpc/connect, @connectrpc/connect-node, v2) with protoc-gen-es v2, which also speaks gRPC and gRPC-Web.
Установить protobuf в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл protobuf?
Define data schemas with Protocol Buffers (protobuf), Google's language-neutral binary serialization format, and generate typed code for TypeScript, Go, Python and other languages. Use when the user asks about ".proto files", "protobuf schema", "gRPC service definition", "buf generate", "protoc", "binary serialization", or how to change a schema without breaking existing clients (field numbers, reserved fields, backward compatibility).
Как установить скилл protobuf?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл protobuf запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic