Buf(1) Buf(1) (NAME) buf-generate - protoc (SYNOPSIS) buf generate [flags] (DESCRIPTION) : # buf.gen.yaml # . # v1beta1 v1 v2. # . version: v2 # clean true zip / jar # "out" . false . # . clean: true # . # . plugins: # buf.build/protocolbuffers/go v1.28.1. # . # "remote" "local" "protoc_builtin" . - remote: buf.build/protocolbuffers/go:v1.28.1 # . # . out: gen/go # (revision) Buf # . revision: 4 # . # . # . opt: paths=source_relative # (imported) . # . include_imports: false # (Well-Known Types) . # . include_wkt: false # . # . types: - "foo.v1.User" # . # . exclude_types: - "buf.validate.oneof" - "buf.validate.message" - "buf.validate.field"" # "${PATH}" . - local: protoc-gen-es out: gen/es include_imports: true include_wkt: true # . - local: ["go", "run", "path/to/plugin.go"] out: gen/plugin # . : # # 1. "directory" # # buf . # : # # for dir in $(find . -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do # protoc -I . $(find "${dir}" -name '*.proto') # done # # Protobuf # . # # 2. "all" # # buf . # : # # protoc -I . $(find . -name '*.proto') # # . # (remote) . # # "directory" . . # . strategy: directory # "protoc_builtin" protoc "-protoc-gen". - protoc_builtin: java out: gen/java # protoc. protoc "${PATH}" . # . protoc_path: path/to/protoc # (Managed mode) / . managed: # . enabled: true # (override rule) # / . # # : # - java_package # - java_package_prefix # - java_package_suffix # - java_multiple_files # - java_outer_classname # - java_string_check_utf8 # - go_package # - go_package_prefix # - optimize_for # - csharp_namespace # - csharp_namespace_prefix # - ruby_package # - ruby_package_suffix # - objc_class_prefix # - php_namespace # - php_metadata_namespace # - php_metadata_namespace_suffix # - cc_enable_arenas # # . # : # - jstype # # # . # . override: # "go_package_prefix" "foo/bar/baz" . - file_option: go_package_prefix value: foo/bar/baz # "java_package_prefix" "net.foo" "buf.build/foo/bar". - file_option: java_package_prefix value: net.foo module: buf.build/foo/bar # "java_package_prefix" "dev" "file.proto". # "net.foo" "file.proto" . - file_option: java_package_prefix value: dev module: buf.build/foo/bar path: file.proto # "go_package" "x/y/z" "x/y/z". - file_option: go_package value: foo/bar/baz path: x/y/z # "jstype" "JS_NORMAL". - field_option: jstype value: JS_STRING field: foo.v1.Bar.baz # . # "overrides" . # . disable: # . - module: buf.build/googleapis/googleapis # . - module: buf.build/googleapis/googleapis path: foo/bar/file.proto # "java_multiple_files" . - file_option: java_multiple_files # "csharp_namespace" . - module: buf.build/acme/weather file_option: csharp_namespace # . # . # "directory" "git_repo" "module" "tarball" "zip_archive" # "proto_file" "binary_image" "json_image" "text_image" "yaml_image" . # . inputs: # . - directory: x/y/z # . - git_repo: https://github.com/acme/weather.git # . # . branch: dev # . # . subdir: proto # . # . depth: 30 # BSR. - module: buf.build/acme/weather # . # . types: - "foo.v1.User" - "foo.v1.UserService" # . # . exclude_types: - "buf.validate" # . # . paths: - a/b/c - a/b/d # . exclude_paths: - a/b/c/x.proto - a/b/d/y.proto # tarball. - tarball: a/b/x.tar.gz # . # . subdir: proto # . # ".tgz" ".tar.gz" Gzip . # ".tar.zst" Zstandard . # . compression: gzip # . # . strip_components: 2 # zip. - zip_archive: https://github.com/googleapis/googleapis/archive/master.zip # . # . strip_components: 1 # proto . - proto_file: foo/bar/baz.proto # false . # . include_package_files: true # Buf . # "yaml_image" "text_image" "json_image". - binary_image: image.binpb.gz # . # . compression: gzip "buf.gen.yaml" go grpc "protoc-gen-go" "protoc-gen-go-grpc" "$PATH" : # buf.gen.yaml version: v2 plugins: - local: protoc-gen-go out: gen/go opt: paths=source_relative - local: protoc-gen-go-grpc out: gen/go opt: - paths=source_relative - require_unimplemented_servers=false buf generate "buf.gen.yaml" . . . "." . buf.gen.yaml : $ buf generate ( "buf.gen.yaml" ): $ buf generate --template buf.gen.yaml . --template YAML JSON : $ buf generate --template '{"version":"v2","plugins":[{"local":"protoc-gen-go","out":"gen/go"}]}' bar.yaml: $ buf generate --template bar.yaml https://github.com/foo/bar.git bar/ bar/ out : $ buf generate --template bar.yaml -o bar https://github.com/foo/bar.git -o . --path : proto/foo proto/bar : $ buf generate --path proto/foo --path proto/bar proto/foo/foo.proto proto/foo/bar.proto : $ buf generate --path proto/foo/foo.proto --path proto/foo/bar.proto proto/foo : $ buf generate --template buf.gen.yaml https://github.com/foo/bar.git --path proto/foo . "proto" "--path proto" "--path proto/foo" "proto/foo" "proto" . . (Insertion points) . (OPTIONS) --clean[=false] jar zip . rm -rf --config="" buf.yaml --disable-symlinks[=false] CLI Buf Schema Registry --error-format="text" stderr . [text,json,msvs,junit,github- actions,gitlab-code-quality] --exclude-path=[] "proto/a/a.proto" "proto/a" --exclude-type=[] ( ) . . ".**" . . buf.gen.yaml -h, --help[=false] generate --include-imports[=false] (Well-Known Types) --include-wkt[=false] (Well-Known Types). include-imports-- true true -o, --output="." . out --path=[] "proto/a/a.proto" "proto/a" --template="" . YAML JSON --type=[] ( ) . . ".**" . buf.gen.yaml (OPTIONS INHERITED FROM PARENT COMMANDS) --debug[=false] --log-format="color" [text,color,json] --timeout=0s 0 (SEE ALSO) buf(1) (HISTORY) 2026-07-17 spf13/cobra Auto generated by spf13/cobra 2026-07-17 Buf(1)