Skip to main content
Version: 5.9.x


Buildifier is a formatter and linter for Bazel code (BUILD and *.bzl files).

Under Workflows, linting is modeled using the lint task. However, that task only runs linters over *_library targets, and BUILD files are not included in any such target. Therefore, Buildifier is provided as a special case.

The simplest configuration looks like this:

- buildifier:

Workflows will bazel run //:buildifier.check, and it exits non-zero, then the task will fail. It will print the suggested changes that the developer should apply to fix it, by running bazel run //:buildifier.


You can choose specific targets to use for running Buildifier:

- buildifier:
# Workflows will 'bazel run' this target to verify that buildifier is "happy"
target: //path/to:buildifier_check
# Developers will be asked to 'bazel run' this target to apply Buildifier suggestions
fix_target: //path/to:buildifier

Per the Buildifier documentation, the "check" target should use mode = diff and lint_mode = warn while the "fix" target should use mode = fix and lint_mode = fix.


The exhaustive list of attributes for the buildifier task are found at Buildifier.