Sub topic 10
Implement one step at a time
This chapter assumes you have an approved plan, as covered in the previous chapter. It also assumes you can read a diff and run your project's tests. The goal is to turn the plan into code in small pieces you can check, so a mistake in one step does not spread into the next.
Why one step at a time
If you tell the agent "implement the plan," it may write every file in one pass. You then have to review a large diff against a long plan, and an early wrong choice has already shaped everything after it.
Limiting the agent to one step keeps each change small enough to review. It also gives you a point to stop, correct the agent, and continue.
Ask for one step and a stop
Put the limit in your approval message. Name the step, and say what the agent must show you before it continues.
Approved. Implement step 1 only, then stop and show me the diff and the test results before moving to step 2.Three parts of this message do the work:
- "Step 1 only" sets the scope.
- "Then stop" makes the agent wait for you instead of continuing on its own.
- "The diff and the test results" tells the agent what evidence you need.
The loop for each step
After each step, do the following:
- Read the diff. Check that only the files named for this step changed.
- Look at the test output. If the agent did not run the tests, ask it to.
- Compare the change to the plan step. Note anything extra.
- Commit the step if it is correct. A commit per step lets you undo one step without losing the others.
- Approve the next step in the same way.
Example with the login rate limit
In the earlier plan, step 1 was to add the limiter module. Your approval limits the agent to that file. The diff should contain auth/limiter.py and nothing in auth/routes.py, because wiring the limiter into the route is step 2.
Suppose the diff also edits auth/routes.py. The agent has gone beyond the step. Tell it so directly:
Step 1 should only add auth/limiter.py. Revert the change to auth/routes.py. We will do that in step 2.Handle a step that does not fit the plan
Sometimes the agent finds, while coding, that the plan was wrong. For example, the client IP may not be on the request object. A good agent reports this instead of working around it silently.
When that happens, stop implementing. Go back to plan revision, update the plan, and approve the changed step. Do not let the agent quietly change direction, because then the plan no longer describes the code.
Keep the steps small enough
A step is a good size when you can review it in a few minutes and describe it in one sentence. If a step is too big, ask the agent to split it before it starts.
Exercise
You approved "step 2 only." The agent returns a diff that completes step 2 and also adds the tests from step 3. What do you do, and why?
Show answer
Tell the agent that the test changes belong to step 3 and ask it to remove them from this diff, or decide deliberately to accept them and note that step 3 is done. Either way, you make the choice. Letting extra work through unreviewed defeats the purpose of stepwise execution, because the diff is larger than the one you agreed to review.