- OCI images — put a
go_imagetarget next to each Go file that has amain: go_image.axl. - Script targets — create a
js_binarytarget for each entry inpackage.json#scriptsthat matches a simple pattern: package-json-scripts.axl. - Lint tests — add a linting test next to every library, for example a
ruff_testfor every package with Python code. - Tool config detection — look for a specific config file and generate a rule that calls the tool:
- find
webpack.config.js→ generate awebpack_bundlerule - find
jest.config.mjs→ generate ajest_testtarget
- find
- Pattern-driven codegen — if a pattern exists in a source file, generate a custom extraction target. For example, i18n with go-i18n: take a naming convention like
locales/**/*.jsonand generate message-translation targets. - Copy to bin — scan for sources that match a pattern and generate
copy_to_bin.
Aspect 150: BUILD file generators in Starlark
Extending existing languages
Use small Starlark Gazelle extensions to augment the stock Gazelle binary — generate OCI images, lint tests, codegen targets, and other custom rules alongside existing languages.
In practice, very few people actually need to write an extension for a new language. Many extension implementations in Go already exist, and more are likely to be written.
However, it’s not possible to customize the Go extensions other than by forking them or via the limited directives they expose. You can use Starlark extensions to do smaller jobs that augment what you get from the standard Gazelle binary. A few patterns we’ve seen in the wild:

