Topic 2 of 5 · 5 min read
Building in small checkpointed steps
Goal: Split a plan into steps that each end with a passing check and a checkpoint you can roll back to.
Build one plan step at a time, end each step with a check that passes, and save a checkpoint before you move on. Then any bad step is cheap to undo.
Check yourself · 1 of 3
What should every plan step end with?
Why it matters
Agents can change many files in one go. That is the problem. A large change is hard to read, hard to test and hard to undo. Review quality drops as the diff grows, which is why Google's engineering guide asks for small changes. Small steps also keep the agent's context clean, because each one starts from a known good state.
How to do it
- Cut the plan into steps a reviewer can hold in their head. One behaviour, a few files. A good step has a one-line description you can say aloud.
- Give every step a finish line. A test that now passes, a type check, a command that prints the expected output. "Step 2 is done when
pytest tests/test_coupon.pypasses." - Run the check yourself. The agent's statement that it passed is a claim, not proof.
- Checkpoint when green. Make a git commit, even a local one you will squash later. Claude Code and Cursor also keep their own checkpoints of file changes, but git is the one you control and can inspect.
- Then ask for the next step, naming it: "Do step 3 only."
Before and after
Weak: "Implement the whole plan."
You get one diff across 22 files. A test fails and nobody knows which change caused it.
Better:
Do step 1 only: add the Coupon model and its migration.
Done when: `npm test -- coupon.model` passes and `npm run typecheck` is clean.
Stop after that and show me the diff.
After it passes, run git commit -am "step 1: coupon model", then ask for step 2.
What goes wrong
- Steps that are too big. If you cannot review a step in a few minutes, split it.
- Checks written by the step's own author. An agent may weaken a test to make it pass. Read the test changes first.
- No checkpoint. Without a commit, rolling back means undoing by hand, and you may lose good work too.
- Chaining steps without looking. "Continue" three times is the same as one large step.
Examples
A step with a finish line
Step 2: apply the coupon in `calculateTotal`.
Done when `pytest tests/test_totals.py -k coupon` passes
and no other test file changed.
The last line catches the common shortcut of editing unrelated tests.
Rolling back one step
Step 3 breaks the build and the agent's fixes make it worse. Because step 2 was committed, you run git reset --hard HEAD and return to the green state. You lose the step 3 attempt, not the work before it.
Key points
- Give each plan step one behaviour and a few files, small enough to review in minutes.
- End every step with a concrete check, such as a named test or command, and run it yourself.
- Commit or checkpoint every time a step is green so you have a known good state to return to.
- Tell the agent to do exactly one named step and stop, instead of saying continue.
- Watch for the agent editing a test to make a step pass, and read test changes first.
Common mistakes
- Asking for the whole plan in one go.
- Accepting "all tests pass" without running the tests.
- Moving to the next step with uncommitted work from the last one.
- Writing steps with no check, so nothing says when one is done.
Check yourself · 2 of 3
Step 2 of a plan passes its tests. What do you do before asking for step 3?
Check yourself · 3 of 3
The agent says step 1 is done and all tests pass. What is the best next move?
Practice items, not counted towards your mastery.
Start here
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
A vendor's own advice: explore and plan first, give the agent a way to verify, and clear context when it drifts.
- Checkpointing (Claude Code docs) (opens in a new tab)DocsFree
How to rewind code and conversation to an earlier point in a session, and what checkpoints do not cover.
- Exploring Generative AI (martinfowler.com) (opens in a new tab)ArticleFree
Field notes from Thoughtworks on working with AI in small steps and reviewing every output.
More for this topic
- Small CLs (Google Engineering Practices) (opens in a new tab)ArticleFree
Why small changes get better reviews, and how to split a large change into reviewable steps.
- Undoing Things (Pro Git) (opens in a new tab)BookFree
The git commands for undoing a commit or a file change, which is your rollback when an agent step goes wrong.