From Spec-First to Spec-as-Source: The Three Tiers of AI-Driven Development
This article outlines three maturity levels of Spec-Driven Development (SDD) in AI coding—Spec-First, Spec-Anchored, and Spec-as-Source—explaining how specs evolve from one-time inputs to living contracts and ultimately to the sole source of truth, with practical guidance on adopting each level.
Why SDD Matters in the AI Coding Era
Traditional software engineering treats code as the single source of truth: requirements and design documents often drift, but code runs in production. AI coding tools (Claude Code, GitHub Copilot, Cursor, etc.) generate vast amounts of code, raising a new question: what should we actually manage? If we only prompt AI with vague requests, the agent must constantly guess business rules, constraints, and acceptance criteria.
SDD (Spec-Driven Development) addresses this by making specifications the stable, verifiable "intent carrier" that both humans and AI agents can read, version, review, and test against.
Level 1: Spec-First — Specification as One-Time Input
Core idea: write a clear spec before asking AI to generate code. Requirement → Spec → AI → Code → Test Example spec for a coupon feature:
Feature: Coupon Redemption
Input:
- User ID
- Coupon ID
Rules:
- User must be logged in
- Each user can redeem a given coupon only once
- Cannot redeem if inventory exhausted
- Cannot redeem expired coupons
Success:
- Create redemption record
- Decrement inventory
Failure:
- Return explicit error code
- No redemption record createdBenefits:
Reduces AI guesswork; the agent focuses on how to implement the spec.
Spec becomes a version-controlled artifact (e.g., spec/coupon.md) that can be read by humans, consumed by AI, reviewed in PRs, and used for test verification.
Limitation: Spec drift . After the initial implementation, the spec is often not updated when code changes. Example: three months later, business rules change (regular coupons once, new-user coupons once, member coupons monthly). Developers update code but forget to update coupon.md. Result: Spec shows old rules, code implements new rules.
GitHub Spec Kit follows this flow: Spec → Plan → Tasks → Implement. The agent writes the spec, developer reviews it, then the agent implements per spec.
Level 2: Spec-Anchored — Specification as Living Contract
Core idea: spec and code co-evolve. Every behavior change must be accompanied by a spec change.
Requirement change
↓
Update Spec
↓
Review Spec
↓
Update Code
↓
Update Tests
↓
Verify Spec / Code / Test consistencySpec becomes a contract shared by Product, Developers, QA, and AI Agents. Example contract format:
Requirement: COUPON-001
User redeems coupon:
Must:
- User logged in
- Coupon valid
- Inventory > 0
- No duplicate redemption per user
Must Not:
- Create record when inventory insufficient
- Decrement inventory on duplicate redemptionTests then prove these rules: COUPON-001 → Spec → Test → Code.
Why Level 2 is the "production sweet spot": real projects still need manual bug fixes, hotfixes, performance tuning, refactoring, DB migrations, architecture changes, and third-party integrations. Requiring all code to be generated from spec is costly. Spec-Anchored only demands that code and spec evolve together .
Critical practice: put specs in Git ( repository/specs/) so they flow through the engineering lifecycle: Spec → Git → PR → Code Review → CI → Release. OpenSpec exemplifies this: current system behavior is maintained in specs/, changes proposed via change artifacts, then archived, making spec the source of "current system state".
Level 3: Spec-as-Source — Specification as the Sole Source Code
Core idea: spec is the source; generated code is a compile-like artifact.
Spec
↓
Generator / AI
↓
Code
↓
Build
↓
ApplicationDevelopers maintain spec/, not src/. Generated files carry markers:
// GENERATED FROM SPEC
// DO NOT EDIT DIRECTLYWorkflow for changes:
Modify Spec
↓
Regenerate
↓
Code
↓
TestNot:
Modify Code
↓
Try to sync SpecIndustry practice: some tools declare targets linking specs to generated files, enforce "GENERATED FROM SPEC" headers, and use CI to detect drift between spec, code, and tests.
Paradigm shift:
Traditional: Code = Source of Truth
Spec-as-Source: Spec = Source of Truth , Code = Generated Artifact
GitHub Spec Kit states: "specifications become the primary artifact, code becomes their expression in a particular language and framework." Maintenance becomes "evolving specifications."
The Real Difference: Spec Authority, Not Tools
The three levels are not about different tools. The same tool (e.g., Spec Kit) can be used at different levels:
Team A (Level 1):
/specify → spec.md → implement → done → spec abandonedTeam B (Level 2):
Requirement → Update Spec → Plan → Implement → Test → PR Review → Spec + Code merged togetherTeam C (Level 3): Spec → Generator/Agent → Code → Test → Build with humans forbidden from editing generated code.
Essence: SDD's core is not "do I have a spec?" but "how much authority does the spec hold in the engineering process?"
What Should a Good Spec Describe?
Not a line-by-line code rewrite. A high-quality spec captures:
Intent — Why does this exist? (e.g., "Why do we need coupon redemption?")
Behavior — What should the system do? ("User redeems valid coupon → create record.")
Constraint — What are the hard rules? ("Same user cannot redeem twice.")
Boundary — What is explicitly out of scope? ("Coupon issuance does not handle payment.")
Scenario — Concrete examples (Given/When/Then).
Acceptance Criteria — When is it done? (Success, duplicate, insufficient inventory, expired.)
Modern SDD emphasizes: Spec describes What , not premature How . GitHub Spec Kit calls this "Intent-driven development."
Spec's Dual Nature in AI Coding
For humans: business intent, design decisions, boundaries.
For AI: context, constraints, acceptance criteria.
Future high-quality specs will be both Human-readable + Machine-actionable .
SDD's True Value: Shifting Focus from "How to Write Code" to "What Is Correct"
AI coding is not just "AI writes 1000 lines instead of human writing 100." The real paradigm shift: attention moves from "how to write code" to "defining what a correct system looks like."
Adoption Roadmap for Most Teams
Start at Level 1, stabilize at Level 2, experiment with Level 3 for narrow domains.
Phase 1: Write Spec → Let AI write code
Phase 2: Spec in Git → Spec + Code co-evolve → Tests verify → CI checks drift
Phase 3: For highly standardized areas → Try Spec-as-SourceLevel 1 fits: prototypes, small features, bug fixes, one-off scripts, personal projects, quick validation.
Level 2 fits: long-lived business systems, multi-person projects, microservices, API contracts, core business rules, projects with continuous AI agent development.
Level 3 fits: highly standardized systems, DSLs, schema-driven systems, CRUD generation, API/SDK generation, infrastructure config, code that can be reliably auto-generated.
Level 3's main challenge is not technical but expressive: Can the spec fully capture your business? If rules are highly complex, full of exceptions and tacit knowledge, forcing everything into spec may create new complexity.
Summary
Level 1: Spec-First — "I write a spec so this AI coding session is accurate." Spec = one-time development input.
Level 2: Spec-Anchored — "I maintain the spec so the system stays consistent long-term." Spec = contract honored by humans, AI, code, and tests. This is where most production projects should land.
Level 3: Spec-as-Source — "I no longer treat code as primary source; spec is the true source." Spec = sole human-edited source; code = regeneratable artifact.
Condensed: Level 1 = "Write spec first", Level 2 = "Maintain spec", Level 3 = "Only maintain spec."
Spec-First → Spec is pre-development input
Spec-Anchored → Spec is mid-development contract
Spec-as-Source → Spec is the system's SourceGitHub Spec Kit frames this as a "Power Inversion": spec used to serve code; SDD makes code serve spec. Tools like OpenSpec now tackle the next hard problem: how to guarantee spec, code, and tests never silently diverge when spec becomes the source of truth.
Writing a spec is easy. The real challenge: building an engineering system where specs continuously evolve, are verifiable, drive agents, constrain code, and ultimately become durable team knowledge assets.
In one sentence: SDD isn't "write requirements then write code" — it's redefining what should be the long-lived source code of software in the AI coding era.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
