Spec-driven development with AI: a 6-step workflow with templates

Spec-driven development with AI: a 6-step workflow with templates

Spec-driven development with AI means you and your coding agent write down what to build (requirements, a short design and a task list) and review it before the agent writes any code. This guide gives a six-step workflow, copyable templates and prompts, a comparison of GitHub Spec Kit, Kiro and a plain SPEC.md, and a rule for when a spec is overkill.

In shortTL;DR
  • A spec is a reviewed Markdown file with requirements, acceptance criteria, design decisions and a task list; it becomes the agent's definition of done.
  • Let the agent interview you to draft the spec, then edit it yourself: the decisions in it must be yours.
  • Start implementation in a fresh session that reads the spec, and have a separate reviewer check the diff against it.
  • GitHub Spec Kit and Kiro automate the requirements, design and tasks phases; a single SPEC.md with Claude Code or Codex works for most teams.
  • Skip the spec for small fixes you could describe in two sentences; use it for features that touch several files, change data or will run unattended.

What is spec-driven development with AI?

Spec-driven development with AI is a workflow where a written specification, not a chat history, tells the coding agent what to build. You write (or co-write with the agent) the requirements, the key design decisions and an ordered task list, review them, and only then let the agent implement against that file.

The spec usually lives in the repository as Markdown, for example SPEC.md or specs/rate-limiting/spec.md. It does three jobs:

  • Alignment. You catch the wrong interpretation in a page of text, before it becomes 40 changed files.
  • Context. A fresh agent session reads the spec instead of depending on a long conversation that may have been compacted.
  • Definition of done. The acceptance criteria are what tests and reviewers check the code against.

Birgitta Böckeler's analysis of SDD tools on martinfowler.com describes three levels of commitment. Spec-first: write a spec before coding a task. Spec-anchored: keep the spec after the task and update it as the feature evolves. Spec-as-source: humans edit only the spec and the code is generated from it. Most teams today practice spec-first, and that is what this guide teaches.

Why write a spec before letting an agent code?

A spec moves your decisions to the cheapest point: before the agent has written anything. Coding agents fill gaps with plausible guesses, and the guesses compound across files, so ten minutes on a spec often saves an hour of corrections.

Anthropic's Claude Code best practices put the same idea in practical terms: when Claude builds something different from what you had in mind, it is usually missing information it can't get from reading the repo. The spec is where that information goes. The same page lists a spec file as one way to tell an unattended agent "what done looks like", next to a goal condition or a failing test.

Specs help most when:

  • The feature touches several files or layers (API, database, UI).
  • There are product decisions the code can't reveal: limits, error messages, who can see what.
  • Several agents or people will work on parts of it.
  • The agent will run without you watching, for example overnight.

How does spec-driven development work, step by step?

The workflow has six steps: interview, draft, review, plan tasks, implement in a fresh session, and verify against the spec. Each step ends with a file you can read, which is what makes the process reviewable.

1. Let the agent interview you

Start with what you know and ask the agent to ask questions until it could write the spec. This is the prompt from Anthropic's best practices page, and it works in any agent:

prompt
I want to add rate limiting to the public API but haven't thought it through yet. Interview me until you could write the spec, then write it to SPEC.md.

Claude comes back with questions about the parts you haven't decided: per-user or per-key limits, what happens to requests over the limit, what is out of scope.

2. Draft the spec from a template

Ask for the spec in a fixed structure so every spec in the repository reads the same way. The template in the next section is a good default.

3. Review and edit the spec yourself

Read every requirement and acceptance criterion. Delete anything you didn't ask for, fix wrong assumptions about the codebase, and mark open questions. This is the step that makes the process worth it; a spec nobody reviewed is a long prompt.

4. Turn the design into tasks

Ask the agent to break the work into small, ordered tasks, each with the files it touches and how to verify it. Our guide to writing tasks for AI agents covers what makes a task the right size.

5. Implement in a fresh session

Start a new session that reads the spec. The best practices page recommends this so the build begins with a clean context and a written definition of done. In Claude Code you can also start in plan mode (claude --permission-mode plan, or Shift+Tab to cycle modes), where Claude researches and proposes a plan but edits stay blocked until you approve it.

prompt
Read SPEC.md. Implement tasks 1 to 3 only. After each task, run the tests listed under "Verification" and tick the task in SPEC.md. Stop and ask if the spec is ambiguous or wrong; do not guess.

