# Spec-Driven Development
<!--
ref: @knowledge/frameworks/spec-driven-development
type: framework
version: 3
updated_at: 2026-07-14T21:18:42.162Z
-->

> Write the spec before writing the code. AI coding tools produce dramatically better output when given structured specifications rather than ad-hoc prompts.

## The Problem

Without specs:
- AI guesses at requirements, producing wrong solutions
- Features get lost between sessions (no persistent context)
- Ambiguities multiply as complexity grows
- "Vibe coding" produces unreliable, unmaintainable results

## The Framework

### 1. Product Requirements Document (PRD)
- Core problem statement
- User personas and stories
- Feature prioritization (P0/P1/P2)
- Constraints and non-negotiables

### 2. Data Model & API Contract
- Database schema upfront
- API endpoints and contracts
- Integration points defined early
- Resolve ambiguities BEFORE coding starts

### 3. Design System
- Visual language documented
- Component library defined
- Responsive breakpoints
- Brand guidelines included

### 4. Implementation Plan
- Ordered task list from spec
- Clear acceptance criteria per task
- Dependencies mapped
- AI receives structured, unambiguous instructions

## P0/P1/P2 Prioritization

| Priority | Rule | Example |
|----------|------|---------|
| P0 | Must have for MVP | User auth, core data model |
| P1 | Important but not blocking | Search, filtering, notifications |
| P2 | Nice to have | Dark mode, export, analytics |

**Be ruthless** — most features are P2. Ship P0, iterate.

## Tools

- **SpecKit** (GitHub) — structured spec templates
- **CLAUDE.md** — project context file
- **Gemini.markdown** — living document for Gemini CLI
- **Checkpointing** — save code state at milestones

## Key Principle

> "Resolve ambiguities upfront. Develop clear data model and API contract BEFORE coding." — Sean Kochel

Specs are not documentation — they are **instructions for the AI**.

## Appendix

### A. Related Concepts
- Self-Documenting Code — prevent feature loss
- Structured Context — 90% of AI failures = bad context
- [Design-First Development](/@knowledge/frameworks/design-first-development) — UX before code

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*