Skip to content
Derar Sattouf

Spec-Driven Development in 2026: Moving AI Coding Beyond Vibe Coding

Updated AI engineering

Spec-Driven Development in 2026: Moving AI Coding Beyond Vibe Coding

In late 2024 and throughout 2025, "vibe coding" captured developer culture. You opened a chat window with an LLM, described what you wanted in casual prose, accepted the generated code, and iterated by intuition. For weekend hacks, exploratory prototypes, and single-file scripts, vibe coding felt like magic.

Then those prototypes reached production.

As codebases expanded past 10,000 lines and survived multiple release cycles, teams hit what engineers now call the three-month wall. Natural language chat sessions lacked persistence. One agent would optimize a database query using raw SQL; another agent, prompted three days later in a separate window, would rewrite the module using an unoptimized ORM pattern. Subtly, architectural drift set in, edge cases were dropped, and technical debt compounded faster than developers could audit it.

In 2026, the software engineering consensus has matured. AI coding agents are no longer novelty assistants; they are autonomous contributors that execute significant portions of the codebase. But to make agents reliable at scale, engineering teams are replacing exploratory prompt banter with Spec-Driven Development (SDD).

In SDD, code is no longer the primary artifact manually written by humans or improvised by chat prompts. Code is a derivative output generated by agents from precise, version-controlled specifications.

Vibe coding is for discovery; spec-driven development is for production. Conversational prompting is great for greenfield prototyping, but it creates architectural drift and untracked edge cases in production systems. SDD inverts the relationship between code and documentation: the specification is the version-controlled source of truth, and the code is compiled by the agent to satisfy the spec.

Every major feature moves through four explicit artifacts: a constitution (global conventions), a specification (requirements and invariants), a plan (architectural blueprint) and tasks (an atomic, verifiable checklist). Token economy matters too. Giving an agent a 20-page requirement document in one prompt degrades attention, while decomposing specifications into isolated, verifiable task loops keeps context windows clean. And an agent is only allowed to check off a task when machine-checkable criteria (unit tests, typechecks and linter runs) pass cleanly.

If you are new to working with agents, start with the earlier posts on how to structure repository context, working with coding agents as async teammates, and orchestrating automated background agents.

Why vibe coding hits the "three-month wall"

To understand why Spec-Driven Development has gained such fierce momentum, look at how pure conversational AI coding fails over time:

[Vibe Coding Loop]
Prompt ──> AI writes code ──> Test visually ──> Re-prompt ──> Commit
   ▲                                                             │
   └────────── Context lost when session resets ─────────────────┘
  1. Context decay across chat sessions: LLMs do not share memory across separate conversation windows. When a developer opens a new tab on Monday morning to fix a regression, the agent has zero recollection of why a helper function was written with a specific concurrency lock on Friday.
  2. Intent-to-implementation drift: When you ask an agent to "make user onboarding faster," it might aggressively cache responses in memory, unknowingly bypassing authentication checks or introducing stale data bugs for multi-tenant users.
  3. Ghost dependencies and inconsistent patterns: Without hard guardrails, an agent might install lodash-es in one file, use native ES6 methods in another, and pull in a redundant date formatting library in a third.
  4. The review burden: Reviewing a monolithic 800-line pull request produced by twenty iterative chat prompts is exhausting. The reviewer cannot distinguish deliberate architectural decisions from accidental agent hallucinations.

Vibe coding optimizes for token generation velocity, but engineering organizations care about system maintainability, correctness, and auditability.

What is spec-driven development (SDD)?

Spec-Driven Development reverses the workflow. Instead of prompting an agent to immediately produce TypeScript, Python, or Go code, the developer collaborates with the agent to create a machine-verifiable specification first.

[Spec-Driven Development Pipeline]
1. Constitution (AGENTS.md) ──> Establishes project rules & non-negotiables
2. Specification (spec.md)   ──> Defines functional requirements & invariants
3. Technical Plan (plan.md)  ──> Maps architectural changes & file touched
4. Task Matrix (tasks.md)    ──> Breaks work into atomic, testable steps
5. Agent Execution Loop      ──> Implements task -> Runs tests -> Checks box

