Maturity Matrix

Incremental builds: only changed targets

Incremental builds with only changed targets rebuild exactly and only the build targets that depend on files that have changed since the last build.

  • ·Advanced build system (Bazel, Buck2, or Pants) is adopted for primary codebase
  • ·Remote execution (EngFlow or equivalent) distributes build steps across multiple machines
  • ·Incremental builds run only changed targets (not full rebuild)
  • ·BUILD file maintenance is assigned to specific team members or automated
  • ·Remote cache hit rate exceeds 80%

Evidence

  • ·Bazel/Buck2/Pants BUILD files in repository
  • ·Remote execution configuration (EngFlow, BuildBuddy, or equivalent)
  • ·Build log showing incremental target selection

What It Is

Incremental builds with only changed targets rebuild exactly and only the build targets that depend on files that have changed since the last build. This is fundamentally different from module-level incremental compilation in Maven or Gradle, which recompiles an entire module when any file within it changes. True target-level incrementality requires a precise, complete dependency graph - exactly what Bazel BUILD files and Buck2 BUCK files provide.

The mechanism is straightforward in concept: the build system maintains a hash of every input to every build action. When a source file changes, its hash changes. Every target that directly or transitively depends on that file has an input hash change, and must be rebuilt. Every target that doesn't depend on the changed file has an identical input hash to the previous build, and can be retrieved from cache. With Bazel, this computation happens before any compilation starts - the build system knows exactly which targets will be cache hits and which need to be rebuilt.

For a monorepo with 10,000 build targets, a change to a leaf utility function might affect 50 targets directly. A change to a widely-used base library might affect 5,000 targets. The build system computes the affected set precisely and rebuilds only that set - without redundant work and without missing anything. This precision is what makes large-codebase builds practical for agents doing iterative work.

The practical impact is dramatic. In a well-structured codebase with fine-grained targets, a one-line change in a leaf module rebuilds in under 5 seconds regardless of how large the overall codebase is. The build system doesn't care that there are 500,000 lines of code it doesn't need to touch - it skips them all. This property is what makes AI agent iteration loops viable at large codebase scale: the agent's build time is proportional to what changed, not to the total codebase size.

Why It Matters

  • Build time is proportional to change scope, not codebase size - a one-line change always takes the same time to build regardless of whether the codebase has 10,000 or 10,000,000 lines
  • Agent iteration loops hit only the relevant build work - an agent fixing a bug in one module doesn't wait for unrelated modules to compile; the build system proves they're unaffected and skips them
  • Developers can work confidently without full rebuilds - when the build system guarantees correct incrementality, there's no reason to run clean; developers and agents trust incremental build results
  • Large monorepos become viable for agent workflows - without target-level incrementality, monorepos are impractical for agent iteration; with it, a 10-million-line monorepo has the same iteration speed as a 100,000-line service
  • Cache hit rates are objectively measurable and improvable - Bazel reports exact cache hit and miss statistics; teams can track and optimize their cache effectiveness systematically

Getting Started

6 steps to get from here to the next level

Common Pitfalls

Mistakes teams actually make at this stage - and how to avoid them

How Different Roles See It

B
BobHead of Engineering

Bob's team completed the Bazel migration 3 months ago and is running with a remote cache. He's looking at the metrics: average agent incremental build time is 8 seconds, but there are outliers at 2-3 minutes. These outliers happen when agents change shared proto files or base utility libraries. Bob wants to understand the pattern and reduce the outlier frequency.

What Bob should do - role-specific action plan

S
SarahProductivity Lead

Sarah has added "agent build time by change type" to her DevEx dashboard. She can see that 90% of agent builds complete under 15 seconds, but 10% take over 90 seconds. She wants to reduce the 10% tail. The data shows the long-tail builds are consistently triggered by changes to 12 specific "high-fan-out" targets.

What Sarah should do - role-specific action plan

V
VictorStaff Engineer - AI Champion

Victor has set up automated affected-target analysis as part of his agent workflow. Before submitting any agent-generated branch to CI, a pre-CI step runs bazel query 'rdeps(//..., //path/to:changed_targets)' and reports the affected target count. If it's over 500, the agent adds a comment to the PR explaining the wide impact and requests human review before CI runs. This prevents agents from accidentally submitting wide-impact changes that saturate CI.

What Victor should do - role-specific action plan