From Vibe Coding to Spec-Driven Development

From Vibe Coding to Spec-Driven Development

Updated November 2026 - added how to generate specs with a coding agent, why Gherkin .feature files in Git are a good home for them, and how a team approves agent-written specs with clear rights and checks.

You type a prompt into your AI coding agent. "Build me a user authentication system with email and password." Code appears. It looks reasonable. You run it, and something works, but not quite the way you imagined. So you refine the prompt. More code appears. You go back and forth five, ten, fifteen times until you either get what you wanted or settle for what you got.

This is vibe coding. And for millions of developers, it's the default way to work with AI. But there's a growing realization in the developer community that vibe coding, while great for quick experiments, falls apart when you need predictable, maintainable software.

There's a more structured approach gaining momentum. It's called spec-driven development, and it puts specifications before code instead of letting the AI decide what to build.

What is vibe coding?

The term was coined by Andrej Karpathy in February 2025 to describe a style of AI-assisted programming where you surrender to the vibes. You describe what you want in natural language, the AI generates code, and you iterate through conversation until the result feels right.

The workflow looks like this: you write a prompt, the model generates code based on what it thinks you want, you review the output, edit your prompt, and repeat. Eventually, after a few rounds, you land on something that works.

Vibe coding works well for certain things. Prototyping a UI concept in minutes. Scaffolding a quick script to process some data. Learning how a library works by asking the AI to build something with it. Exploring ideas without committing to architecture.

But the limitations show up fast.

Where vibe coding breaks down

The fundamental issue with vibe coding is ambiguity. When you tell an AI "build me a login page," it has to make dozens of decisions you never specified. Which authentication library? Session-based or token-based? Where do error messages appear? What happens on rate limiting? How are passwords validated?

The AI fills in those blanks on its own. And it fills them differently every time. Run the same prompt ten times, and you might get ten different implementations. This is fine when you're exploring, but it's a problem when you need a specific outcome.

Beyond unpredictability, vibe coding skips the traditional software development lifecycle almost entirely. There's no planning phase, no requirements document, no design review. Decisions live in a chat thread, not in documentation. When a new team member joins, there's no spec to read - just a trail of prompts and iterations.

Testing becomes an afterthought. You build first, then figure out what to test. And because the AI made architectural decisions you never explicitly approved, you're testing an implementation you don't fully understand.

Technical debt accumulates invisibly. The AI chose a pattern in iteration three, built on top of it in iteration seven, and by iteration twelve, you have a codebase shaped by a series of conversational pivots rather than deliberate design.

What is spec-driven development?

Spec-driven development workflow: Spec, Requirements, Design, Implement, Test - with human oversight on the first three steps and AI handling implementation and testing

Spec-driven development takes the opposite approach. Instead of prompting the AI with what you want it to build, you first describe what the system should do - the behavior, the constraints, the inputs, the outputs, the error cases. This specification becomes a contract that drives everything downstream.

The workflow looks fundamentally different:

Step 1: Write the specification. Before any code exists, you describe the feature's behavior. Not implementation details, but what the system should do from the outside. For a payment webhook, this means: it accepts POST requests at /webhooks/stripe, validates the signature header, processes checkout.session.completed events, updates the order status in the database, and returns a 200 acknowledgment within 5 seconds.

Step 2: Generate requirements. Hand the spec to your AI agent and ask it to produce a structured requirements document. Review it. Does it capture everything? Did it infer reasonable defaults for things you didn't specify? Approve or refine.

Step 3: Create a design document. The AI turns approved requirements into implementation tasks with specific to-dos for code, tests, and documentation. You review the design before a single line of code is written.

Step 4: Implement. Now the AI writes code. But instead of improvising from a vague prompt, it's following a spec. The retry strategy, the idempotency handling, the timeout behavior - these were all decided in the spec, not left to the model's imagination.

Step 5: Generate and run tests. Here's where it gets powerful. Because the spec defines inputs, outputs, and edge cases explicitly, test cases generate themselves. Valid signature returns 200. Missing header returns 401. Duplicate event ID is safely ignored. The spec is the test contract.

The key insight is simple: AI models are excellent at following detailed instructions, but poor at inferring what you want from vague ones. Spec-driven development gives them better instructions.

A concrete example: vibe coding vs spec coding

The vibe coding approach:

"Build me a Stripe webhook handler. Use Node.js. It should process payments and update orders."

The AI produces something. Maybe it verifies signatures, maybe it doesn't. Maybe it handles duplicate events, maybe it processes them twice. Maybe it responds before processing, maybe it blocks until the database write completes. You don't know until you read the output, and by then the decisions are already baked in.

The spec-driven approach:

