name: Bazel
description: "Bazel build system — MODULE.bazel (bzlmod), custom rules, test targets, Starlark scripting, CI integration, and remote caching. USE WHEN bazel, bazel build, MODULE.bazel, bzlmod, bazel rule, starlark, BUILD file, bazel test, bazel CI, bazel remote cache, bazel query, bazel run, bazel error, custom rule, bazel workspace, bazel dependency."
Bazel
Hermetic build system with caching, reproducibility, and custom rules via Starlark.
Quick Reference
- Module file:
MODULE.bazel — declares deps (WORKSPACE removed in Bazel 9)
- Build files:
BUILD.bazel — targets per package
- Rules: Starlark (Python-like, deterministic, no I/O in analysis)
- Tests: Rule produces script, exit 0 = pass, non-zero = fail
- Caching: Same inputs = instant skip. Remote cache shares across CI jobs.
- Formatter:
buildifier -r . — mandatory for clean .bzl files
- Query:
bazel query "deps(//target)" — explore the dependency graph
References
Scripts
| Script |
Purpose |
scripts/bazel-debug.sh |
Query deps, rdeps, changed targets, profile builds |
scripts/bazel-init.sh |
Bootstrap a new project with MODULE.bazel + .bazelrc |
External References