Direct answer
A small Claude Code request becomes a large diff when the working goal is broader than the requested change. Fix the scope before editing: name the files, describe the symptom, define success and require a diff plan. Official: Anthropic recommends prompts that name files, describe symptoms and define success. For unclear goals, it recommends interviewing the user until a spec can be written (F008). After the edit, compare the final diff with that contract and reject unrelated cleanup. The concrete win is a review that evaluates the requested behavior instead of a surprise rewrite. The honest loss is that a large diff can be correct, and a small diff can still be wrong. Diff size is a scope signal, not a quality score. Use it to start a review, then inspect behavior, tests and risk.
How scope drifts
Scope drift rarely begins with a command to rewrite everything. It begins when the request leaves a decision open. “Improve validation” can mean a message change, a new schema, a shared helper or a framework migration. An agent may choose one of those interpretations and then improve adjacent code because the broader pattern looks inconsistent.
Official: best practices favor specific files, symptoms and success criteria (F008). Specificity removes choices that do not belong to the task. It also gives the reviewer a boundary. Without that boundary, a clean-looking abstraction can expand the change until the original bug is hard to find.
Context growth adds another pressure. Official: session guidance warns that performance can degrade as context grows and that a bad autocompact can drop important details (F002). A long session can carry old requests, abandoned ideas and nearby cleanup suggestions. The final diff may reflect the accumulated conversation rather than the latest instruction.
Community and Unknown: the supplied fact pack contains anecdotal reports of unwanted changes and overengineering, but no measured Claude Code scope-drift rate (F010). Do not turn those reports into a universal defect claim. Treat scope control as a review practice that any coding workflow can benefit from.
There is also a legitimate reason for a broad diff. A cross-cutting type change may require edits in many files. A dependency upgrade may alter generated output. The question is not “how many files changed?” The question is “did every change serve the approved goal?” A large diff with a clear causal chain deserves review. A small unrelated cleanup inside that diff still deserves rejection.
Scope drift modes
| Mode | How it starts | Why it grows | Control |
|---|---|---|---|
| Goal inflation | A vague outcome invites a broader solution | Nearby weaknesses become part of the task | Write an observable success condition |
| Cleanup creep | A small style or naming issue appears during editing | The agent fixes adjacent code for consistency | Separate cleanup into another change |
| Abstraction promotion | Repeated logic suggests a helper | The helper grows options for future use | Require a present use case |
| Framework substitution | A library seems awkward for one case | The change expands into replacement work | Name the allowed dependency boundary |
| Test expansion | A new test reveals weak coverage | The task becomes a suite rewrite | Test the changed behavior first |
| Generated-file churn | A generator updates many outputs | Formatting or version drift adds noise | Review generator and lockfile together |
| Recovery overreach | A failed approach leaves partial edits | A retry rewrites instead of reverting | Stop and compare with the last accepted state |
Each mode has a different remedy. A file allowlist will not fix an inflated goal. A reviewer who checks only line count will miss an abstraction with no current caller. Match the control to the way the scope expanded.
The session handoff guide helps when a task crosses people or sessions. Carry the approved goal and the rejected alternatives forward. Otherwise the next person may reopen a broader design because the packet never recorded why it was out of scope.
The diff plan
Write the plan before the edit and keep it short. It should name the behavior, the files, the dependency boundary, the verification and the stop condition. A plan is useful only if it constrains the work that follows.
Start with the symptom. “The checkout button remains enabled after validation fails” is inspectable. “Improve checkout UX” is not. Then name the smallest surface that can own the fix. If the handler and its test are enough, say so. If a shared utility must change, explain why and list its callers that need review.
Official: for unclear goals, Claude should interview the user until it can write a spec (F008). Use that interview to close scope questions. Do not let the implementation become the place where the team discovers what the request meant.
A diff plan should also separate required edits from optional follow-ups. Optional cleanup belongs in a note, not in the current branch. Separating cleanup keeps the review focused and makes the eventual cleanup easier to evaluate on its own merits. The code-review bottleneck guide explains why accepted work matters more than generated volume.
Change contract
| Contract field | Required content | Example of a bounded statement | Reject when |
|---|---|---|---|
| Goal | Observable behavior that must change | Invalid input shows the approved message | The outcome is still ambiguous |
| Non-goals | Nearby behavior that must remain stable | Successful submission is unchanged | Cleanup changes unrelated behavior |
| Allowed files | Named implementation and test paths | Edit the handler and its validation test | New files appear without approval |
| Dependency boundary | Packages that may be added or changed | No dependency changes | A new package appears |
| Verification | Checks tied to the changed behavior | Run the validation fixture and existing handler test | The test does not exercise the fix |
| Stop condition | Event that requires a new plan | Stop if a shared utility must change | The agent crosses the boundary silently |
| Review owner | Person who accepts scope changes | Task owner reviews any expansion | Expansion has no named approver |
The example statements are templates, not a benchmark or a claim about a real repository. Replace them with the actual paths and behavior. A contract that cannot be checked is just a longer prompt.
Ask for the planned diff categories before execution. The agent can name the files it expects to edit and the reason for each. That does not guarantee the final diff, but it creates a reference point. When the final diff differs, the reviewer can ask whether the plan changed or the execution drifted.
Official: hooks can block tool calls, and permissions provide controls around agent actions (F011). Use durable restrictions where the platform supports them. A sentence in a prompt is guidance. A configured control can enforce a boundary. The harness security boundary guide helps distinguish those layers.
Allowed files
An allowed-file list is the simplest scope control. Name the implementation files, test files and any generated output that legitimately belongs to the task. Everything else requires a pause.
Use paths that match the repository’s actual structure. A broad directory name may be convenient but weak. If the task touches a monorepo, name the package as well as the file. The reviewer should be able to compare the final changed-file list with the contract without interpreting a vague folder description.
Do not treat generated files as accidental by default. A generator may legitimately rewrite many outputs. Review the generator input, tool version and lockfile together. The dependency-install side-effects guide explains why an install can change more than the manifest.
A file outside the list is a stop signal, not an automatic catastrophe. The agent may have discovered a real dependency. Ask for the reason, inspect the new surface and update the contract if the expansion is justified. The failure is silent expansion, not the existence of an additional file.
Official: checkpointing tracks Claude Code file edits, but Bash-only changes, subagent edits and some external changes are not fully tracked (F014). An allowed-file list therefore needs version-control evidence as well as session history. The rewind checkpoint guide explains why a checkpoint is not a complete review or recovery mechanism.
The same caution applies to Git. Community: issue #29179 reports tracked files including .gitignore being removed, after which a broad clean operation removed previously ignored directories (F013). That sequence is a user report, not a universal Git behavior. It is still a reason to review destructive cleanup separately from the requested code change. The gitignored-file deletion guide covers the state transition.
When a broad diff is justified
A broad diff earns its place when the requested behavior cannot be implemented coherently inside a narrow file set. A shared type change may require updates at every call site. A generator may legitimately rewrite outputs after an input changes. A dependency upgrade may alter lockfiles and generated code together. These are reasons to widen the contract, not reasons to abandon it.
Start by asking whether the change has one causal chain. Can the reviewer trace each edited file back to the approved behavior? If yes, the diff may be large but focused. If several edits serve unrelated improvements, split them. The distinction is purpose, not size.
A compatibility change deserves special attention. If a shared interface changes, name every affected consumer and the migration path. The plan should say whether old behavior remains supported and which tests prove it. Without that explanation, a broad diff can hide a breaking change behind mechanical edits.
Generated output also needs context. Review the generator input and the resulting files as one unit. If formatting churn appears alongside the functional change, separate it when possible. The dependency-install review helps identify when a tool or install step caused the wider surface.
Official: independent review is recommended because a fresh reviewer has not seen the implementation reasoning (F009). That matters even more for a broad diff. Give the reviewer the contract and ask them to trace the causal chain. Do not ask only whether the code looks clean. A coherent rewrite can still miss the requested behavior.
Split cleanup by behavior rather than by file count. If a naming change is independent of the fix, move it to another branch. If a helper is required by the fix and has real callers, keep it. Artificial splitting can make the main change incomplete and force the reviewer to reconstruct a dependency across branches.
The honest loss is that broad changes take longer to review and carry more integration risk. The practical implication is to widen the contract deliberately, preserve a clear migration path and use stronger verification. Do not force a cross-cutting fix into an artificially small diff merely to satisfy a file limit.
Stop conditions
A stop condition protects the team from having to review an avoidable mess. Put it in the plan before work starts. Useful conditions include a new dependency, a shared API change, an unexpected production command, a new file outside the contract or a test that cannot run locally.
When a stop condition fires, the agent should summarize what changed so far and what remains unknown. Do not ask it to push through because the task is nearly done. “Nearly done” is not a scope argument. The next decision may require a different owner or a separate approval.
Keep stop conditions observable. “Stop if this becomes complicated” is hard to apply. “Stop if the fix requires changing the shared request type” gives the reviewer a concrete branch. The more specific the condition, the less room there is for an enthusiastic refactor to become the new task.
A stop also creates a useful handoff. Record the attempted approach, the boundary that blocked it and the smallest next decision. The database migration safety guide uses the same separation between drafting and production action. Scope control and destructive-action control reinforce each other.
Do not punish a justified stop. If the agent reports a genuine dependency, the process worked. Measure whether the team obtained the information early, not whether the agent managed to avoid every interruption.
A worked example: the contract test
Use a scratch branch with a small validation change. Write the goal, non-goals, allowed files, dependency boundary, verification and stop condition before asking for an edit. Do not use a production repository or production credentials.
After the edit, inspect the changed-file list and compare it with the contract. Then inspect the behavioral diff. A file-count match is necessary but not sufficient. The allowed handler could contain an unrelated refactor, while a generated file could contain legitimate output from the approved change.
Derived: A simple gate is unexpected files = changed files not in the allowed set. The gate fails when unexpected files > 0 unless the owner approves and records an updated contract. This formula checks scope membership, not code quality. It uses no invented benchmark data.
Next, inspect the non-goals. If successful submission behavior changed, the contract failed even when the file list matched. Run the stated verification and record the result. The proof-of-work packet guide helps attach evidence to the exact behavior rather than to a generic “tests pass” claim.
The safe test has a concrete win: it catches unrelated work while the diff is still easy to discuss. Its concrete loss is that it cannot prove the fix is complete or that no subtle regression exists. The practical implication is to pair the contract test with behavioral review and an independent reviewer.
Official: best practices recommend subagents for independent review because they have not seen the reasoning behind the code (F009). Give the reviewer the spec and ask them to skip style unless style is part of the requirement. This reduces unnecessary abstraction and keeps the review aligned with the requested change.
A review checklist
Review the final diff in two passes. First, check scope. Second, check behavior. Mixing them makes it easy to admire a clever helper while missing an unrelated file, or to reject a legitimate cross-cutting change because it looks large.
Review checklist
| Review question | Evidence to inspect | Pass condition | Common failure |
|---|---|---|---|
| Does the diff serve the goal? | Goal statement and behavioral diff | Every material change has a stated purpose | Cleanup hides the actual fix |
| Are non-goals stable? | Adjacent behavior and regression tests | Unrelated behavior remains unchanged | A broad refactor changes defaults |
| Are files within contract? | Changed-file list and generated outputs | Every path is allowed or approved | Silent expansion |
| Are dependencies justified? | Manifest, lockfile and install effects | No unreviewed package or script | Convenience dependency added |
| Is abstraction proportionate? | Callers and current use cases | Complexity has a present need | Framework built for future work |
| Is verification relevant? | Test names, fixtures and results | Checks exercise the changed behavior | Passing tests miss the bug |
| Are stop conditions honored? | Plan updates and approval record | Expansion has explicit review | Agent pushes through a boundary |
| Is recovery understood? | Checkpoint and version-control evidence | Claims match actual coverage | Rewind treated as universal restore |
| Is the change attributable? | Commit or provenance record | Reviewer and assistance are recorded | Model contribution becomes vague |
The license-compliance review belongs here when generated code or a new dependency raises copying or attribution questions. The AI provenance guide helps record who reviewed the change without pretending that a watermark proves authorship.
Keep review comments tied to the contract. “This helper adds configuration we do not need for the stated task” is actionable. “This feels overengineered” starts an argument. Name the extra behavior, the missing caller or the unrelated file so the author can accept or reject the comment on evidence.
Honest loss and data gaps
A strict contract can block useful work. Sometimes the best fix requires a broader change than the first plan anticipated. The answer is to review and update the plan, not to abandon scope control or silently accept the expansion.
Unknown: the supplied sources do not provide a measured overengineering rate, an ideal diff size or a universal file limit. The checklist cannot tell a team that a specific number of changed lines is safe. It can tell the team whether the changes match the approved purpose.
Official: checkpoint retention is bounded, and checkpoint coverage excludes several change surfaces (F014). Do not use rewind as permission to experiment without limits. A checkpoint may help with tracked file edits, but it does not make an unreviewed dependency install or database action reversible.
The honest loss is review effort. A contract takes time to write and enforce. On a trivial change, that effort may exceed the benefit. On a shared API, migration or security-sensitive path, the same effort can prevent a costly detour. Scale the contract to consequence rather than applying maximum ceremony to every typo.
The practical implication is simple. Make the requested change the unit of scope. Let a good discovery become a new plan instead of an invisible expansion of the old one.
Adjacent checks worth keeping separate
Scope control starts with team handoff and decision logs and offline work boundaries. Mobile review adds phone approval limits. Platform symptoms belong with network storm diagnosis, Linux ARM and headless login, macOS Keychain permissions, PowerShell path quoting, corporate proxy TLS and mTLS and outage failover.
The highest-risk expansions involve executable actions. Review dependency-install side effects and database migration safety. Check gitignored-file deletion and rewind checkpoint coverage before treating a broad cleanup as easy to undo.
Untrusted content needs its own boundary. Use repository prompt-injection controls, MCP trust boundaries, plugin security audits, secrets-in-logs cleanup, security-research authorization and game-development IP restrictions. A broad diff can cross any of these lines without changing a single test.
Cost and reasoning settings influence how much work an agent attempts, but they do not enforce scope. Compare annual plan lock-in, Max and Ultra value, fast-mode pricing and Batch API versus subscription. Tune with prompt-cache minimums, thinking-token caps and reasoning effort defaults. Measure the result through review capacity, AI provenance and license compliance.
A practical OpenAI-format alternative
If you want to compare two agents on the same bounded task, the 46 live free model IDs offer an OpenAI-format route. First-party, checked 2026-11-27: the catalogue showed 76 listed models and 46 available-now free IDs across 22 families (F044). The free lane shares 100 requests and 5,000,000 tokens per day per account, resetting at 05:30 IST or 00:00 UTC, with one request in flight per key (F045).
One AI API Key supports OpenAI-format agents such as OpenCode, Cline or Cursor. Use the endpoint quickstart, choose one free ID and send requests to https://api.oneaiapikey.com/v1 (F047, F048). The prepaid pricing page documents $10 signup credit with no card and no subscription or seat fee (F046). The per-key controls cover caps, expiry and model allowlists, while the cost calculator can compare a controlled test.
Do not put those free IDs into Claude Code. They are OpenAI-format only. The documented Claude Code route is unavailable because all four Claude IDs were marked unavailable on 2026-11-27 (F047). Compare accepted, in-scope changes rather than raw diff volume. A second agent may produce a different diff, but the contract should remain the same.
FAQ
Why does Claude Code change files I did not request?
The supplied sources do not establish a universal cause or a measured rate. Vague goals, accumulated context and opportunistic cleanup are plausible scope pressures. Use a specific goal, allowed files and a final diff check (F008, F010).
Is a large diff always overengineering?
No. A cross-cutting fix may legitimately touch many files. Judge whether each change serves the approved goal. Diff size is a review signal, not a quality metric.
How many files should I allow?
There is no universal number in the supplied evidence. Name the actual implementation, test and generated paths required for the task. Add a stop condition for any expansion.
Can permissions prevent scope drift?
Permissions and hooks can constrain tool actions (F011), but they do not replace a clear spec or behavioral review. Use configuration for durable boundaries and the diff contract for purpose.
Does /rewind make broad experiments safe?
No. Official: checkpointing has exclusions, including Bash-only and subagent changes (F014). It is not a complete recovery mechanism for external state or destructive commands.