Spec-Driven Development
Youâve watched it happen: you ask an AI agent to âadd photo sharing to the appâ and it builds something. The code compiles. Tests pass. But the architecture doesnât match what youâd choose. The data model makes assumptions youâd never make. And now youâre three days into a feature that needs a rewrite.
This is the vibe coding trap. The agent isnât brokenâitâs doing exactly what you asked. The problem is you asked for code when you should have asked for clarity first.
Spec-Driven Development (SDD) flips the script. Instead of jumping straight to implementation, you define what you want in a specification that becomes the source of truth. The spec isnât documentation written after the factâitâs an executable contract that determines what gets built.
The problem with code-first
Section titled âThe problem with code-firstâWhen you prompt an AI agent without clear specifications, youâre asking it to read your mind. And language models are exceptional at pattern completion, not mind reading.
What happens with vague prompts:
- The agent makes reasonable assumptionsâsome will be wrong.
- Requirements emerge incrementally, locking you into early decisions.
- The codebase becomes the de-facto specification.
- Crucial decisions get trapped in Slack threads or peopleâs heads.
- Major rewrites require enormous effort because code is inherently binding.
You discover issues deep into implementation when theyâre expensive to fix. The agent built what you said, not what you meant.
What SDD actually is
Section titled âWhat SDD actually isâLetâs be clear about what SDD isnât:
- Not waterfall planning: Youâre not writing exhaustive documentation before touching code.
- Not bureaucracy: This shouldnât slow you down; it should prevent expensive rework.
- Not predicting the future: Youâre capturing current understanding, which evolves.
SDD is making technical decisions explicit, reviewable, and evolvable. Itâs version control for your thinking.
The core insight: Specifications become living documents that evolve alongside code. Theyâre active tools that help you think through edge cases, coordinate across teams, and enable multi-variant implementations.
When your spec turns into working code automatically, intent becomes the source of truthânot the code itself.
The SDD workflow
Section titled âThe SDD workflowâSDD breaks development into distinct phases. Each phase has a specific purpose and produces artifacts that feed the next phase.
Phase 0: Constitution (optional but recommended)
Section titled âPhase 0: Constitution (optional but recommended)âBefore any iteration begins, establish the rules of the game. What are your non-negotiable principles?
What goes in a constitution:
- Testing approaches and standards
- Security policies and compliance rules
- Design system constraints
- Tech stack conventions (CLI-first, API-first, etc.)
- Engineering practices
- Integration requirements
This becomes the guardrails that guide all development. The agent knows whatâs off-limits before it writes a single line of code.
Phase 1: Specify
Section titled âPhase 1: SpecifyâDefine the âwhatâ and âwhyâ: the problem, users, scope, and success criteria.
Focus on:
- Problem statement
- User personas and cohorts
- Key user flows and experiences
- Success metrics
- Constraints (performance, privacy, security)
- Whatâs explicitly out of scope
Avoid: Technical implementation details, stack choices, architecture (that comes later).
Example specification prompt:
Build a trip planner that generates day-by-day itineraries for multi-city trips.
Problem: help travelers plan multi-city trips with realistic timing, budget guidanceUsers: casual travelers, travel bloggers, small tour operatorsKey flows: create trips, add cities, auto-generate itinerary, adjust by preferencesNon-functional: P95 itinerary generation under 4 seconds for 7-day tripsOut of scope: airline booking, hotel paymentsThe output is a structured SPEC.md that captures requirements. The agent may flag [NEEDS CLARIFICATION] sectionsâresolve these before proceeding.
Phase 2: Plan
Section titled âPhase 2: PlanâTranslate the product spec into technical implementation. Now youâre defining the âhowâ.
Focus on:
- Tech stack selection
- Architecture and design patterns
- Integration boundaries
- Data contracts and schemas
- Performance targets
- Security approach
- Identified risks
Example planning prompt:
Stack: FastAPI + Postgres + Redis; Next.js front end; mobile via Expo.Architecture: API-first, backend service + vector store for place of interest (POI) embeddings.AI: routing agent for POIs, scheduler for packing days, critic for validation.Performance: target end-to-end plan in under 4 seconds at P95.Security: redact PII in logs, encrypt at rest.The output is a PLAN.md with technical architecture. A key benefit: you can generate multiple plan variations to compare different approaches before committing.
Phase 3: Tasks
Section titled âPhase 3: TasksâBreak the spec and plan into manageable, testable, ordered work items.
Each task includes:
- Clear description
- Acceptance criteria
- Dependencies
- Links to spec sections
- Test requirements
Example task breakdown:
- API contract for itinerary generation with schemas
- Agent prompts and guardrails
- Data loaders for POI metadata
- Caching and rate-limit handling
- Frontend flows: create trip, edit preferences, view itinerary
- Observability: timing spans, cost tracking, error taxonomies
By default, test-related items are included and ordered before implementationâTDD structure baked in.
Phase 4: Implement
Section titled âPhase 4: ImplementâExecute tasks in small slices while staying within constraints.
Key practice: Keep agents pointing back to SPEC.md and PLAN.md for every change. Work from the spec, plan, or task file rather than ad-hoc prompts. Execute in small, reviewable chunks.
Example implementation slice:
- Implement POST /itinerary with schema validation
- Add scheduler agent prompt respecting constraints
- Cache lookups and transit matrices
- Verify against acceptance criteria
Each chunk should solve a specific piece of the puzzle.
Phase 5: Testing
Section titled âPhase 5: TestingâTesting isnât a separate phaseâitâs integrated throughout. Tests attach directly to requirements for traceability.
Types of tests:
- Contract tests: API request/response validation
- Property tests: Constraint verification (e.g., no day exceeds 10km walking)
- Performance tests: P95 latency under target
- Security tests: PII redaction, encryption verification
The trace from âwhat was promisedâ to âwhat was deliveredâ becomes auditable.
Phase 6: Maintain
Section titled âPhase 6: MaintainâRequirements change. SDD handles this gracefully:
- Update spec first
- Regenerate plan
- Update tasks
- Let agents refactor within boundaries
- Extend tests for new rules
- Keep changelog of spec revisions
Example change request:
Add "family mode" that favors kid-friendly POIs and shorter walking segments.
Process:- Update SPEC.md constraints- Re-run planning- Regenerate affected tasks- Adjust prompts- Extend tests for new rules- Document why trade-offs were madeHuman review is essential before accepting regenerated plans.
GitHub Spec Kit
Section titled âGitHub Spec KitâGitHubâs Spec Kit is an open-source toolkit that operationalizes SDD across multiple AI coding agents.
What it provides
Section titled âWhat it providesâ- Specify CLI: Python-based tool that bootstraps projects for SDD
- Templates: Structured formats for specs, plans, tasks, and constitution
- Slash commands: AI agent prompts for structured development workflow
- Helper scripts: Automation for maintaining SDD scaffolding
Installation
Section titled âInstallationâ# Persistent installation (recommended)uv tool install specify-cli --from git+https://github.com/github/spec-kit.git
# Initialize projectspecify init <PROJECT_NAME>
# Or in current directoryspecify init . --ai claudeSupported agents
Section titled âSupported agentsâSpec Kit works with most modern AI coding agents:
| Agent | Support |
|---|---|
| Claude Code | â |
| GitHub Copilot | â |
| Cursor | â |
| Gemini CLI | â |
| Windsurf | â |
| Kilo Code | â |
| Roo Code | â |
| Codex CLI | â |
| opencode | â |
The templates are designed to work across agents without tweaks.
Project structure
Section titled âProject structureâAfter running specify init, youâll see:
ââââ.github (or agent-specific folder)â ââââpromptsâ plan.prompt.mdâ specify.prompt.mdâ tasks.prompt.mdâââââ.specify ââââmemory â constitution.md â ââââscripts â ââââbash (or powershell) â check-task-prerequisites.sh â create-new-feature.sh â setup-plan.sh â ââââtemplates plan-template.md spec-template.md tasks-template.mdWhen SDD works
Section titled âWhen SDD worksâIdeal scenarios
Section titled âIdeal scenariosâGreenfield development (0-to-1): Starting new projects from scratch. Small upfront work ensures AI builds actual intent, not generic solutions based on common patterns.
Feature work in existing systems (N-to-N+1): The most powerful use case. Adding features to complex, existing codebases. Forces clarity on how new features interact with existing systems. New code feels native, not bolted-on.
Legacy modernization: Rebuilding legacy systems where original intent is lost to time. Capture essential business logic in a modern spec, design fresh architecture, and let AI rebuild without inherited debt.
Complex systems with many contributors: Microservice architectures, multi-repo frontends, AI-powered backends. Every boundary becomes explicit, enabling contract testing.
High-stakes features: Payment flows, healthcare diagnostics, safety-critical automation. Encode performance, security, and reliability thresholds.
Long-term projects: When a project will outlive the founding team, SDD preserves design intent as institutional memory.
When to skip it
Section titled âWhen to skip itâQuick prototypes: SDD might be overkill. Lighten the processâshort spec, simple plan, manual notes.
Design experiments: SDDâs full structure slows momentum when youâre exploring.
One-shot operations: Sometimes you need immediate results without iteration.
Simple, well-understood problems: Overhead isnât justified for trivial tasks.
Why this works
Section titled âWhy this worksâThe core problem with vague prompting is that language models are exceptional at pattern completion, not mind reading.
Vague prompt: âadd photo sharing to my appâ
This forces the model to guess at thousands of unstated requirements. It makes reasonable assumptionsâbut some will be wrong. You discover issues deep into implementation when theyâre expensive to fix.
With clear specification + technical plan + focused tasks = AI clarity
Now, instead of guessing, AI:
- Knows what to build: From specification
- Knows how to build it: From plan
- Knows sequence: From tasks
- Knows constraints: From constitution
The approach works across different stacks because the fundamental challenge is the same: translating intent into working code. Your specification captures intent clearly. Your plan translates intent to technical decisions. And tasks break the work down into implementable pieces. AI just handles the actual coding.
Common pitfalls
Section titled âCommon pitfallsâOver-specifying too early
Section titled âOver-specifying too earlyâProblem: Trying to capture every pixel before building.
Solution: Specs should evolve with insight. Aim for just-enough structure for test automation and AI generation, and iterate as you validate assumptions.
Letting specs drift
Section titled âLetting specs driftâProblem: Changes sneak into production without spec updates.
Solution: Treat the document as your changelogâs front line. Update the spec first, then merge code. This preserves traceability for audits.
No clear ownership
Section titled âNo clear ownershipâProblem: âSomeone else will fix it laterâ syndrome.
Solution: Appoint a âspec stewardâ (a role that rotates) to ensure that merge requests include spec updates. They should flag inconsistencies early.
Focusing on what instead of why
Section titled âFocusing on what instead of whyâProblem: Future teammates lack context for confident changes.
Solution: Capture rationale as well as requirements. Include business drivers (âreduce checkout time to under 2 secondsâ) and document risks mitigated (âmeet SOC 2 audit log mandatesâ).
Treating as static document
Section titled âTreating as static documentâProblem: The spec becomes an outdated artifact.
Solution: Keep your spec as living document that evolves alongside the code. Update during maintenance phase and keep a changelog of revisions.
Enterprise benefits
Section titled âEnterprise benefitsâCentralized requirements: Security policies, compliance rules, design system constraints, integration needsâthese should all live in the specification and plan, where AI can actually use them. Not in someoneâs head, buried in a wiki nobody reads, or scattered across Slack conversations.
Auditability: With a spec commit linked to every release, you have a provable chain from requirement to implementation, to satisfy auditors demanding due diligence.
Shared vocabulary: One glossary of user flows, metrics, and error states. With no dueling definitions of âsessionâ, âtenantâ, or âSLAâ, you have less friction in cross-functional work.
Accelerated onboarding: New hires skim change-tracked specs. They can see how requirements evolved and reach productive coding in days, not weeks.
Safe parallel development: With interfaces frozen in contract and mock servers generated from specification, you can surface integration issues early, before staging.
The shift in thinking
Section titled âThe shift in thinkingâTraditional development: code is the source of truth.
Spec-driven development: intent is the source of truth.
You stop asking âHow do I get the perfect prompt?â and start asking âHow do I capture intent clearly enough that AI can execute it?â
The agentâs job is translating intent into working code. Your job is making that intent explicit, reviewable, and evolvable.
Resources
Section titled âResourcesâOfficial
Section titled âOfficialâ- TRY: GitHub - github/spec-kit â Official repository (62k+ stars, MIT license)
- READ: Spec-driven development with AI - GitHub Blog â Official announcement and overview
Tutorials
Section titled âTutorialsâ- READ: Spec-Driven Development Tutorial using GitHub Spec Kit â Real-world tutorial with examples
- READ: Diving Into Spec-Driven Development With GitHub Spec Kit â Microsoft Developer Blog
Maintainers
Section titled âMaintainersâ- Den Delimarsky (@localden)
- John Lam (@jflam)
Using SDD in production? Share your experienceâwhat worked, what didnât, and what you learned along the way.