6. Verify against the spec

Have a second agent compare the diff with the spec, not hunt for bugs in general. Anthropic's example review prompt:

prompt
use a subagent to review the rate limiter diff against SPEC.md, check every requirement is implemented and the listed edge cases have tests, report gaps that affect correctness and skip style

A read-only reviewer subagent with only Read, Grep and Glob tools can't "fix" things quietly while reviewing.

What should a spec template for AI agents include?

A good spec template has six parts: goal, requirements with acceptance criteria, out of scope, design decisions, tasks and verification. Keep it to one to three pages; the agent needs decisions, not essays.

A notebook with handwritten notes next to a keyboard on a wooden desk
Write down the decisions an agent cannot infer from the code
SPEC.md
# Spec: <feature name>## GoalOne paragraph: who needs this, what changes for them, why now.## Requirements- R1: WHEN <condition> THE SYSTEM SHALL <behavior>.- R2: ...## Acceptance criteria- [ ] AC1 (R1): <observable result, e.g. "6th request in 60s returns 429 with Retry-After">- [ ] AC2 (R2): ...## Out of scope- <things the agent must not build or change>## Design- Data: <tables, fields, migrations>- Interfaces: <endpoints, function signatures, events>- Decisions: <choice made, alternative rejected, one-line reason>- Constraints: <libraries to use or avoid, performance, security>## Tasks1. [ ] <task> (files: ..., verify: ...)2. [ ] ...## Verification- Commands: <test, lint, typecheck commands>- Manual check: <what a human clicks through>## Open questions- <decisions still pending; the agent stops here instead of guessing>

Two details make the template work with agents. The Out of scope list stops the agent from "helpfully" refactoring nearby code. The Open questions list gives it a sanctioned place to stop, which you reference in the implementation prompt.

The requirement lines use EARS notation (Easy Approach to Requirements Syntax), which Kiro uses in its requirements files: WHEN [condition/event] THE SYSTEM SHALL [expected behavior]. Each line is specific enough to become a test. Project-wide rules (test commands, code style) belong in CLAUDE.md or AGENTS.md rather than every spec; see CLAUDE.md best practices.

GitHub Spec Kit vs Kiro vs a plain SPEC.md: which should you use?

Use a plain SPEC.md with the agent you already have unless you want enforced phases and generated templates. GitHub Spec Kit adds a command-driven process to many agents, and Kiro builds specs into its IDE.

GitHub Spec KitKiroPlain SPEC.md + agent
What it isOpen source CLI (MIT) plus agent commandsAgentic IDE with a spec modeA Markdown file and prompts
Works withClaude Code, GitHub Copilot, Codex and many othersKiroAny agent
FilesConstitution, spec.md, plan.md, tasks.mdrequirements.md (or bugfix.md), design.md, tasks.mdOne file, your structure
PhasesConstitution, specify, clarify, plan, tasks, analyze, implement, convergeRequirements, design, tasks (or design first)Interview, review, tasks, build, verify
Best forTeams that want a repeatable, auditable processDevelopers who want specs inside the editorMost features, small teams

GitHub Spec Kit in practice

Spec Kit needs Python 3.11+, uv and a supported coding agent. Install the CLI and set up a project:

terminal
uv tool install specify-clispecify init my-project --integration claude

Then run the steps inside your agent's chat, one at a time, reviewing each result. As of November 2026, the README's minimal flow is /speckit-constitution, /speckit-specify, /speckit-plan, /speckit-tasks, /speckit-implement and /speckit-converge, repeating implement and converge until convergence reports Converged. For production features the quickstart adds /speckit-clarify, /speckit-checklist and /speckit-analyze as quality gates; analyze reports conflicts and gaps across spec.md, plan.md and tasks.md without changing them. The spelling depends on your agent: the reference docs use dots (/speckit.specify) and Codex uses $speckit-specify.

Kiro in practice

Kiro offers Feature Specs, Bugfix Specs and a Quick Spec that generates all three files in one pass without approval gates. For feature specs you choose Requirements-First (behavior, then design, then tasks) or Design-First (technical design, then the requirements and tasks it allows).

When is spec-driven development overkill?

A spec is overkill when you could describe the whole change in two sentences and verify it by looking at one diff. Böckeler's tool review found exactly this failure: Kiro turned a small bug into four user stories, and spec-kit produced "a LOT of markdown files" to review, which she called overkill for the size of the problem.

