Spec, plan, build, review is a five-step workflow for coding with an AI agent: write a spec, turn it into a plan where every task ends in a test, build one task at a time, have a fresh agent review the whole branch, then fix what it finds in one pass. We used it to build this site's playbook section: all 1,277 tests passed, and the fresh reviewer still found two critical bugs.
The workflow at a glance
flowchart LR
S[Write the spec] --> P[Plan tasks with tests]
P --> B[Build one task at a time, test first]
B --> R[Fresh agent reviews the whole branch]
R --> F{Critical or important findings?}
F -- yes --> X[Fix each one with a failing test first]
X --> T[Run the full test suite]
F -- no --> T
T --> D[Ship]
When to use it
- Changes that touch several files or more than one system.
- Work where a silent bug costs more than an extra review: billing, publishing, user data.
- Any request with gaps. An agent rarely stops to ask; it picks an interpretation and builds on it. The spec and plan are where those guesses surface while they are cheap to change.
Skip it for a one-file fix or a copy change. A quick test and a read of the diff is enough.
Step 1: Write the spec
- Do: Describe the outcome, who it is for, and every decision you have already made. Ask the agent to list its assumptions before it writes anything, then approve the spec before any code exists.
- Output: A short document in
docs/specs/. It is the authority when anything later disagrees. - From a rough idea: Structuring an AI Software Design Workflow for Mobile walks from a vague app idea to the structured design a spec needs.
Step 2: Turn it into a plan
- Do: Break the work into tasks that each end with a test you can run. Name what each task hands to the next one, such as function names and fields.
- Add a review focus: List the five inputs or failures your tests will not cover, like "GitHub is down" or "the model invents a link".
- Output: A plan file the agent works through in order.
- Why a plan: Preventing AI Coding Mistakes: Proofs vs. Planning compares structured planning with formal proofs as ways to stop an agent's mistakes.
Step 3: Build task by task, test first
- Do: For each task, write the failing test, watch it fail, write the code, and watch it pass. Then commit.
- A step that repeats: When one task runs the same steps many times, Manager and Subagents: A Workflow for Repetitive Tasks splits it so each subagent does one step and ordinary code decides what runs next.
- Keep a ledger: Whenever the agent decides something the plan did not cover, it writes one line: the decision, the reason, and the cost if it is wrong.
Step 4: Review with fresh eyes
- Do: Start a new agent on your strongest model. Give it the spec, the plan, the full diff, the review focus list and the ledger.
- Ask for: Findings graded Critical, Important or Minor, each with a concrete failure scenario.
- Why fresh: The agent that wrote the code shares its own blind spots. A second agent with the same context would too.
Step 5: Fix in one pass
- Do: Re-grade each finding by what a user would actually see. Fix the critical and important ones, each with a test that fails first. Log the minor ones for later.
- Then: Run the full suite once more before you ship.
What the review caught
Two of its findings from our build:
- When a preview build failed, the automatic fix re-drafted a playbook post as an ordinary article and published it without review.
- After its research step, a post read as "pick an angle", so a stalled run could not be reopened or retried.
Both slipped past every test, because no test walked those paths. The review focus list pointed the reviewer straight at them.
Variations
- Medium change: Skip the written spec. Describe the design in chat and wait for a yes.
- Tight budget: Build everything in one session and pay only for the final reviewer.
- Ready-made: The open-source Superpowers plugin for Claude Code packages this workflow as skills.
Frequently asked questions
When should I skip the spec and the plan?
For a one-file fix or a copy change, a quick test and a read of the diff is enough. For a medium change, skip the written spec: describe the design in chat and wait for a yes before the agent builds.
Why does the reviewer have to be a fresh agent?
The agent that wrote the code shares its own blind spots, and a second agent with the same context would too. A new agent on your strongest model, given the spec, the plan, the full diff, the review focus list and the ledger, can catch what the builder and the tests missed.
What goes in the plan besides the tasks?
A review focus: the five inputs or failures your tests will not cover, like "GitHub is down" or "the model invents a link". That list points the reviewer at the bugs the tests miss. The tasks themselves each end with a test and name what they hand to the next one.