What spec-driven development is
Spec-driven development (SDD) starts a change from a specification: what the system must do, under which constraints, and how anyone will check that it does. The agent builds a plan, a list of tasks and then the code from that document, not from a conversation.
It grew out of a problem every team that tried agents ran into. With requirements scattered across chat history, the agent filled gaps with plausible guesses, wrote confident code around them, and the guesses surfaced in review or in production. Andrej Karpathy's 2025 name for the unreviewed version of this, "vibe coding", stuck because it described a real habit. SDD is the opposite habit: the requirements are a file in the repository, versioned and reviewed like code, and the code is judged against them.
A spec is not a heavyweight requirements document. A good one fits on a screen or two, and every line in it is either a decision or a way to check one.
Why write a spec if the agent understands the task?
The agent understands the words. It does not know which of the ten reasonable readings you meant, and it will not tell you which one it picked. A spec helps in four concrete ways:
- The agent asks instead of guessing. Gaps show up as open questions before the code is written, when answering them costs a sentence rather than a rewrite.
- Review gets shorter. The reviewer, person or agent, checks the change against numbered criteria rather than reconstructing the intent from the diff.
- Defects become traceable. When something breaks you can tell whether the spec was wrong (fix the spec and its template) or the spec was right and the code was wrong (fix the rules and checks in the harness).
- Work can be handed over. The spec separates what from how, so the planning, the coding and the review can be done by different sessions, or different people, without losing the decisions in between.
How the process runs
Most SDD tools and teams converge on the same five stages. A person decides at the transitions; the agent does the work inside each one.
- SpecifyScenarios, numbered requirements, acceptance criteria. No technology choices yet: what, not how.
- ClarifyThe agent reads the spec against the code and lists what is missing or ambiguous. A person answers; the answers go into the spec, not into chat.
- PlanArchitecture, data changes, contracts, risks. This is where the agent proposes how, and a person approves it.
- Break into tasksSmall steps, each one checkable on its own: a test that goes green, a page that renders.
- ImplementThe agent writes code task by task. Tests and review check the result against the acceptance criteria, not against the agent's own summary.
What goes into a spec
Six sections cover almost every change. Leave a section empty rather than padding it.
| Section | What it holds |
|---|---|
| Context | Why the change is needed, in two or three sentences, with a link to the issue. |
| Requirements | Numbered statements of behavior. One behavior per line. |
| Acceptance criteria | Given / When / Then, each tied to the test that proves it. See AI test generation. |
| Out of scope | What the agent must not do, even if it looks helpful. This line prevents more scope creep than any other. |
| Constraints | Performance, security, compatibility, modules that must not change. |
| Open questions | The agent appends them during clarify; a person answers in place. |
Here is a small example. A subscription service bills monthly renewals, and customers who signed up on the 31st were being charged on the 1st of the following month whenever the next month was shorter.
# specs/renewal-billing-date.md
## Context
Monthly renewals for subscriptions started on the 29th–31st are billed
on the 1st of the next month when the month is shorter. Issue #<n>.
## Requirements
R1. A monthly renewal is billed on the same day of the month as the
subscription started.
R2. If that day does not exist in the month, the renewal is billed on
the month's last day.
R3. The following renewal goes back to the original day when it exists.
## Acceptance criteria
AC1. Given a subscription started on 31 January,
when February's renewal runs,
then it is billed on 28 February (29 in a leap year).
-> tests/billing/test_renewal_dates.py::test_short_month
AC2. Given the same subscription,
when March's renewal runs,
then it is billed on 31 March, not 28 March.
-> tests/billing/test_renewal_dates.py::test_back_to_anchor
AC3. Given a subscription started on 15 May,
then every renewal is billed on the 15th.
-> tests/billing/test_renewal_dates.py::test_ordinary_day
## Out of scope
- Annual plans (separate issue).
- Changing the invoices table.
## Constraints
- The renewal job's run time must not grow by more than a few percent.
- Dates are computed in the customer's billing time zone, not the server's.
## Open questions
- Q1 (agent): Should customers already billed on the wrong day be
refunded? -- A (product): No; support handles it case by case.
Notice AC2. The obvious fix for AC1, "clamp the day to the month's length", silently moves every later renewal to the 28th. Writing the criterion down is what catches that, before any code exists. Criteria added after a real defect, like this one, are the most valuable lines in a spec.
Three levels of SDD
Birgitta Böckeler's article on martinfowler.com, "Understanding Spec-Driven-Development: Kiro, spec-kit, and Tessl", separates three levels by what happens to the spec after the task.
| Level | What happens to the spec | Fits |
|---|---|---|
| Spec-first | Written before the task, used to build it, not maintained after the merge. | New features; the place to start. |
| Spec-anchored | Kept beside the code and edited first whenever the feature changes. | Modules that change often, where the spec saves rediscovering the rules. |
| Spec-as-source | The only thing a person edits; the code is generated from it and never touched by hand. | Experimental. Böckeler warns it risks combining model-driven development's rigidity with an LLM's non-determinism. |
The same article is worth reading for its criticisms. One tool turned a small bug into four user stories and sixteen acceptance criteria; another produced so much repetitive markdown that reviewing it was more tedious than reviewing code; and agents still ignored parts of the spec. The lesson is to scale the spec to the change, not to apply one heavy template to everything.
Tools: Spec Kit, Kiro, or markdown in the repository
- GitHub Spec Kit is an open-source (MIT) toolkit that installs templates and commands into a repository. Its workflow starts from a constitution of project principles, then runs specify, plan, tasks and implement as commands inside your coding agent.
- Kiro is an IDE with SDD built in. A spec is three files:
requirements.md(user stories and acceptance criteria),design.mdandtasks.md. It suits a team willing to change its editor. - Your own templates in a
specs/folder, plus one rule in the agent's instructions, give most of the benefit with nothing to install:
# In AGENTS.md / CLAUDE.md
## Specs
- A task that touches more than one module starts from specs/<task>.md,
made from specs/_template.md.
- Before coding, read the spec and list anything ambiguous under
"Open questions". Do not guess an answer.
- Before saying a task is done, check every acceptance criterion
against its test and name any that has no test.
When tasks live in a tracker
Most teams already keep work in Jira, Linear or GitHub Issues, and SDD does not ask them to stop. Keep the tracker as the place where work is planned and counted, and keep the spec in the repository where the agent and the code are. The ticket links to the spec file and the spec links back. The agent can draft the spec from the ticket; a person approves it; a change of requirement goes through a pull request against the spec, so the history of decisions sits next to the history of code.
When a spec is not worth it
- Small, local changes. A typo, a dependency bump, a refactor inside one module. Good instructions and tests are enough.
- Throwaway prototypes. If the code will be deleted next week, so will the spec.
- Exploration. When nobody knows yet what the answer looks like, run a time-boxed spike first, then write the spec from what you learned.
The rule of thumb runs the other way too: the more modules and teams a change touches, the more detailed the spec should be.
Questions
How is a spec different from an ordinary requirements document?
It is shorter, every acceptance criterion is tied to a test, it lives in the repository next to the code, and it changes through a pull request. A requirements document describes intent; a spec is something the agent and the reviewer can check against.
Who writes the spec?
The agent drafts it from the issue and the code; the person who owns the outcome approves it: a product manager, an analyst or the tech lead. The approval is the point. A spec nobody read is a guess written down.
Does SDD slow a team down?
On the first tasks, yes: writing and approving criteria takes time. That time comes back as shorter review and fewer rounds of rework, because the disagreements surface before the code. Small changes can skip the spec entirely.
Do we need Spec Kit or Kiro to start?
No. A template in specs/ and three lines in the agent's instructions are enough to find out whether the practice fits your team. Adopt a tool once you know what you want from it.
Take your team there, step by step
A 13-week pilot on one team: a baseline, a harness built around your process, real backlog tasks through the whole cycle, and the numbers before and after.