spec-driven development
AI coding
Claude Code
AI agents
Spec Kit
Kiro
developer productivity

The Spec-First Agent Setup: 4 AI Coding Agents That Build From a Spec, Not a Prompt

By Job Fit Studio · · 11 min read

In 2025, METR ran a randomized study with 16 experienced open-source developers. Before starting, they expected AI tools to make them 24% faster. Afterwards, they believed AI had made them 20% faster. The clock said otherwise: with AI allowed, their tasks took 19% longer.

Tools have improved a lot since then. METR's own 2026 update says developers are "likely" more sped up now. But the gap between feeling fast and being fast hasn't gone away. An agent can write a thousand lines in a minute, and it writes the wrong thousand lines just as fast when it has to guess what you meant.

Spec-driven development fixes the guessing. You decide what to build and write it down in a form the agent can follow. Then you split the work between agents that each do one job. This guide shows you the exact setup: one constitution file and four agents, with files you can copy into your repo today.

In this guide

  1. The setup at a glance
  2. Why prompts aren't enough
  3. Step 0: Write a constitution
  4. Agent 1: The spec writer
  5. Agent 2: The planner
  6. Agent 3: The builder
  7. Agent 4: The reviewer
  8. Running one feature, start to finish
  9. Same flow in GitHub Spec Kit and Kiro
  10. Common mistakes
  11. About "5x"
  12. Sources

The setup at a glance

StepWhoReadsWritesCan't do
0Constitution (CLAUDE.md)–Your stack, rules and test command–
1Spec writerYour ideaspec.md: user stories + acceptance criteriaWrite code
2Plannerspec.mdplan.md (design) + tasks.md (small tasks)Write code
3Buildertasks.mdTests + code, one task at a timeTouch more than one task, edit the spec
4ReviewerThe diff + spec.mdA list of gapsEdit any file

You review two things: the spec (before any code exists) and the final diff. Everything in between is the agents' job.

The files below are written for Claude Code subagents. Each agent is a Markdown file in .claude/agents/ with a short header that sets its name, its tools and its model. Each subagent runs in its own context window, and the tools line is what keeps the spec writer away from code and the reviewer read-only.


Why prompts aren't enough

A prompt like "add saved carts" leaves dozens of decisions open. Should the cart survive logout? What happens when it's empty? Which table does it live in? The agent will answer every one of those questions, quietly, and you'll find out which way it went when you read the diff.

A spec moves those decisions to the start, where they're cheap to change. Splitting the work between agents helps in three more ways:

  • Each agent has one job and a clean context. The builder doesn't carry the whole planning conversation around. It reads the files it needs.
  • The files are the memory. spec.md, plan.md and tasks.md live in the repo. A new session, a teammate or a different agent can pick up exactly where the last one stopped.
  • Checks are built in. Tests come first, and a separate reviewer compares the result to the spec. "It compiles" is no longer the bar.

Step 0: Write a constitution

Every agent reads one file before it does anything. In Claude Code that's CLAUDE.md at the repo root. Other tools use AGENTS.md, Spec Kit calls it the constitution, and Kiro calls these steering files. Keep it short: stack, rules, and how you test.

# Project constitution (every agent reads this)

## Stack
- Next.js (App Router), TypeScript, Postgres via Prisma   <- replace with yours

## Rules
- Specs live in specs/<feature>/ (spec.md, plan.md, tasks.md). The spec is the source of truth.
- No new dependencies without asking.
- Small diffs: one task = one commit.
- If the spec is unclear, stop and ask. Do not guess.

## Tests
- Test command: `npm test` (vitest). All tests green before a PR.
- Every acceptance criterion in spec.md has at least one test.

Tip: the most useful line is the test command. An agent that can run your tests can check its own work.


Agent 1: The spec writer

Job: turn your idea into specs/<feature>/spec.md. Never writes code.

The spec has user stories ("As a shopper, I can save my cart") and numbered acceptance criteria (AC-1, AC-2...). Each criterion is written so it can be tested: WHEN the user logs out THE SYSTEM SHALL keep their cart. That "when / shall" style comes from EARS, the format Kiro uses for requirements. It's a good habit even if you never use Kiro.

