Topic 2 of 4 · 4 min read
Spotting scope creep in agent changes
Goal: Separate the requested change from unrequested edits in an agent's diff and decide which to keep, split or revert.
Scope creep is every line in a diff that the task did not ask for. Agents produce a lot of it: renamed variables, "improved" error handling, upgraded dependencies, reformatted files, loosened lint rules, edited tests. Some of it is harmless. Some of it is where the real risk hides, because reviewers skim it.
Check yourself · 1 of 3
An agent was asked to fix one function. Its diff also reformats five unrelated files. Why is that a problem?
Why agents do it
An agent tries to reach a goal ("make the tests pass", "fix the bug") and treats anything in the way as fair game. It also tends to tidy what it touches. Neither habit respects the boundary you had in mind. A one-line fix can arrive as a 600-line diff.
What to look for
- Edited or deleted tests. The most dangerous creep. A weakened assertion, a skipped test (
it.skip,@pytest.mark.skip), or a snapshot regenerated to match the new (wrong) output. - Config and policy changes. Lint rules disabled, type checks relaxed (
"strict": false,# type: ignore), CI steps removed, timeouts raised, permissions widened. - Dependency changes. New packages, version bumps, lockfile churn. Each one is a supply-chain decision, and agents sometimes add packages that do not exist or that you already have an equivalent for.
- Drive-by refactors. Renames and restructuring in files unrelated to the task. They hide the real change and create merge conflicts for everyone else.
- Formatting churn. Whole files reformatted, which buries a two-line logic change.
How to handle it
- Map the diff to the task. List the files and mark each one "needed", "related" or "unrelated".
- Revert or split the unrelated parts. Ask the agent for a diff that touches only the files the task needs. A separate PR can carry a refactor if you want it.
- Treat test, config and dependency changes as their own review. Each needs a reason you agree with.
- Prevent it next time. Say the boundary in the prompt ("change only
billing/; do not edit tests or config; ask before adding a dependency") and enforce it with tooling: protected paths, CODEOWNERS, a CI check that fails on new skips.
Before and after
Task: Fix the rounding bug in
calculateTax.Agent's diff: 9 files.
tax.ts(the fix),tax.test.ts(one assertion changed from19.99to20.00),.eslintrc(ruleno-explicit-anyturned off),package.json(addsdecimal.js), 5 files reformatted.
After review: keep the fix, question the assertion change (did the expected value really change, or was the test bent to fit?), revert the lint rule, decide on decimal.js separately, and drop the formatting.
What goes wrong
Reviewers read the file they expected and skim the rest, approve test changes as "just updated tests", and accept a dependency because the build passed.
Examples
A test bent to fit
- expect(total(cart)).toBe(19.99);
+ expect(total(cart)).toBe(20.00);
The task was a rounding fix. If the spec says 19.99, the agent changed the test to match a bug. Ask which value the specification requires before accepting either.
A prompt that sets the boundary
"Fix the rounding in calculateTax. Change only files under billing/. Do not edit or skip tests, do not change config, and ask before adding a dependency. If a test fails for a reason outside this task, stop and tell me."
Key points
- Scope creep is every line the task did not ask for; agents produce a lot of it.
- Edited or skipped tests are the most dangerous form, because they hide broken behaviour.
- Config, lint, type-check and dependency changes each need their own reason.
- Map each file in the diff to the task, then revert or split the unrelated parts.
- Prevent it with explicit boundaries in the prompt and tooling such as protected paths.
Common mistakes
- Approving test edits as routine without checking whether the expected values changed for a valid reason.
- Missing a disabled lint rule or relaxed type check inside a large diff.
- Accepting a new dependency because the build is green.
- Letting formatting churn hide a small logic change.
Check yourself · 2 of 3
Which unrequested change in an agent's diff deserves the closest look?
Check yourself · 3 of 3
What is the best way to stop scope creep before it happens?
Practice items, not counted towards your mastery.
Start here
- What to look for in a code review (Google Engineering Practices) (opens in a new tab)ArticleFree
Design, functionality, complexity, tests and naming: the baseline every AI diff still has to meet.
- Small CLs (Google Engineering Practices) (opens in a new tab)ArticleFree
Why small changes get better reviews, and how to split large ones; applies directly to agent output.
- Secure Code Review Cheat Sheet (OWASP) (opens in a new tab)ArticleFree
A security checklist for input handling, auth, secrets and error handling during review.