Feature: Stripe Webhook Handler

Endpoint: POST /webhooks/stripe
Headers: { stripe-signature: string }
Validates: HMAC-SHA256 signature using STRIPE_WEBHOOK_SECRET

Events handled:
  checkout.session.completed → set order status to "paid"
  charge.refunded → set order status to "refunded"
  All other events → acknowledge with 200, no action

Constraints:
- Idempotent: store processed event IDs, skip duplicates
- Respond with 200 before async processing (Stripe retries on timeout)
- Log all events to webhook_events table
- Retry failed DB writes 3 times with exponential backoff

Error responses:
- Invalid signature → 401 { error: "INVALID_SIGNATURE" }
- Unknown event type → 200 (acknowledge silently)
- DB write failure after retries → 500, alert ops channel

When the AI implements this, there's no ambiguity. Every decision is made. Every edge case is defined. The implementation matches the spec, and the tests verify the spec. If something doesn't work, you know whether it's a spec problem or an implementation problem.

How spec-driven development connects to TDD and BDD

Evolution of development approaches: Traditional (Code First, Docs Later) to TDD (Tests First, Code Later) to BDD (Behavior First, Tests and Code Later) to Spec-Driven (Specs First, AI Does the Rest)

If this reminds you of test-driven development or behavior-driven development, you're right. Spec-driven development extends both TDD and BDD by adding AI to handle the implementation, turning your specification into the primary artifact that drives all downstream work.

In traditional development, the flow was: write code first, document later. Your intuition drives the architecture, and documentation catches up eventually (or never).

Test-driven development flipped part of this: write tests first, then write code to make them pass. The tests define expected behavior before implementation begins.

Behavior-driven development took it further by expressing those tests in natural language (Gherkin syntax) that non-developers can read and validate. A product manager can review a .feature file and confirm "yes, that's what the webhook should do" before any code exists.

Spec-driven development extends this chain: specifications first, then design, then code, then tests. The spec is the single source of truth, and AI handles the downstream work of turning specs into implementations and tests.

BDD also hands spec-driven development something practical: a file format for the spec. That leads to the questions a team has to answer once it agrees that the spec comes first. Who writes it? Where does it live? Who approves it?

How to generate specs with a coding agent

You do not have to write every line of a spec by hand. The agent that writes your code can also draft the spec, as long as you control what it drafts from and what it is allowed to decide. Six habits make the difference.

1. Start from the requirement, never from the code. Give the agent the user story, the ticket, or your own notes. Do not ask it to write a spec for code it has already produced. A spec written from the code describes what the code does, bugs included, and every test you derive from it will pass.

2. Make the agent ask before it writes. Agents fill gaps silently. Turn that around with one instruction:

Read the ticket below. Before you write anything, list the questions
you need answered to specify this feature. Do not guess. Do not write
scenarios yet.

The questions are often the most useful output of the session. "What happens when the same event arrives twice?" is a decision you want to make yourself, not one you find in the code three weeks later.

3. Ask for behavior, not clicks. Ask for scenarios in Gherkin, the Given/When/Then format from BDD. One behavior per scenario. Steps say what the system does, not which button a user presses, so the spec survives a redesign. Ask for the failure cases by name: invalid input, missing permission, duplicate request, timeout.

Here is the webhook spec from above as an agent drafts it:

Feature: Stripe webhook handler

  Scenario: A paid checkout marks the order as paid
    Given an order "1042" with status "pending"
    When Stripe sends a signed "checkout.session.completed" event for order "1042"
    Then the response status is 200
    And order "1042" has status "paid"

  Scenario: A request with an invalid signature is refused
    When Stripe sends a "checkout.session.completed" event with an invalid signature
    Then the response status is 401
    And the error code is "INVALID_SIGNATURE"

  Scenario: A duplicate event is processed once
    Given the event "evt_123" was already processed
    When Stripe sends the signed event "evt_123" again
    Then the response status is 200
    And no order changes

4. Put your conventions in the agent's rules file. Where the feature files live, how scenarios are named, which tags exist, what a step may mention. Write this once in CLAUDE.md, AGENTS.md or your Cursor rules, and every spec the agent drafts has the same shape.

5. Edit the draft the way you would edit a new colleague's work. The agent gives you twenty scenarios in a minute. Delete the ones that repeat each other. Add the edge case that only your team knows about. The draft is cheap. The decision about what goes in is still yours.

6. Change the spec and the code in the same pull request. The spec change comes first in the diff and first in the review. If the code changed and the spec did not, the change was a refactor or the spec is now wrong.

Why Gherkin .feature files, and why they stay in Git

A spec can live in many places. A chat thread is gone when the session ends. A wiki page is correct on the day someone writes it and drifts after that. A ticket describes one change, not how the system behaves today.

