By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
You ask Claude Code to refactor the payments module. It returns a large, plausible diff. The summary says the tests pass. You merge. Two days later you find a behaviour change nobody requested, on a line somewhere in the middle of the diff.
The failure was not in the model. The failure was the size of the turn: one request, one large change, one unread diff. Iterative refinement is the alternative. Change one thing per turn, check the result, and use that evidence to choose the next change. Each pass leaves something you can read in under a minute.
Run the tests yourself and read the changed hunks. The summary is a claim about evidence; the diff and the exit code are the evidence. On a machine where the suite runs in seconds, the second opinion is nearly free.
Two rules keep turns small. If you cannot describe the change in one sentence, split it. If the diff touches files you did not expect, stop and ask why before you continue.
def review_plan(files_changed: list[str], budget: int = 5) -> str:
"""Say whether this diff is small enough to review in one pass."""
if not files_changed:
return "nothing changed: re-read the request"
if len(files_changed) > budget:
return f"{len(files_changed)} files is over the {budget}-file budget: split the task"
return f"{len(files_changed)} files: read every hunk, then run the tests"
print(review_plan(["src/pricing.py", "tests/test_pricing.py"]))
print(
review_plan(
["src/a.py", "src/b.py", "src/c.py", "src/d.py", "src/e.py", "src/f.py"]
)
)Then stop. A refinement loop that never ends is another way to avoid shipping, because each new small change starts to touch code you already reviewed. Stop when the change stops surprising you and the tests cover what you touched. If you cannot name the next small change, the task is either done or was never planned.
| Situation | Move | What it does |
|---|---|---|
| You keep retyping the same preference | /memory | Stores it as a durable instruction for future sessions |
| The session is long and the context is crowded | /compact | Summarises the conversation so the important detail survives |
| The task changed completely | A fresh session | Drops stale context that now misleads |
| You need the earlier state of this task | --resume | Reopens a prior session with its context intact |
Use /memory for a preference you want every session to honour. Use /compact when the conversation has grown long and you are still on the same task. Compact at a clean boundary, not in the middle of a debugging chain. Start a fresh session when the task changes, because old context that no longer applies is worse than no context at all.
Pick a task you would normally do in one prompt, such as adding input validation to one function.
Write the one-sentence version of the first small change.
Run it, then read every hunk before you type anything else.
Run the test command yourself and note the exit code.
Write the next small change based on what the diff showed, then repeat once more.
Definition of done: three turns, three read diffs, three test runs you started yourself. If a turn touched a file you did not predict, say what you learned from asking why.
Key takeaways
Iterative refinement means one small change, then evidence, then the next change.
Read the hunks and run the tests yourself; a summary is a claim, not proof.
Unexpected files in a diff are a question to raise before you continue.
/memory for durable preferences, /compact for a crowded session, a fresh session for a new task.
Compact at a task boundary, not in the middle of a debugging chain.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.