In SDD:

  • The human developer acts as the System Architect and Quality Gatekeeper.
  • The specification acts as the Contract.
  • The AI agent acts as the Executor and Test Implementer.

Because the spec lives as Markdown files inside the repository, it benefits from git version control, peer review, and branch isolation.

The four pillars of the SDD pipeline

A production-ready spec-driven workflow consists of four structured layers:

Pillar 1: the project constitution (AGENTS.md)

Before an agent can read a feature specification, it must know the project's foundational laws. As detailed in our guide on context engineering, this lives in an AGENTS.md file at the root of the repository.

The constitution defines:

  • The canonical tech stack and approved package ecosystem.
  • Forbidden patterns (e.g., "Never use any in TypeScript; never query the database from a React component").
  • Exact build, lint, and test commands.
  • Security boundaries (e.g., "Never expose internal IDs to client endpoints").

Pillar 2: the feature specification (spec.md)

When building a new capability, create a scoped directory (for instance, docs/specs/idempotent-webhooks/ or specs/billing-tier-upgrade/). The spec.md outlines what is being built and why, completely independent of low-level implementation details.

A good spec.md includes:

  • User scenarios: Precise user stories and background context.
  • Data invariants: Schema definitions, input validations, and state machines.
  • Edge cases and failure modes: What happens during network timeouts, database deadlocks, or malformed payloads.
  • Acceptance criteria: Concrete, unambiguous assertions written in testable language.

Pillar 3: the technical blueprint (plan.md)

Once the human reviews and approves the spec.md, the AI agent is instructed to produce plan.md. This is where the agent plans the technical execution:

  • Existing files that need modification.
  • New files, schemas, and routes to be created.
  • Database migration strategy.
  • Potential risks and breaking changes.

The developer reviews the plan to verify that the agent's architectural approach aligns with the team's patterns before any code is generated.

Pillar 4: the task matrix (tasks.md)

The agent translates the approved plan.md into an ordered, atomic checklist in tasks.md.

Each task must be:

  • Small: Limited to 1–3 files.
  • Self-contained: Capable of passing tests and typechecks independently.
  • Verifiable: Accompanied by a specific test command.
<!-- tasks.md snippet -->

- [ ] Task 1.1: Create `WebhookEvent` Prisma schema and run migration
  - Verification: `pnpm prisma migrate dev`
- [ ] Task 1.2: Implement Zod payload validation in `lib/webhooks/schema.ts`
  - Verification: `pnpm vitest run tests/webhooks/schema.test.ts`
- [ ] Task 1.3: Implement idempotent deduplication check in Redis
  - Verification: `pnpm vitest run tests/webhooks/dedup.test.ts`

Walkthrough: building an idempotent webhook engine

Let’s see SDD in practice. Suppose we need to build an idempotent Stripe webhook processing pipeline in a Next.js application with PostgreSQL.

Step 1: authoring the spec.md

Rather than typing "write a webhook handler that handles stripe idempotently", we author specs/webhooks/spec.md:

# Feature Specification: Idempotent Stripe Webhook Pipeline

## 1. Objective

Ensure all inbound Stripe webhook events are processed exactly once,
even when Stripe delivers duplicate payloads or network retries occur.

## 2. Invariants & Rules

1. Signature Verification: Every incoming payload must be verified with the
   Stripe webhook secret before parsing.
2. Idempotency Key: Store `event.id` in a dedicated `processed_events` table.
3. Concurrency Protection: If two identical event IDs arrive simultaneously,
   only one must process; the duplicate must return HTTP 200 immediately.
4. Transactional Integrity: Business logic execution (account crediting)
   and event status updates must execute inside a single database transaction.

## 3. Failure Modes

- Missing or invalid Stripe signature: Return HTTP 400 immediately.
- Duplicate event ID: Log event as DUPLICATE and return HTTP 200 with `{ received: true }`.
- Downstream database failure during processing: Return HTTP 500 so Stripe retries later.

## 4. Acceptance Criteria

- [ ] Unit test: Rejects payloads missing `stripe-signature` header.
- [ ] Unit test: Rejects tampered payloads.
- [ ] Integration test: Submitting event `evt_100` twice results in exactly
      one database mutation and two HTTP 200 responses.