A .feature file is a plain text file in your repository. That one fact gives you most of what a spec needs:

  • It moves with the code. Same branch, same pull request, same release tag. Check out last month's release and you get last month's spec with it.
  • A behavior change shows up as a diff. A reviewer sees "a refund now sets the order to refunded" as one changed line in plain language, before reading any code.
  • It has a history. git log and git blame tell you who changed a rule, when, and in which pull request.
  • The agent can read it with no setup. It is a file in the working directory. Every session starts with the current spec in reach, and you can point the agent at one scenario by path and line.
  • People who do not write code can read it. Given/When/Then is close to plain English. A product owner can confirm a scenario without a walkthrough.
  • It can run. Cucumber, Behave, pytest-bdd and Reqnroll bind each step to code and run the scenario as an automated test. When the code stops matching the spec, the build fails.

Gherkin has limits. It describes behavior from the outside, so it is the wrong place for a database schema, an architecture decision or a performance budget. Keep those in a short design note next to the feature files, in the same repository, for the same reasons.

Who approves the spec? Rights and checks for agents and people

An agent can write a spec in a minute. So the slow, valuable step is no longer the writing. It is the moment when someone says "yes, this is what we want". When coding agents and a development team work on the same specs, that moment needs a few rules.

The author does not approve. This is the oldest rule of code review, and it applies to specs too. If an agent drafted the scenario under your account, you are the author. Someone else approves.

The agent gets its own account and the smallest set of rights. A bot account with its own token can push to a branch and open a pull request. It cannot merge to the main branch, and it cannot approve. Every change then carries a name, and you can tell what a person did from what an agent did.

Two reviews answer two different questions. A pull request review asks: is this file consistent with the code and with the other specs? Developers answer that. A behavior review asks: is this what the product should do? A QA lead or a product owner answers that, and they often do not work in Git.

Approval is a gate, not a courtesy. Protect the main branch. Use a CODEOWNERS file so a named group must approve every change under features/. Keep scenarios that nobody has approved out of the regression run.

Feedback is written where the agent can read it. "Can we talk about scenario three?" in a meeting never reaches the agent. A comment attached to the scenario does. The agent reads it, changes the file, and the review starts again.

A passing test is not an approval. Automated checks tell you that the code matches the spec. They cannot tell you that the spec is right. A person decides that, and for anything a user touches, a person still tries it.

Keep the record. Who approved which version of which scenario, and when. Customers in regulated industries ask for exactly this.

Most of these rules need nothing more than Git and discipline. Branch protection and CODEOWNERS cover the first review. The second review is harder, because the people who own the behavior are usually not in the repository. The next three sections show how we handle that part in TestCollab.

Keeping specs and test management in sync

TestCollab is a test management tool: a team keeps its test cases there, runs them, and reports the results. If your specs are .feature files, TestCollab's BDD sync reads them from your repository and keeps one test case for each scenario:

tc sync --project 42

Run that in your CI pipeline, and every merge updates the test cases. Git stays the source of truth. The sync goes one way, from the repository to TestCollab, and a synced test case is not edited in the web interface. Developers define behavior in the repository, QA plans, runs and tracks it in the tool, and nobody maintains a second copy by hand.

Feature files in a Git repository on the left, and the matching test cases in TestCollab on the right, kept in step by tc sync

The approval workflow for synced specs

A TestCollab project can require review: a reviewer must approve each new or changed test case. Since November 2026, the sync works with that setting:

  • A new or changed scenario is saved as "under review". It goes to the project's default reviewer group, where any member can pick it up, or to the default reviewer.
  • A scenario that did not change keeps its approval. One edited scenario does not send the whole feature file back to review.
  • Each reviewer gets one email per sync, not one email per test case.
  • A test case under review cannot be added to a test plan, the set of test cases a team selects for one test cycle. Behavior that nobody approved stays out of the run.
  • The reviewer approves, or asks for changes with a comment.

The rights follow the rules above. The sync runs with the API token of a bot account that is not a reviewer, because nobody can review their own test cases. So the pipeline that delivers an agent's specs cannot approve them.

Closing the loop: the agent reads review feedback through MCP

The reviewer's comment now sits in TestCollab, and the agent works in the repository. MCP connects the two. MCP (Model Context Protocol) is an open standard that lets an AI assistant call the tools of another product. The TestCollab MCP server gives Claude Code, Cursor, Codex and other MCP clients tools for test cases, test plans and results.

Version 1.6.0 added the tool get_test_case_reviews. For one test case or for a whole project, it returns the review status (review_pending, approved, update_requested or rejected), the author, the reviewer or reviewer group, the review comments as plain text, and a link to each case. It can keep only the cases that have comments, and it can include earlier review rounds.

