Spec-Driven Development
A self-maintaining docs/ catalog the AI must read before touching code and update after shipping. The catalog owns what & why; code owns how.
READ β before coding
SYNC β after shipping
BOOTSTRAP β run once
The whole idea in one picture
Problem
Without a reference the AI trusts, long-running projects hit these four failures. Each one is blocked by a specific part of the catalog.
Session #12 doesn't remember session #3 β so it writes a second, slightly different version.
Blocked by READ β "Already exists?"A refactor drops a capability nobody intended to remove β noticed weeks later.
Blocked by specs + changelogChanges behavior without knowing what callers depend on ("improves" a 404 into a 200).
Blocked by Invariants in each specBuilds something that violates project principles or was never planned.
Blocked by constitution + roadmap gatesOperation Β· interactive
βΈ Click a situation to see which mode fires:
No mode picker, no flags β the skill infers the mode from what's on disk and what you just said.
CLAUDE.mdoverview β constitution β roadmap β spec + check the record foldersMechanism Β· interactive
βΈ Click any layer in the diagram to see what it does:
principles gate plans β mission gates roadmap β roadmap gates specs β specs gate code.
Live demo Β· interactive
A real session, step by step. You ask for something that already exists β see how the catalog catches it before a single line is written.
| Situation | Response |
|---|---|
| Feature already exists | STOP. "Already exists at <path>. Modify it, or is this genuinely different?" |
| Breaks a documented invariant | "Breaks invariant X. Confirm (goes in the changelog) or rethink?" |
| Violates the constitution | "Conflicts with <principle>. Update the constitution first, or change approach." |
| Not on the roadmap | STOP. Add a roadmap entry (Now/Next) first β unless you explicitly override. |
| Spec points to a missing file | "Spec X references a missing file β sync first?" Never silently self-corrects. |
Structure Β· interactive
βΈ Click any file in the tree to preview its exact format:
Heart of the catalog
One spec-<feature>.md per feature: header + 3 sections (+ optional Notes). Goal: someone who has never seen the code understands why it exists and which contracts must not break.
### Feature: jwt-authentication - Status: active Roadmap: shipped - Last verified: 2026-04-30 @ a1b2c3d ## Plan # why + approach JWT chosen over sessions β constitution requires a stateless API tier. Non-goal: SSO. ## Requirement - Surface: POST /api/auth/login Β· /refresh - Invariants: - Wrong password β 401 empty body - Email comparison is case-insensitive - WHEN /refresh with a valid token THEN the old token is revoked AND a new token is issued in the same transaction ## Validation # verifiable by reading alone - Given wrong password β 401 empty body. - Given refresh token reused β 401. ## Notes # gotchas code doesn't document Do not cache decoded JWTs β revocation requires a DB lookup on every request.
Invariants = only what a caller can observe without reading source. This is the #1 thing people get wrong β try it:
SYNC mode
SYNC reads the diff (never the whole repo), classifies each change, and shows you the catalog diff before writing anything.
| Change type | Catalog action |
|---|---|
| New feature | Create spec-<name>.md + remove from roadmap + add to overview |
| Feature update | Update spec; Requirements changed β changelog entry |
| Remove feature | Status: removed + changelog ### Removed |
| Rename feature | Rename spec file + roadmap + changelog ### Renamed |
| Internal refactor | Update Source files if files moved β don't touch overview/roadmap, unless it embodies a cross-cutting decision β decision record (can touch overview via its first-entry link) |
| Tech stack change | Surface to you β constitution + changelog only after you confirm |
# changed files + commit hash + today's date bash scripts/sync_helpers.sh diff # pre-formatted "Last verified" line for a spec bash scripts/sync_helpers.sh stamp # find specs pointing to missing files bash scripts/sync_helpers.sh stale
Hard rule
Every change β feature, refactor, and bug fix β gets a one-line roadmap.md entry before code is written. It exists to stop the AI from rationalizing "too small to record" β untracked small changes are exactly how the roadmap drifts and the gates decay. It is not a way to overrule you: you own the project.
Discipline
An AI-maintained catalog is only trustworthy if it refuses to fill in blanks. These are the red flags the skill self-enforces.
_TBD:_ is fine, fabrication is not.jwt-authentication, email-search) Β· flat namespace Β· no abstract names (util, core) Β· no bare nouns (user β user-creation).Where it fits
source-of-truth is a catalog, not a workflow engine. The methodology produces the work; the catalog keeps the source of truth honest across sessions.
READs the catalog before coding and SYNCs after shipping.