Topic 3 of 5 · 5 min read
Turning a spec into an agent plan
Goal: Check an agent's plan against its spec and find the acceptance criterion it skipped or the step it invented.
Before an agent writes code, ask it for a plan and task list built from the spec, then check the plan against the spec line by line. A wrong plan costs a minute to fix. Wrong code built on it costs a review and a rewrite.
Check yourself · 1 of 3
What is the main benefit of asking an agent for a plan before it writes code?
Why it matters
Agents are good at producing a plausible plan, and a plausible plan can drop a requirement or add work nobody asked for. If you only read the final diff, those errors are buried in hundreds of lines. In a plan they are one line each. Claude Code's plan mode, Kiro's tasks file and the plan command in Spec Kit all exist for this step.
How to do it
- Ask for the plan only. Say "Read SPEC.md. Do not write code yet. Give a numbered plan, and for each step name the acceptance criteria it satisfies and the files it changes."
- Build a coverage table. List the acceptance criteria down one side and the plan steps across the other. Every criterion needs at least one step and one test. A criterion with no step was skipped.
- Hunt for invented work. Every step should trace back to a criterion or a stated constraint. A step with no trace is invented: a new library, a schema change, a rewrite of a shared helper.
- Check the order and size. Each step should be small enough to review and test alone. Tests for a criterion should come with or before the code for it.
- Fix the spec or the plan. If the plan is wrong because the spec was unclear, edit the spec. If the spec was clear, correct the plan and rerun.
Before and after
Spec criteria: 1) 6th failed login returns 429, 2) success resets the counter, 3) Redis down still allows login.
Weak plan:
1. Add express-rate-limit and configure it.
2. Add the middleware to /login.
3. Write tests for rate limiting.
Criterion 2 and 3 have no step, and step 1 adds a dependency the spec forbade.
Reviewed plan:
1. Add failedLoginCount(email) helper on the existing Redis client. (criteria 1, 2)
2. Return 429 with Retry-After from POST /login after 5 failures. (criterion 1)
3. Reset the counter on success. (criterion 2)
4. Catch Redis errors, log them and allow login. (criterion 3)
5. One test per criterion. (all)
What goes wrong
- Skipped criteria. The hardest or least interesting one is the one dropped, usually the failure path.
- Invented steps. New dependencies, migrations and cleanups appear because they look like good practice.
- A plan that restates the spec. "Implement the feature" is not a plan. Each step needs files and a criterion.
- Plan drift. The agent starts coding and quietly changes the plan. Re-check when a step turns out harder than expected.
Examples
A coverage table
| Criterion | Plan step | Test |
|---|---|---|
| 1. 6th failure returns 429 | 2 | yes |
| 2. Success resets counter | none | none |
| 3. Redis down allows login | 4 | no |
Criterion 2 was skipped and criterion 3 has no test. Both go back to the agent before any code is written.
The prompt that asks for a traceable plan
Read docs/specs/login-limit.md. Do not edit files yet.
Give a numbered plan. For each step list: the criteria it satisfies,
the files it changes, and the test that proves it.
List anything you want to add that the spec does not ask for.
The last line makes invented work visible instead of hidden.
Key points
- Ask for a plan before code, with each step naming the criteria it satisfies and the files it changes.
- A coverage table of criteria against steps shows at once which criterion was skipped.
- Any step that traces to no criterion or constraint is invented work and should be removed or justified.
- Keep steps small enough to review and test alone, with tests alongside the code they check.
- If the plan is wrong because the spec was unclear, fix the spec first, not only the plan.
Common mistakes
- Reading only the final diff and never the plan, so skipped criteria are found late or never.
- Accepting a plan that names no files or criteria, so it cannot be checked.
- Letting a step add a dependency or schema change the spec did not mention.
- Approving the plan once and not re-checking it after the agent changes direction mid-run.
Check yourself · 2 of 3
A plan step adds a new logging library. The spec never mentions logging libraries. What is this step?
Check yourself · 3 of 3
Your spec has four acceptance criteria and the plan's steps mention only three. What do you do?
Practice items, not counted towards your mastery.
Start here
- GitHub Spec Kit (opens in a new tab)ToolFree
An open-source toolkit with commands for writing a spec, a plan and a task list before code.
- Understanding Spec-Driven Development: Kiro, spec-kit and Tessl (martinfowler.com) (opens in a new tab)ArticleFree
A critical comparison of three spec tools, including where specs still fail agents.
- Specs (Kiro docs) (opens in a new tab)DocsFree
How one agentic IDE structures a spec as requirements, design and tasks files.
More for this topic
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
Advice on exploring and planning before coding and on giving the agent a way to verify its work.