Skip to main content
aspect buildifier formats Starlark files (BUILD, BUILD.bazel, MODULE.bazel, .bzl, .axl, WORKSPACE and more) using the buildifier binary from buildifier_prebuilt. It’s registered as an alias of aspect format with format.alias() in .aspect/config.axl. That makes it a CLI command with no BUILD target or rules_lint dependency: a bazel_dep on buildifier_prebuilt and a few lines of AXL. aspect buildifier runs through aspect format: the same change detection, the same drift check, the same --severity behavior and the same artifact upload. Only the formatter binary and the file patterns differ.

Setup

MODULE.bazel:
.aspect/config.axl:
This registers aspect buildifier as a real CLI command. Run it locally:
—scope=all covers a narrower file set than —scope=changed. In —scope=all the format task hands off discovery to buildifier’s -r . tree walk, which has a hard-coded list of recognized file types: BUILD, BUILD.bazel, MODULE.bazel, WORKSPACE, WORKSPACE.bazel, *.bzl, *.star. Files matching the alias’s include_patterns but not on buildifier’s list, notably *.axl, *.MODULE.bazel, Tiltfile and BUCK, are skipped. include_patterns filters the changed-file list in —scope=changed and the post-format diff in both modes, but it doesn’t extend buildifier’s tree walk.In —scope=changed (the default) the task passes the changed file list to buildifier positionally, so every extension in include_patterns is formatted. The same applies when you pass files explicitly (aspect buildifier path/to/file.axl).For a CI job that needs an extension buildifier doesn’t discover, prefer —scope=changed against a broader base ref, or invoke buildifier on the file set yourself.

Configuration

All aspect format configuration applies: --scope, --severity, --include-pattern, --exclude-pattern, --upload-format-diff. The format.alias() defaults set the formatter target and file patterns so you don’t repeat them on every invocation. To add or remove file patterns, keep run_in and formatter_args_for_tree_walk and change include_patterns:
.aspect/config.axl

CI example

.github/workflows/buildifier.yaml
The --task:name matches the alias name you registered. Complete pipeline examples shows the same setup on Buildkite, GitLab CI and CircleCI, and on Aspect Workflows CI runners.