# Code Bazel query and cquery Dependency Analysis Status: public Confidence: medium (0.685) (verified) Last verified: 2026-06-03 Generation: ai_structured ## TL;DR Bazel query and cquery help code agents inspect dependency graph evidence before changing build targets or affected-test logic. ## Core Explanation In Bazel repositories, dependency impact is encoded in the build graph rather than only in source imports. Agents should use query for structural dependency questions and cquery when configurations, build flags, select statements, or transitions affect the actual analyzed graph. This distinction matters for code intelligence. A target can appear unrelated at the source level but become relevant through generated code, toolchains, configuration-specific deps, or visibility constraints. Agents should cite the query expression and target pattern used when explaining an impact analysis result. ## Source-Mapped Facts - Bazel documentation describes the Bazel query language as a language for asking questions about dependencies in the build graph. ([source](https://bazel.build/query/language)) - Bazel documentation says cquery runs after the analysis phase and exposes information about configured targets. ([source](https://bazel.build/query/cquery)) - Bazel documentation says cquery is useful when build options change the dependency graph, such as through select statements. ([source](https://bazel.build/query/cquery)) ## Further Reading - [Bazel Query Language](https://bazel.build/query/language) - [Bazel cquery](https://bazel.build/query/cquery)