DEV Community

planu-dev.ai
planu-dev.ai

Posted on • Originally published at planu.dev

SDD vs TDD: Why Spec Driven Development Changes the Game for AI-Assisted Coding

SDD vs TDD: Why Spec Driven Development Changes the Game for AI-Assisted Coding

Most developers are familiar with TDD — Test Driven Development. Write a failing test, make it pass, refactor. It's been a cornerstone of software craft for over two decades. But as AI coding agents enter the picture, a different kind of discipline is emerging: Spec Driven Development (SDD).

This article breaks down what each approach does, where they differ, and why SDD has become essential for teams working with AI tools like Claude, Cursor, or Windsurf.

What is TDD?

Test Driven Development is a micro-cycle practice. The loop is tight:

  1. Write a failing test that describes desired behavior
  2. Write the minimum code to make the test pass
  3. Refactor without breaking the test

TDD operates at the code level. Its primary job is to keep the implementation honest: the test expresses what a function or module should do, and the code must satisfy that contract.

The benefits are real. TDD forces you to think about interfaces before implementation. It catches regressions early. It creates a living documentation of expected behavior. Teams that practice TDD consistently ship more maintainable code.

The limitation is equally real: TDD doesn't tell you what to build. You still need to decide what the feature is, what it accepts, what it returns, how it handles edge cases, and how it interacts with other parts of the system. TDD assumes you've already made those decisions.

What is SDD?

Spec Driven Development is a pre-implementation discipline. Before any code is written — and before any AI agent writes a single line — you create a specification that defines:

  • What the feature does (user story, acceptance criteria)
  • How it fits into the architecture (affected files, new types, dependencies)
  • What risks exist (edge cases, performance concerns, rollback complexity)
  • How success is measured (concrete, verifiable criteria)

SDD operates at the feature level. It produces documents — typically a User Story file and a Technical Sheet — that serve as contracts between the developer (or agent) and the intended outcome.

The cycle looks like this:

  1. Write the spec (spec.md + technical.md)
  2. Get explicit approval from the team or product owner
  3. Implement against the spec
  4. Validate with automated quality gates
  5. Merge only when all criteria pass

The Key Differences

Dimension TDD SDD
Scope Function / module Feature / spec
Timing Before writing the function Before writing any code
Artifact Test file Spec document + acceptance criteria
Primary concern "Does this code do what I wrote?" "Are we building the right thing?"
Works well for Implementation correctness Feature scope, AI agent direction
Fails without Clear requirements Approval gate before coding

These are complementary, not competing. TDD answers "is this implementation correct?" — SDD answers "is this the implementation we agreed to build?"

Why AI Coding Agents Break Without Specs

Here's the real-world problem: AI agents are highly capable at generating code, and nearly incapable of maintaining long-term coherence without structured context.

When you ask Claude or Copilot to "add a user settings page," you get code. But:

  • It may contradict a decision made two sprints ago
  • It may introduce a new database schema when you already had one for the same data
  • It may handle error cases differently from your existing patterns
  • In a parallel session, another agent may be building the same feature from a different angle

Without a spec, every AI session is a fresh start. The agent has no contract to honor, no acceptance criteria to satisfy, and no way to know when it's done. The result is feature sprawl, inconsistency, and the kind of technical debt that's hard to name but easy to feel.

With a spec, the agent has:

  • Explicit acceptance criteria it must satisfy
  • The architecture constraints it must respect
  • A definition of done that both you and the agent can verify

When to Use Each

Use TDD when:

  • You're implementing a well-defined module with clear inputs and outputs
  • You're fixing a bug and want to prevent regression
  • You're refactoring and need a safety net

Use SDD when:

  • You're starting a new feature, even a small one
  • You're working with AI coding agents (always)
  • Multiple people or agents may work on the same area
  • The feature touches more than one file or layer
  • You want an explicit approval gate before any code is written

Use both when: you're building software seriously. SDD tells everyone what's being built. TDD verifies it was built correctly.

How Planu Helps

Planu is an MCP server that brings SDD discipline directly into your AI coding workflow. When you install Planu, your AI agent gains access to tools that:

  • Create structured spec documents (create_spec) with User Stories and Technical Sheets
  • Enforce an approval gate before any implementation begins
  • Track implementation status against acceptance criteria
  • Validate the spec is complete before marking it done

The workflow with Planu looks like this:

User: "Add OAuth login support"
Agent: [uses create_spec] → generates spec.md + technical.md
User: reviews and approves the spec
Agent: [implements against the spec, tracks progress]
Agent: [uses validate_spec] → all criteria checked
Merge when gates pass
Enter fullscreen mode Exit fullscreen mode

The agent doesn't guess at scope. It has a contract.

Getting Started

SDD doesn't require Planu — you can practice it with any structured document format. But if you want the discipline enforced automatically within your AI coding sessions, Planu integrates directly with Claude, Cursor, Windsurf, and any MCP-compatible agent.

Read the Getting Started guide to set up Planu in under five minutes.

The spec is the contract. TDD verifies the code. Together, they close the loop.

Top comments (0)