- [ ] Typecheck: All event handler maps are strictly typed with `Stripe.Event`.

Notice the precision: there is no ambiguity about HTTP status codes, race conditions, or transaction boundaries.

Step 2: the agent generates plan.md

We prompt our coding agent:

"Read AGENTS.md and specs/webhooks/spec.md. Draft a technical implementation plan in specs/webhooks/plan.md. Do not write application code yet."

The agent produces a structured architectural roadmap:

# Architecture Plan: Idempotent Stripe Webhooks

## File Changes

1. `prisma/schema.prisma`: Add `WebhookEventLog` table with unique constraint on `eventId`.
2. `src/server/webhooks/verify.ts`: Webhook signature cryptographic check.
3. `src/server/webhooks/processor.ts`: Transactional processor with advisory locks.
4. `src/app/api/webhooks/stripe/route.ts`: Next.js Route Handler.
5. `tests/webhooks/stripe.test.ts`: Vitest test suite.

## Database Migration

Table: `WebhookEventLog`

- `id`: UUID (Primary Key)
- `eventId`: VARCHAR(255) (Unique Index)
- `eventType`: VARCHAR(100)
- `processedAt`: TIMESTAMP
- `status`: ENUM ('PROCESSING', 'COMPLETED', 'FAILED')

Because you can read this in under a minute, you catch architectural flaws before the agent writes hundreds of lines of code.

Step 3: executing the task loop

With the plan verified, the agent works through tasks.md sequentially. The prompt to the agent is straightforward:

"Execute Task 1.1 from specs/webhooks/tasks.md. Run the designated verification command. If it passes, mark the checkbox [x] and pause for review."

The agent:

  1. Creates the migration file.
  2. Runs pnpm prisma migrate dev.
  3. Checks the terminal output for clean exit code 0.
  4. Updates tasks.md to - [x] Task 1.1.

If an error occurs (such as a foreign key constraint conflict), the agent reads the terminal traceback, corrects the migration, and reruns the check. It does not move to Task 1.2 until Task 1.1 is verified.

Tools that implement this workflow

You can run SDD with plain Markdown files and any agent, but several tools package the workflow. The tooling is changing fast, so verify each project's current commands and status.

ToolApproach
GitHub Spec Kit (open source)A CLI that scaffolds a spec-driven structure for many coding agents: a constitution file, then slash commands to create a specification, a plan, a task list, and to implement.
Kiro (AWS)An agentic IDE built around three artifacts per feature: requirements, design and tasks, with requirements written in EARS notation.
Tessl and similarTreat the spec as the maintained source of truth, with code generated from it; a more experimental direction.
Plain files plus AGENTS.mdThe lightweight DIY approach described here; works with Claude Code, Cursor, Copilot, Codex and others.

Spec Kit's flow, in outline (command names have changed between releases, so check its README):

# Install and initialize in an existing repository (verify the current install command in the README)
uvx --from git+https://github.com/github/spec-kit.git specify init my-feature --ai claude

# Then, inside the agent, run its slash commands in order, for example:
#   constitution -> specify -> plan -> tasks -> implement

Writing requirements people and agents can both test: EARS and Given/When/Then

EARS (Easy Approach to Requirements Syntax) templates remove ambiguity:

Ubiquitous:   The system shall <response>.
Event-driven: When <trigger>, the system shall <response>.
State-driven: While <state>, the system shall <response>.
Unwanted:     If <condition>, then the system shall <response>.
Optional:     Where <feature is included>, the system shall <response>.

Example:
When a Stripe event with an already processed id is received,
the system shall return HTTP 200 and shall not run business logic again.
If the stripe-signature header is missing, then the system shall return HTTP 400.

Given/When/Then scenarios map almost one-to-one onto tests:

Given a processed event evt_100
When the same event evt_100 arrives again
Then the response is 200 and the account balance is unchanged

Because the criteria are executable, an agent can turn each one into a test first, watch it fail, then implement. That is test-driven development with the spec as the test plan. See unit testing with AI.

Templates you can copy

# Spec: <feature name>