TaskSpec?Use instead
Fix a typo, rename a variable, bump a dependencyNoA direct prompt
Fix a bug with a known causeRarelyA failing test plus a prompt
Add a field to an existing form and APIMaybeA short plan in plan mode
New feature across API, database and UIYesFull spec
Migration, auth, billing or anything irreversibleYesFull spec plus human review of the design
Unattended or overnight agent runYesSpec with explicit verification

Two more warnings from practice. Agents can still ignore parts of a spec, so the verification step is not optional. And reviewing pages of generated Markdown is real work; if you find yourself skimming, the spec is too long.

Common mistakes with AI-written specs

Most spec failures come from treating the agent's draft as finished. The spec should record your decisions; the agent's job is to ask good questions and format the answers.

  • Accepting the first draft. Agents add plausible features nobody asked for. Cut them.
  • Vague acceptance criteria. "Handles errors gracefully" can't be tested. "Returns 422 with a field-level message" can.
  • No out-of-scope list. The agent widens the change to adjacent code.
  • Design by the agent alone. For data models, auth and anything you can't easily undo, decide yourself.
  • Stale specs. If you change course during implementation, update the spec first, then the code. Otherwise the next session builds against an outdated plan.
  • One giant spec. Split features that need more than about ten tasks.

Spec-driven work is also what makes vibe coding safe to grow out of: the prototype tells you what you want, the spec captures it, and the agent rebuilds it properly.

How to start with spec-driven development today

Try the workflow on your next medium-sized feature before adopting any tool.

  1. Copy the template above into docs/specs/TEMPLATE.md in your repository.
  2. Run the interview prompt for one real feature and let the agent write SPEC.md.
  3. Spend 15 minutes editing it: cut, decide, add acceptance criteria.
  4. Start a fresh session, implement the first three tasks and run the verification commands.
  5. Ask a reviewer subagent to compare the diff with the spec.
  6. Note where the agent went off-spec, and add that kind of detail to the template.

A reviewed spec with clear verification is also what lets an agent work while you are away. If you want that to happen on a server instead of your laptop, Orkio runs Claude Code and Codex on an always-on cloud box: you hand over the task from your phone, close the app, and review the pull request later. For the overnight version of this loop, see our overnight AI agent workflow.

Frequently asked questions

What is the difference between spec-driven development and vibe coding?

Vibe coding steers the AI turn by turn and judges the result by running it. Spec-driven development fixes the requirements, design and tasks in a written file first, and the agent builds against that file. Vibe coding is faster for prototypes; specs pay off when the code must be maintained or the agent works without you watching.

Is spec-driven development the same as waterfall?

No. A spec for an AI agent covers one feature and takes minutes to an hour to write, not weeks. You still ship in small increments, and the spec changes when you learn something during implementation.

Do I need GitHub Spec Kit or Kiro to do spec-driven development?

No. Both tools structure the process with commands and templates, but the core is a Markdown file the agent reads and a review step. Claude Code's plan mode or a SPEC.md in the repository gives you the same loop with no extra tooling.

How long should a spec be for an AI coding agent?

Long enough that a new developer could build the feature without asking you questions, usually one to three pages. If the spec is longer than the code it describes, split the feature or cut the spec.

What is EARS notation?

EARS (Easy Approach to Requirements Syntax) writes each requirement as a fixed sentence pattern such as WHEN a condition occurs THE SYSTEM SHALL do something. Kiro uses it in its requirements files, and each sentence is specific enough to turn into a test.

SOURCES

  1. Claude Code docs: Best practices
  2. Claude Code docs: Permission modes (plan mode)
  3. GitHub Spec Kit repository
  4. Spec Kit docs: SDD quickstart
  5. Kiro docs: Specs
  6. Birgitta Böckeler: Understanding Spec-Driven Development: Kiro, spec-kit, and Tessl
  • #ai coding
  • #specs
  • #workflow
  • #claude code
  • #planning
Orkio team

The team building Orkio. We write about putting AI to work: coding agents that run overnight, always-on boxes and pull requests ready by morning.

Keep reading

All posts

07:06 · YOU MERGED #128

Go to sleep. Wake up to pull requests.

Start for $19 a month
© 2026 Orkio · Hosted in Europe TürkçeStatus