The setup is one block in the agent's MCP configuration. For Claude Code, that is .mcp.json in the project root:

{
  "mcpServers": {
    "testcollab": {
      "command": "npx",
      "args": ["-y", "@testcollab/mcp-server"],
      "env": {
        "TC_API_TOKEN": "your-api-token",
        "TC_DEFAULT_PROJECT": "42"
      }
    }
  }
}

The MCP setup guide has the same block for Cursor, Codex and Claude Desktop. After that, the loop is one prompt:

Read the review feedback for this project. For every test case where
the reviewer requested changes, find the scenario with the same title
in features/, apply the requested change, and open a pull request.
Change nothing else.

The agent changes the .feature file, not the test case, because Git is the source of truth. After the merge, the sync sends the changed scenario back to review, and the reviewer sees the new version.

The spec approval loop: an agent drafts a feature file from a requirement, developers review the pull request, tc sync sends the scenarios to TestCollab, a QA lead or product owner approves or requests changes, and the agent reads the review comments through MCP

Two details keep this safe. The tool only reads: an agent cannot approve or reject a review through it. And the agent works with the API token you give it, so the API applies that account's project access and role to every call.

The same server covers the rest of the cycle. An agent can read the cases of a test plan, run them, and report each result with evidence files. TestCollab marks those results as run by an agent, so a report never mixes what a person checked with what an agent checked.

This is the full circle: the spec drives the implementation, tests derived from the same spec verify it, a person who did not write it approves it, and the chain is traceable from requirement to test result.

You do not need this part for a solo project where a green CI run is enough proof. The Git habits above are free and they cover it. The sync and the review step earn their place when someone other than the author has to agree on the behavior, or has to show later who agreed.

Tools for spec-driven development

The spec-driven approach is tool-agnostic - it's a workflow pattern, not a product feature. But several tools make it easier:

GitHub Spec Kit is an open-source framework specifically built for spec-driven development with AI. It provides templates for writing specs and works with AI coding agents like Claude Code, Cursor, and GitHub Copilot to generate implementations from them.

Claude Code with CLAUDE.md files lets you define project conventions, architectural decisions, and specifications in markdown files that Claude reads before generating code. The CLAUDE.md file acts as a persistent spec that shapes every interaction.

Cursor Rules serve a similar purpose - .cursorrules files define how the AI should approach your project, what patterns to follow, and what constraints to respect.

PRD-driven workflows in tools like GitHub's Copilot coding agent start from a product requirements document and generate implementation plans before writing code.

The common pattern across all of these: give the AI structured context before asking it to code.

When to vibe code vs when to spec code

These aren't competing philosophies. They're different tools for different situations.

Vibe code when:

  • You're prototyping or exploring an idea
  • The project is a one-off script or throwaway experiment
  • You're learning a new framework or library
  • Speed matters more than predictability
  • You're the only person who'll ever touch the code

Spec code when:

  • The project will be maintained by a team
  • You need predictable, reproducible implementations
  • Testing and QA are part of the process
  • The feature has defined requirements or edge cases
  • You're building something that needs to work the same way every time

Many developers find the sweet spot is starting with vibe coding to explore and prototype, then switching to spec-driven development once the idea solidifies and needs to be built properly.

Getting started with your first spec-driven project

You don't need new tools to try this. Pick a feature you're about to build and spend twenty minutes writing a spec before opening your AI agent.

A basic spec should cover:

  • What the feature does (one paragraph)
  • Inputs it accepts (data types, validation rules)
  • Outputs it produces (success and error responses)
  • Constraints it operates under (performance, security, business rules)
  • Edge cases it must handle (what happens when things go wrong)

Hand this to your AI coding agent instead of a vague prompt. You'll notice the difference immediately: fewer iterations, more predictable output, and a document you can hand to a QA engineer or a new team member.

If you work in a team, add three habits from the first day. Keep the spec in the repository, next to the code. Let the agent draft and a person edit. And make sure the one who approves is not the person, or the agent, who wrote it.

The shift from vibe coding to spec-driven development isn't about giving up speed. It's about spending time in the right place. Twenty minutes on a spec saves two hours of prompt iteration and produces code you can actually trust.

And in a world where AI can write code faster than any human, the person who writes the best spec wins. For a team, add one condition: someone other than the author approved it.

If your specs are .feature files and you want that approval step, start a free TestCollab trial and run the sync on one repository. The sync also handles dataset-driven Scenario Outlines, result reporting without IDs in the feature files, and archiving for removed scenarios; the details are in BDD test management from Git: what's new in tc sync.