Spec-Driven Development
A self-maintaining docs/ directory as the project's source of truth: the AI reads first before editing code, syncs after a feature ships. The catalog owns what & why; code owns how.
READ → before coding
SYNC → after shipping
BOOTSTRAP → run once
Problem
These are the four recurring failures the skill was built to prevent. If you've never hit any of them, you probably don't need it yet.
| Failure | Description | How the catalog blocks it |
|---|---|---|
| Rebuilding what already exists | Reimplementing a feature that already exists elsewhere. | READ checks "Already exists?" before writing code. |
| Silently removing a feature | A refactor drops a capability that no one intended to remove. | Specs document live features and their invariants. |
| Breaking an invariant | Changing behavior without knowing the contract callers depend on. | The Invariants section in each spec. |
| Drifting off-track | Building something that violates project principles or isn't on the roadmap. | Gate chain: constitution → roadmap → spec. |
Operation
The skill looks at whether a catalog exists, whether you're about to edit code, or whether you just shipped — then runs the appropriate mode.
CLAUDE.mdoverview → constitution → roadmap → specMechanism
No layer can be crossed before the one above permits it. Read top-down to understand why a line of code exists; read bottom-up to understand how far a change can propagate.
principles gate plans → mission gates roadmap → roadmap gates specs → specs gate code.
Structure
docs/Five project-level files plus one spec per feature. All markdown — human-readable, greppable, and easy to load into AI context.
docs/ ├─ overview.md # index — points to everything ├─ constitution.md # principles & tech stack ├─ mission.md # why the project exists ├─ roadmap.md # Now / Next / Later ├─ CHANGELOG.md # removals / renames / contract changes └─ specs/ └─ spec-<feature>.md # Plan + Requirement + Validation
Invariants is the most important field.Heart of the catalog
One spec-<feature>.md per feature: header metadata + 3 main sections (+ optional Notes). Goal: someone (or an AI) who hasn't seen the code can still understand why it exists and which contracts must not be broken.
### 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, no test run needed - Given wrong password → 401 empty body. - Given refresh token used a second time → 401. ## Notes # gotchas the code doesn't document itself Do not cache decoded JWTs — revocation requires a DB lookup on every request.
Invariants describe only externally observable behavior — what a caller can verify without reading source code. Implementation details belong in Notes.
| Is an Invariant | Is an implementation detail |
|---|---|
| HTTP status, response shape | Library choices (bcrypt, Redis) |
| Ordering & idempotency | Class/function structure |
| Input validation rules | Caching/retry strategy |
| Caller-visible side effects | Micro-optimization |
READ mode
The Catalog check is not internal reasoning — it's printed so you can override. Any of the situations below causes the skill to stop and ask rather than proceed.
Constitution: <relevant principles / "no conflict"> Roadmap status: Now|Next|Later|NOT TRACKED Related features: <list / "none"> Invariants: <contracts to preserve> Acceptance: <acceptance criteria still required to pass> Already exists? <yes + feature / no> Plan: <what will be done & why it doesn't conflict>
| Situation | Response |
|---|---|
| Feature already exists | STOP. "Already exists at <path>. Modify it, or is this genuinely different?" |
| Breaking a documented invariant | "Breaks invariant X. Confirm (record in CHANGELOG) or reconsider?" |
| Violates the constitution | "Conflicts with <principle>. Update the constitution first, or change your approach." |
| Not tracked on the roadmap | STOP. Add a roadmap entry (Now/Next) first — unless you explicitly override. |
| Spec references a missing file | "Spec X references a missing file — sync first?" Does not silently self-correct. |
SYNC mode
After shipping, the skill reads the diff (not the entire repo), classifies each change, updates the right files, and always shows you the catalog diff for review before writing.
| Change type | Catalog action |
|---|---|
| New feature | Create spec-<name>.md + remove from roadmap when shipped + add to overview |
| Feature update | Update spec; if Requirements change → record in CHANGELOG |
| Remove feature | Status: removed + roadmap + CHANGELOG ### Removed |
| Rename feature | Rename spec file + roadmap + CHANGELOG ### Renamed |
| Internal refactor | Only update Source files if files move — do not touch overview/roadmap |
| Tech stack change | Surface to you → update constitution + CHANGELOG only after you confirm |
# changed files + commit hash + today's date bash scripts/sync_helpers.sh diff # pre-formatted "Last verified" line ready to paste into 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 an entry in roadmap.md before any code is written. The rule exists to prevent the AI from rationalizing "too small to record" — because it's precisely those small, untracked changes that cause the roadmap to drift from reality and the gates to decay. It is not here to override 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 nested directories · avoid abstract names (util, core, manager) · avoid bare nouns (user → user-creation).Where it fits
source-of-truth is a catalog skill, not a workflow engine — it sits alongside a development methodology rather than replacing one. The methodology produces the work; the catalog keeps the source of truth honest across sessions. Pairing it with one of these is a great fit.
READs the catalog before coding and SYNCs it after shipping.