Materials / Approach

Spec-driven development with AI agents

An agent that works from a chat message fills every gap with a guess. A short, checkable specification in the repository moves those guesses into questions a person answers before any code exists. Here is what to write, how the process runs, and where it stops paying off.

9 min read25 Sep 2026Ilia Poliakov

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:

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.

  1. SpecifyScenarios, numbered requirements, acceptance criteria. No technology choices yet: what, not how.
  2. 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.
  3. PlanArchitecture, data changes, contracts, risks. This is where the agent proposes how, and a person approves it.
  4. Break into tasksSmall steps, each one checkable on its own: a test that goes green, a page that renders.
  5. 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.

SectionWhat it holds
ContextWhy the change is needed, in two or three sentences, with a link to the issue.
RequirementsNumbered statements of behavior. One behavior per line.
Acceptance criteriaGiven / When / Then, each tied to the test that proves it. See AI test generation.
Out of scopeWhat the agent must not do, even if it looks helpful. This line prevents more scope creep than any other.
ConstraintsPerformance, security, compatibility, modules that must not change.
Open questionsThe 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.

LevelWhat happens to the specFits
Spec-firstWritten before the task, used to build it, not maintained after the merge.New features; the place to start.
Spec-anchoredKept beside the code and edited first whenever the feature changes.Modules that change often, where the spec saves rediscovering the rules.
Spec-as-sourceThe 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

# 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

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.