bazel-diagnose

Diagnose broken Bazel builds by routing symptoms to root-cause measurements.

Updated Aug 13, 2026
One-click install
npx skills add https://github.com/ocx-sh/grimoire-lore --skill bazel-diagnose-ocx-sh
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bazel-diagnose
Source: https://github.com/ocx-sh/grimoire-lore/tree/main/skills/bazel-diagnose
Command: npx skills add https://github.com/ocx-sh/grimoire-lore --skill bazel-diagnose-ocx-sh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? A Bazel build that is slow, missing the cache, rebuilding for no reason, or failing on only one machine is hard to debug because the obvious tools (exit codes, --explain, help output) routinely mislead. This Skill routes each symptom to the one measurement that names the actual root cause, verified against Bazel 8.7.0 and 9.2.0. ## Core Features & Use Cases - Symptom-based routing: Eight diagnostic paths covering slow builds and analysis, unexpected cache misses, cache/BES outages and exit code 39, non-hermetic or nondeterministic actions, flaky tests, repository-rule and module-extension refetches, target-selection misses, and flags that appear not to exist. - Measured, version-aware procedures: Every command was checked on Bazel 8.7.0 and 9.2.0 on Linux, with explicit notes where behavior differs between majors or host platforms, and citations to bazel-quality rule IDs. - Guardrails against false fixes: A "never edit the check" table blocks common violations like tagging actions no-cache, setting flaky = True, or committing --sandbox_debug, plus a four-part receipt format (symptom, root cause, evidence, fix or gap) for reporting. - Use Case: CI never hits the remote cache. The skill walks you through the execution-log diff recipe (execlog parser on two runs), shows that an action absent from the log is a local action-cache hit, and identifies the --action_env=WS=$PWD line in .bazelrc as the key-busting mechanism. ## Quick Start Diagnose why my Bazel build rebuilt everything with no source changes using the bazel-diagnose skill.

Frequently Asked Questions about bazel-diagnose

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug unexpected Bazel cache misses?▼

Capture an execution log with --execution_log_compact_file on two runs, convert both with the execlog parser built from a bazelbuild/bazel source checkout, and diff the outputs. Differing environment_variables, command_args, or input digests name the cause; never use --explain, which misreports disk-cache hits as new actions.

Why does my Bazel build re-analyze everything with no source change?▼

Mixing bazel build -c opt with bazel cquery in one session makes each discard the other's analysis cache. Add --noallow_analysis_cache_discard and re-run the sequence; a hard error confirms the discard, while no error means the cost is elsewhere.

Does a Bazel remote cache outage fail the build?▼

No. On a cache-only build with no --remote_executor, an unreachable cache produces a WARNING and a green local build with exit 0 on both Bazel 8.7.0 and 9.2.0. A lane that must fail on cache outage needs a reachability check outside Bazel.

How do I detect flaky Bazel tests instead of masking them?▼

Run bazel test --runs_per_test=100 --runs_per_test_detects_flakes //the:test. The flaky = True attribute and --flaky_test_attempts both stop at the first success, so they manufacture a green result rather than measure the flake.

Does bazel analyze-profile work on Bazel 9?▼

No. The command was deleted at Bazel 9.0.0 even though the frozen 9.1.0 documentation snapshot still lists it. On 9.x, open the JSON trace profile from --profile in chrome://tracing or Perfetto and read the phase markers directly.

When should I not use this Bazel diagnosis procedure?▼

Do not use it to decide whether to adopt Bazel or to stand a workspace up from scratch; that is the bazel-adopt skill's scope. It also does not restate build standards, which live in the bazel-quality rules it cites by ID.