// TL;DR

Before you commit: point at a line you changed, point at the request you got. Can you explain in one sentence why that line had to change to fulfil the request? If not — delete the line.

Why the rule exists

Scope creep is the most common reason AI-assisted code gets rejected in review. Not because the code is wrong — it's often fine — but because there's too much. The reviewer now has to decide: was this intentional, or did it slip in?

"The Test" is a quick mental tool that catches it before commit. It doesn't replace good judgment, but it catches 80% of the problems with a simple mechanical exercise.

How to run the test

  1. Diff your change. git diff --staged or your tool's equivalent.
  2. For each changed line: can you explain in one sentence why that line had to change?
  3. If the sentence sounds strained — like "for consistency" or "while I was there" — the line doesn't belong in this change.
  4. Delete or revert the lines that don't pass.

// Example

Request: "Fix the bug where user.email is null in the export."

Diff contains:

  • (a) Null check on user.email before export. ✓ Traces to the request.
  • (b) Renaming exportUser() to exportUserData(). ✗ Not in the request — revert.
  • (c) Adding a null check on user.phone in the same place. ✗ Not in the request, separate bug — revert and flag it.

What the test is not

The Test isn't a defence of sloppy code. A change can require necessary follow-up edits — for example, if you add a parameter, you also have to update its callers. That still "traces to the request."

But when the follow-up edit starts pointing into refactor territory ("now that we're here..."), it's no longer trace — it's creep.

When the test is hard

It's hard when the request is vague. "Make it better" isn't a request that can be traced. If you got one, then before you start coding: ask concretely what "better" means, or propose one concrete direction and confirm.

When you trace, you should be able to point at a concrete line in the request — not a general impression.


Related rules