## Context and goal
One paragraph: who needs this and why now.

## Non-goals
What this change deliberately does not do.

## Requirements
- R1 (EARS): When ..., the system shall ...
- R2 (EARS): If ..., then the system shall ...

## Data and interfaces
Schemas, endpoints, events, state machine. Link to existing code by path.

## Failure modes
Timeouts, retries, partial failures, abuse cases.

## Acceptance criteria
- [ ] AC1: Given ... when ... then ... (test: tests/path.test.ts)

## Open questions
Things the agent must ask about rather than guess.
# Tasks: <feature name>
Rules: one task per commit; do not start a task until the previous one is verified.

- [ ] T1 Add migration for processed_events (files: prisma/schema.prisma). Verify: pnpm test:db
- [ ] T2 Signature verification (files: src/server/webhooks/verify.ts). Verify: pnpm vitest run verify

Verification gates: make "done" machine-checkable

The most valuable idea in SDD is that an agent cannot claim success without evidence. Put the gates in one command and in CI:

{
  "scripts": {
    "check": "pnpm typecheck && pnpm lint && pnpm test --run && pnpm test:e2e:smoke",
    "typecheck": "tsc --noEmit",
    "lint": "biome check .",
    "test": "vitest"
  }
}
# .github/workflows/check.yml
name: check
on: [pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
      - uses: actions/setup-node@v4
        with: { node-version: 24, cache: pnpm }
      - run: pnpm install --frozen-lockfile
      - run: pnpm check

Add traceability so reviewers see requirement coverage: name tests after acceptance criteria (AC1_duplicate_event_returns_200) and have the PR description list which requirements each commit satisfies. For correctness of AI features themselves (not just code), add evaluations; see evals for LLM apps. For reviewing the generated diffs safely, see securing AI-generated code.

Vibe coding vs. spec-driven development

Here is how the two approaches compare across core engineering metrics:

MetricVibe CodingSpec-Driven Development (SDD)
Primary InputAd-hoc natural language promptsVersion-controlled markdown specifications
Context ManagementEphemeral chat history (lost on reset)Persistent file artifacts (spec.md, tasks.md)
Architectural DriftHigh (each prompt introduces subtle variance)Low (bounded by project constitution)
Code Review DifficultyExhausting (massive monolithic diffs)Fast & structured (reviewed against task list)
Tool CompatibilityLocked to a specific chat window or IDEUniversal (works with Claude Code, Cursor, Copilot, custom CLI agents)
Best Suited ForSpikes, hackathons, single-file scriptsProduction apps, multi-developer teams, critical systems
Failure ModeAccumulates tech debt at 3 monthsUpfront overhead if specs are over-engineered

Practical rules for writing good specs

To keep SDD productive without drowning in administrative bureaucracy, follow these practical rules:

Specify invariants, not implementations

Describe what must hold true, not every single line of code.

  • Weak spec: "Create a function called calcDiscount that uses an if statement to check if the user is a premium member."
  • Strong spec: "Users with tier PREMIUM receive 15% off cart totals over $50. Discounts cannot reduce cart value below $0.00. Floating point rounding must round half-up to two decimal places."

The strong spec gives the agent room to use idiomatic code while guaranteeing business accuracy.

Include negative test cases

Agents are naturally eager to satisfy the happy path. A great spec spends half its space defining what should not happen:

  • What happens when the JWT has expired?
  • What happens if the payload size exceeds 1MB?
  • What happens if the external API returns a 503 gateway timeout?

Keep specs co-located in Git

Do not bury specifications in external tools or ephemeral dashboards where agents cannot access them. Store specs directly in your repository:

my-app/
├── AGENTS.md
├── specs/
│   ├── auth-passkeys/
│   │   ├── spec.md
│   │   ├── plan.md
│   │   └── tasks.md
│   └── billing-stripe/
│       ├── spec.md
│       ├── plan.md
│       └── tasks.md
└── src/

When specs live in the repository, any agent launched in that workspace can read them instantly, and pull requests include both the specification and the implementation diff together.

The hybrid workflow: when to vibe, when to spec

Spec-Driven Development does not mean you can never vibe code again. Senior engineers use a hybrid cadence:

  1. Phase 1: exploration and spikes (vibe coding) When you don't yet know how an unfamiliar library works or how a complex UI layout should feel, open an exploratory session. Vibe code freely to throw ideas at the screen. Treat this code as disposable research.
  2. Phase 2: consolidation (spec authoring) Once the spike proves the concept, discard the scratchpad code. Write a concise spec.md capturing what you learned, the edge cases you discovered, and the data schema you want.
  3. Phase 3: production build (spec-driven execution) Instruct the agent to execute against the spec with full type safety, thorough test coverage, and clean commit hygiene.

Criticisms and failure modes of SDD

Spec-driven development is not free, and critics (including practitioners writing about Kiro, Spec Kit and similar tools) raise fair points:

  • It can become waterfall in disguise. Long up-front documents for small changes slow teams down. Size the spec to the risk: a bug fix needs a paragraph, not a template.
  • Review fatigue moves, it does not vanish. Reading generated specs, plans and tasks is still work. Agents tend to produce verbose Markdown; trim it.
  • Specs drift from code. If code changes without updating the spec, the spec becomes a lie that future agents will trust. Make spec updates part of the definition of done, and delete obsolete specs.
  • Agents still ignore instructions sometimes. More context is not a guarantee. Verification gates, not prose, enforce compliance.
  • Non-determinism remains. Running the same spec twice yields different code. Tests and reviews, not the spec alone, define correctness.
  • Over-specification of implementation removes the agent's room to find simpler solutions and reintroduces the cost of maintaining redundant documentation.

Right-sizing the process

Change typeSuggested artifact set
Typo, copy change, small bugA clear prompt plus a regression test
Single-module featureA short spec with acceptance criteria, then tasks
Cross-module or data-model changeFull spec, plan and tasks, with human review of the plan
Security, payments, migrationsFull spec, explicit failure modes, extra review and staged rollout
ExplorationVibe coding in a throwaway branch

What tends to go wrong

  • Writing specs that describe the implementation line by line instead of the behavior and invariants.
  • Skipping the plan review: this is the cheapest moment to catch architectural errors.
  • Giving the agent the whole spec bundle for every task instead of the relevant slice; context bloat hurts accuracy. See context engineering for coding agents.
  • Letting the agent edit the spec to match what it built without human approval.
  • Having no machine-checkable acceptance criteria, so "done" is a feeling.
  • Ignoring non-functional requirements: performance budgets, accessibility, security, observability, cost.
  • Never pruning: old specs and tasks files pile up and confuse agents.

Team practices that make it stick

  1. Specs go through code review like any other change, with the same owners.
  2. Short-lived specs for features, durable docs for architecture: archive finished feature specs, and promote lasting decisions into ADRs (architecture decision records).
  3. One agent, one task, one branch for parallel work, with the task list as the coordination mechanism. See automated development workflows with background agents.
  4. Measure lead time, review time, defect rate and rework per change type. If SDD does not reduce rework on your team, trim it.
  5. Train people to write specs: a good spec is a good ticket plus tests. Pair on the first few.
  6. Security review for specs that touch auth or data; see prompt injection defense for AI agents if agents read external content while executing tasks.

A few questions

Is SDD just waterfall with AI? It is iterative at the feature level: small specs, quick plan review, implementation in minutes to hours, and the spec updated as you learn. Avoid large up-front design for small changes.

Does it work with any agent? Yes, because the artifacts are Markdown files in the repository. Tool-specific commands differ, but the files are portable. See AI coding agents in 2026.

How long should a spec be? Long enough to remove ambiguity about behavior and failure modes. One to two pages is typical for a feature.

Who writes the first draft? Often the agent, from your bullet notes and an interview-style prompt ("ask me questions until the requirements are unambiguous"), then you edit.

What about existing codebases? Start with the next feature or bug. Ask the agent to summarize the current behavior of the module into the spec first (characterization), review it, then specify the change.

How is this different from TDD or BDD? It builds on them: acceptance criteria become tests. SDD adds the plan and the persistent artifacts that keep agents aligned across sessions.

Sources and docs

More on this site