Building with agents, lesson 2.2
Research, plan, implement
An agent that codes first builds on its first guess. This lesson walks through the order that works: read the code, write a spec, have a person check it, then build and prove it against the spec.
Every example below changes to fit what you pick. The businesses are made up for teaching.
The picture, one step at a time
Each box is one stage. The picture lights up as you scroll.
Research, plan, implement: from reading the code to checking against the spec
1Research
The agent reads the code, the docs and the history. It changes nothing.
2Write the spec
What to build, what done looks like, what is out of scope, and the checks that prove it.
3You read the plan
The cheapest moment to catch a wrong turn: before any code exists.
4Implement
A fresh session builds from the spec, and only what the spec says.
5Check against the spec
The checks run, and something that did not write the code compares it to the spec.
Five stages. Code is only the fourth.
Step 1 of 6
Why not just start?
An agent that starts writing code at once builds on its first guess. If the guess is wrong, every line after it is wrong too, and you find out at the end. For a job like adding parcel tracking to the support agent, three short stages before any code save most of that waste: read, plan, and let a person check the plan.
Step 2 of 6
Research: read, change nothing
First the agent reads. Which files does this touch? What already exists that it could reuse? Where else does the same pattern appear? It can run commands to look around, but it edits nothing. The output is what it found, not code.
Claude Code has a plan mode for this (as of November 2026): it reads files and runs commands to explore, writes a plan, and cannot edit your code until you approve. Shift+Tab switches to it.
Step 3 of 6
Write the spec
Next, the plan goes in a file: the goal in one sentence, what done looks like, what is out of scope, the edge cases, and the checks that will prove it works. If you have not decided some of it yet, have the agent ask you questions until it can write the spec.
Anthropic's Claude Code guide gives a prompt for this: "Interview me until you could write the spec, then write it to SPEC.md."
Step 4 of 6
A person reads the plan
This is the cheapest place to catch a mistake. A wrong plan costs a minute to fix in a file, and a day to fix in code. Read it for one thing above all: would the result be what you actually want?
The plan looks right, but it never says what the agent must not touch. What do you do?
Step 5 of 6
Implement from the spec
Now the code. Start a fresh session pointed at the spec, so the build begins with a clean slate and a written target. It builds what the spec says, and only that. If the spec turns out to be wrong, stop and fix the spec first, then carry on.
Anthropic's guide recommends exactly this: once SPEC.md exists, start a fresh session to build from it, "so the build begins with a clean context and a written definition of done".
Step 6 of 6
Check against the spec
Last, prove it. Run the checks the spec names: a test, a build, a linter, anything that comes back pass or fail. Ask for evidence, the command and its output, not "all tests pass". Then have a reviewer that did not write the code compare it to the spec, line by line.
Who makes the better reviewer of the finished code?
Where did it go wrong?
Here are four jobs that went wrong in your business. Sort each one into the stage that should have caught it.
1The agent wrote a new parcel tracker from scratch. Your codebase already had one, used by the order emails.
2The new tool refunds any lost parcel on its own, including a £300 one. Your rule is that a person approves anything over £50.
3The plan said "add track_parcel". The change also renamed a column in the orders table.
4It said "done". The tracking tool returns yesterday's status, and no test ever ran.
0 of 4 right so far, 4 to go.
A spec template
This is what you keep: the sections of a spec, in order. Copy them into a file at the start of any job bigger than a one-line change.
A spec template
- The goal: one sentence on what changes, and for whom.
- What the research found: the files involved, what already exists to reuse, and anything surprising.
- What done looks like: the checks that must pass, written so a machine can run them.
- Out of scope: what it must not touch or change.
- Edge cases and open questions, each with an answer or the name of who decides.
- The steps, in order, each small enough to check on its own.
No code until a person has read the plan, and no "done" until the checks in the spec have run, with proof.
Next: Lesson 3.1: MCP fundamentals: servers, clients, tools. How one standard way of connecting lets an agent reach your systems.