Save this as .claude/agents/spec-writer.md:

---
name: spec-writer
description: Turns a feature idea into specs/<feature>/spec.md with user stories and acceptance criteria. Use first, before any planning or code.
tools: Read, Write, Glob, Grep
model: opus
---
You write specs, never code.

1. Read CLAUDE.md and skim the code the feature touches.
2. Write specs/<feature>/spec.md with:
   - Goal: one paragraph, the user problem and why it matters.
   - User stories: "As a <user>, I can <action>, so that <benefit>." (US-1, US-2...)
   - Acceptance criteria: numbered AC-1, AC-2..., each testable, written as
     "WHEN <condition> THE SYSTEM SHALL <behaviour>".
   - Out of scope: what this feature will NOT do.
   - Open questions: anything you had to assume.
3. Do not choose libraries, schemas or file layouts. That is the planner's job.
4. Do not write or edit source code or tests.

Your review #1 happens here. Read the spec. Fix wrong assumptions now, while it's one Markdown file and not 400 lines of code.


Agent 2: The planner

Job: read the approved spec and write two files. plan.md holds the design: data, routes, components and edge cases. tasks.md is a checklist of small tasks, each tied to the acceptance criteria it covers.

Good tasks are small (under about an hour of work), testable on their own, and ordered so the app still builds after each one.

Save this as .claude/agents/planner.md:

---
name: planner
description: Reads an approved spec.md and writes plan.md (design) and tasks.md (small, ordered, testable tasks). Use after the spec is reviewed.
tools: Read, Write, Glob, Grep
model: opus
---
You turn a spec into a plan. You do not write source code.

1. Read CLAUDE.md and specs/<feature>/spec.md. If an AC is ambiguous, list it under "Questions" and stop.
2. Write specs/<feature>/plan.md: data model changes, API/route changes, components, edge cases, and which ACs each part covers.
3. Write specs/<feature>/tasks.md as a checklist:
   - [ ] T1 <task>  (covers AC-1)
   Each task is small (under ~1 hour of work), testable on its own, and ordered so the app builds after every task.
4. Every AC must be covered by at least one task.

Example tasks.md:

- [ ] T1 Add saved_carts table              (covers AC-1)
- [ ] T2 Save cart on logout, restore on login  (covers AC-1)
- [ ] T3 Empty-cart hint                    (covers AC-2)

Agent 3: The builder

Job: take one open task, write a failing test, then write the code that makes it pass. Run the full test suite, then tick the task.

One task per run keeps diffs small and easy to review. It also stops the agent from "helpfully" rewriting half the app.

Save this as .claude/agents/builder.md:

---
name: builder
description: Implements exactly one open task from tasks.md, test first. Use repeatedly until all tasks are done.
tools: Read, Edit, Write, Bash, Glob, Grep
model: sonnet
---
You implement ONE task per run.

1. Read CLAUDE.md, spec.md, plan.md and tasks.md. Pick the first unchecked task.
2. Write a failing test for the AC(s) the task covers. Run the tests and confirm it fails.
3. Write the smallest code change that makes it pass. Follow plan.md; if the plan is wrong, stop and say why.
4. Run the full test command from CLAUDE.md. All green, or you are not done.
5. Tick the task in tasks.md ([x]) and summarise what changed in 3 lines.
Never work on more than one task. Never edit spec.md.

Run it again for each task until tasks.md is all [x].


Agent 4: The reviewer

Job: compare the diff with the spec, one acceptance criterion at a time, and list what's missing. It has read-only tools (Read, Glob, Grep), so it can't "fix" things by itself. Anything it finds goes back to the builder as a new task.

Save this as .claude/agents/reviewer.md:

---
name: reviewer
description: Read-only review of the current diff against spec.md, one acceptance criterion at a time. Use after the builder finishes.
tools: Read, Glob, Grep
model: sonnet
---
You review. You never edit files.

1. Read CLAUDE.md and specs/<feature>/spec.md.
2. Look at the changed files. For each AC, answer: met / not met / not tested, with the file and line that proves it.
3. Also flag: rule violations from CLAUDE.md, code outside the spec's scope, missing error handling for edge cases in plan.md.
4. Output a short list. Anything "not met" or "not tested" goes back to the builder as a new task line for tasks.md.

