Agentic Pattern Libraryby Vikas Goyal
← All patterns
54

Small-Change Budget

Also known as: PR size limit, change budget, small batches

Cap how large each agent change can be, so every change stays reviewable and easy to roll back.

TrackAI-native software delivery FamilyVerify Maturity Emerging ChangesDecisionVerification
01

Problem

An agent can rewrite twenty files as easily as two. Large changes are slow and hard to review, so reviewers skim them; when they fail in production, it’s hard to tell which part caused it, and rolling back undoes good work along with the bad. The speed agents gain writing code is lost in review queues and failed releases.

  • Agents have no natural sense of how big a change should be.
  • Review quality drops sharply as change size grows.
  • Some changes are genuinely large, like migrations or upgrades.
  • Splitting work has a cost in coordination and more PRs.
02

Solution

Set an explicit size budget for agent changes, such as a maximum number of changed lines or files, excluding generated files and tests. Put the budget in the project memory file so the agent plans to it, and enforce it in CI with a check that labels or blocks oversized PRs. When a task is bigger than the budget, the agent splits it into a stack of small, independently mergeable changes, each with its own description, behind feature flags if needed. Genuinely large mechanical changes, like a rename across the codebase, get an explicit exception with their own review approach.

03

Diagram

Large task~1,500 lines Agent plansplit to budget budget: 400 lines PR 1 · model PR 2 · conversion PR 3 · calculation PR 4 · PDF PR 5 · flag on Review + mergeone at a time CI size checkover budget → blocked each PR builds, passes tests and rolls back on its own

The budget shapes the plan, not just the PR. Big tasks become a stack of small changes that each pass review and roll back on their own.

04

When to use

Use it when

  • Agent PRs are often too large to review properly
  • Failed releases are hard to diagnose or roll back
  • Review waits grow as agents produce more code
  • Feature flags or a similar way to ship incomplete work exist

Avoid it when

  • Mechanical changes like codemods; review them by sampling instead
  • Teams without CI, where the check can't be enforced
  • Splitting would create changes that can't work on their own
05

Trade-offs

Latency More PRs, but each is reviewed quickly
Cost A CI check and a rule in the memory file
Complexity Splitting tasks, stacked PRs, feature flags
Reliability Reviewable changes and precise rollbacks

Gains

  • Each change gets a real review instead of a skim
  • Failures point to a small change and roll back cleanly
  • Steadier flow through review instead of large batches

Costs

  • More PRs to track and merge in order
  • Feature flags add their own complexity
  • Arbitrary limits can split work at awkward points
06

Worked example

Scenario
A team sets a budget of 400 changed lines per PR, excluding tests and generated files, after agent PRs kept stalling in review.
  1. Task“Add multi-currency support to invoicing.” The agent’s plan estimates about 1,500 lines.
  2. Agent planSplits it into 5 stacked PRs: currency model, conversion service, invoice calculation, PDF rendering, and a feature flag to turn it on. Each is under 400 lines.
  3. CI checkA sixth PR the agent opens later reaches 620 lines when it pulls in an unrelated cleanup. The check labels it over-budget and blocks merging until it’s split.
  4. ReviewEach PR is reviewed in under an hour. One problem in the conversion rounding is caught in PR 2, before anything depends on it.
  5. ReleaseThe flag is turned on for 5% of customers. An issue in PDF rendering is fixed by reverting only PR 4.
07

Failure modes

FailureSymptomMitigation
Budget gamedWork split into pieces that don't make sense aloneEach change must build, pass tests and be reviewable on its own
Hidden in exceptionsLarge changes routinely marked as exceptionsExceptions need a named reviewer and a reason; track how often they're used
Stack driftLater PRs in a stack conflict with changes to earlier onesMerge in order; rebase the stack after each merge
Half-shipped featuresPartial work visible to usersFeature flags until the last change of the stack lands