buf
The best way of working with Protocol Buffers.
Buf is a CLI tool for Protocol Buffers that lints API definitions, detects breaking changes, generates code, and formats .proto files in one fast tool.
Buf is a command-line tool for working with Protocol Buffers, which is a format for defining the structure of data and the shape of APIs. When software systems need to talk to each other over a network, they need to agree on a common format. Protocol Buffers (often called Protobuf) is a widely used way to define that format in a structured file, and those definitions then get turned into code in whatever programming language the team uses.
The challenge has historically been that the tooling around Protobuf was awkward to set up and use. Buf addresses that by providing a single tool that handles the most common tasks: checking that your API definitions follow good design practices, catching changes that would break existing clients, generating code from your definitions, and formatting definition files consistently. These are the kinds of checks that teams otherwise have to set up manually or skip entirely.
One specific feature worth noting is the breaking change detector. When you update an API definition, Buf can compare the new version against the old one and flag any changes that would cause existing code depending on that API to stop working. This is useful for teams that maintain APIs used by other teams or external developers.
Buf also connects to a cloud service called the Buf Schema Registry, which is a hosted place to store and share Protobuf definitions across teams or organizations. Using the registry is optional; the core command-line features work without it.
The tool runs on Linux, Mac, and Windows, and can be installed via package managers like Homebrew or npm, or as a Docker image. It is built with speed as a priority, compiling Protobuf sources faster than the standard compiler by using all available CPU cores.
Where it fits
- Lint .proto files to catch bad API design before code review
- Detect breaking changes in Protobuf API definitions before deploying to prevent client breakage
- Generate client and server code from .proto files across multiple programming languages
- Share and version Protobuf schemas across teams using the optional Buf Schema Registry