Skip to content

Buf CLI#

The Buf CLI is the ultimate tool for modern, fast, and efficient Protobuf API management. It makes crucial tasks like code generation, breaking change detection, and linting easy to configure, and integrates seamlessly with your existing workflows, so you can focus on what matters most: writing great APIs.

Commands#

Buf's commands change Protobuf management from a chore into a workflow: generate code, safely evolve your schemas, test APIs, and collaborate with others through the Buf Schema Registry:

  • generate: Generate code stubs from Protobuf files using protoc plugins
  • breaking: Verify no breaking changes have been made, to guard against compatibility issues
  • lint : Lint your Protobuf files according to best practices
  • format: Format your Protobuf files for consistency
  • curl: Test your APIs by invoking an RPC endpoint, similar to using curl
  • convert: Convert a message from binary to JSON or vice versa—useful when debugging or testing
  • registry, push, and export: Manage your repositories in the Buf Schema Registry
  • config: Generate and manage Buf configuration files

See the Buf CLI reference for complete options and flags for each command.

Configuration files#

The Buf CLI uses several configuration files, depending on the task:

buf.yaml#

buf.yaml defines a workspace and the configurations for each module within it. It's the primary configuration file, and defines each module's directory, name, lint and breaking configurations, and any files to exclude, along with the workspace's shared dependencies.

buf.gen.yaml#

buf.gen.yaml defines the set of code generation plugins, their options, and the inputs used by buf generate when generating code from your Protobuf files. It also allows you to enable and configure managed mode.

buf.lock#

buf.lock records exact dependency versions to ensure consistent builds across your team and CI.