Example review:

AC-1 Cart persists after logout ... met (src/cart/session.ts:42, test cart.spec.ts:18)
AC-2 Empty cart shows a hint ...... NOT MET: no empty state in CartPanel.tsx
-> add to tasks.md: - [ ] T4 Empty-cart hint in CartPanel (covers AC-2)

Running one feature, start to finish

In Claude Code, you can ask for a subagent by name:

  1. Use the spec-writer agent: let shoppers save their cart across sessions
  2. Read spec.md. Edit it. (Review #1)
  3. Use the planner agent on specs/saved-cart
  4. Use the builder agent for the next open task. Repeat until every task is ticked.
  5. Use the reviewer agent on the current diff. Send any gaps back to step 4.
  6. Read the final diff. (Review #2) Open the PR.

Two habits make this work: commit after each builder task, and start a fresh session when a conversation gets long. The spec files carry the context, so you don't need the chat history.

All five files are above: copy the constitution into CLAUDE.md at your repo root and the four agent files into .claude/agents/, then edit the stack and test lines to match your project.


Same flow in GitHub Spec Kit and Kiro

You don't need Claude Code to work this way. The same phases exist in other tools:

PhaseThis setupGitHub Spec KitKiro
RulesCLAUDE.md/speckit-constitutionSteering files
Specspec-writer → spec.md/speckit-specifyrequirements.md
Planplanner → plan.md/speckit-plandesign.md
Tasksplanner → tasks.md/speckit-taskstasks.md
Buildbuilder/speckit-implementRun tasks
Checkreviewer/speckit-converge–

Spec Kit is open source and works with several coding agents. You install it with uv tool install specify-cli and start a project with specify init. Its docs suggest running the commands one at a time and reviewing each result before you continue. That's the same two-review rhythm as above. Kiro keeps its specs in .kiro/specs/<feature>/ as requirements.md, design.md and tasks.md.


Common mistakes

  • Skipping review #1. If the spec is wrong, everything after it is confidently wrong. Five minutes here saves an hour later.
  • Specs that describe code instead of behaviour. "Add a saved_carts table" is a plan, not a spec. Write what the user sees and what must be true.
  • Tasks that are too big. "Build the cart feature" isn't a task. If a task can't be tested on its own, split it.
  • Giving every agent every tool. The tool limits are the guardrails. A reviewer that can edit files will quietly patch problems instead of reporting them.
  • Using it for everything. A one-line bug fix doesn't need a spec. Use this flow for features that touch more than a couple of files.

About "5x"

You'll see "3x to 5x faster" in a lot of write-ups about spec-driven development, and some say "up to five times". To be clear: those numbers come from developers and teams reporting their own experience. They are not results from a controlled study. The only randomized result quoted in this post is METR's, and it measured a slowdown with early-2025 tools.

What the evidence supports is narrower and still useful. Giving agents clear, written context and smaller, well-defined tasks consistently comes up in the teams that get more out of AI. Your own speed-up will depend on your codebase, your tests and how well you write specs. Measure it: count merged PRs and rework before and after you switch.


Sources

  • METR, "Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity", July 2025. Randomized study, 16 developers: tasks took 19% longer with AI; developers expected a 24% speed-up and afterwards believed it was 20%. metr.org
  • METR, "We are Changing our Developer Productivity Experiment Design", February 2026. Says developers are likely more sped up by newer tools, but its 2026 data is not statistically reliable. metr.org
  • Claude Code docs, "Create custom subagents": .claude/agents/ Markdown files with YAML frontmatter (name, description, tools, model); each subagent has its own context window. code.claude.com
  • GitHub Spec Kit: constitution, specify, plan, tasks, implement and converge commands; install with uv tool install specify-cli. github.com/github/spec-kit
  • Kiro docs, "Specs": requirements.md, design.md and tasks.md in .kiro/specs/. kiro.dev
  • "Spec-Driven Development: From Code to Contract in the Age of AI Coding Assistants", arXiv 2602.00180. arxiv.org
  • Examples of self-reported 3x to 5x claims: Level Up Coding, Kanopy Labs.

More guides