All courses

Scope creep and unasked-for changes in a diff

Recognise drive-by reformatting, renames, refactors, new abstractions, config tweaks and dependency bumps mixed into the requested change. Explain how they hide the real change, raise risk and make review and revert harder.

Builds on: You own every line the agent writes

Read it card by card Start the whole course

A one-line fix in a nine-file diff

You asked the agent to make page numbers start at 1 instead of 0. That should be a one-line fix. The diff touches 9 files: imports re-sorted, a helper renamed, a new `Paginator` class, `.prettierrc` edited, the lockfile bumped. The summary says "Fixed pagination and tidied up a little." Tests are green. Which of these changes did you ask for? And what will the rest cost you?

Why the agent tidies, and who pays

While it works, the agent reads whole files. It rewrites what it would have done differently: style, names, structure, versions. Each edit costs it nothing, and nothing in the task told it to stop. It cannot see what review costs you, which files teammates are editing, or why a version is pinned. The extras bury the real change and add risk nobody tested. They also get tangled with the fix if you ever need to revert it.

Every hunk must trace to the task

Check each hunk against the request. Any hunk the task doesn't need is a tell. Common tells and their later cost: - **Reformatting or re-sorted imports**: hide the fix in noise. Blame history credits those lines to this commit. Teammates editing the same lines can hit merge conflicts. - **Renames**: break callers the diff doesn't show. - **Moved code, new classes or helpers**: more to maintain. Moved code shows as delete-plus-add, so an edit inside it slips past review. - **Config edits**: change behaviour for every file or every environment. - **Dependency or lockfile changes**: unreviewed code ships to production. Tools that help: `git diff --stat` and `git diff -w`.

The one-line config change

The agent fixed a date bug in `invoice.ts`. It also changed `printWidth` in `.prettierrc` from 80 to 100 "to match the code style". The whole diff is tiny. The tell is a config edit that the task never mentioned. The later cost: the next time a teammate formats any file, Prettier rewraps it to the new width. Unrelated lines flood their PRs and merge conflicts follow. What to ask: "Revert every hunk not needed for the date bug and list other suggestions separately."

Find the fix in this diff

Only the `start` line fixes the bug. The rest are tells: - **Import spacing**: noise that hides the fix and credits the line to this commit in blame history. - **Rename of `get_page` to `paginate`, and `n` to `page`**: no caller is updated here, so every call to `get_page` fails. Even a caller switched to `paginate` fails if it passes `n=` as a keyword argument. Python only finds out at runtime. - **Pin `==2.28.2` loosened to `>=2.31`**: every fresh install now gets the newest `requests`, never the tested 2.28.2. Reverting this commit would also undo all of it.
// Python
--- a/api/pages.py
+++ b/api/pages.py
-from utils import clamp,fetch
+from utils import clamp, fetch
-def get_page(rows, n, size):
-    start = n * size
+def paginate(rows, page, size):
+    start = (page - 1) * size
     return rows[start:start + size]
--- a/requirements.txt
+++ b/requirements.txt
-requests==2.28.2
+requests>=2.31

Small diff, one purpose

Read the diff against the request: every hunk should be needed for the task. Unasked-for reformatting, renames, new abstractions, config changes and dependency bumps get reverted or split into their own change. That keeps the fix small, easy to review and revertible on its own.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.