Spec-driven development, for real
Spec-driven development, for realPart 1
The building blocks
On this page
In short: Spec-driven development means every fact lives in one file with an ID, and Claude is never trusted to remember it. Requirements, decisions, business words, open questions, the API’s shape and where the work stands each have a home. Hooks make Claude read that home before it acts, reviewers check against it, and CI proves it was used. This series takes the twelve building blocks one at a time, with the real files in an open framework you can install.
The series How Claude Code works explained the tools. This one shows a whole working system built from them, the way a real team runs it. The team, the product and every name in it are invented.
Meet the team
Maya joins Acme Rentals on a Monday. Acme builds software for equipment rental companies: each company rents out ladders, drills and generators, and each is a separate tenant with its own data. There is a Django API and a React web app. Most of the code is written with Claude.
Her first ticket is ACME-41: charge a fee when a rental comes back late. It sounds like an afternoon. By Friday it will have touched almost every block on the map below, and nothing about it will have been guessed.
Think of it like this: A good restaurant kitchen does not run on the head chef’s memory. The recipes are written, the suppliers’ deliveries are checked against the order, the allergy rules are on the wall, and the shift notes say what to prep first. Any cook can walk in and produce the same dish. This series builds that kitchen for a codebase.
Vocabulary
The series uses a few short codes. Here they all are, in plain words, with an example from Maya’s ticket and the part that covers each one. Anywhere in the series, hover over or tap a code like REQ or ADR to see what it means.
Requirement. What a user must be able to do or see. Written in plain words, before any code.
Example REQ-041: a rental returned late is charged a fee.
Decision. A business choice, quoted in the words of the person who made it.
Example DEC-018: "Per started hour, never more than a full day."
Architecture decision record. One short file explaining a technical choice, and the options that were turned down.
Example ADR-0009: compute the late fee once, at return, and store it.
Definition. A business word written down once, by its owner, and computed by one function.
Example DEF late return: back after the due time, in the company’s time zone.
Open question. Something only someone outside engineering can answer, left open on purpose. Never guessed.
Example OQ-07: which ledger account do late fees post to? Finance decides.
Acceptance criterion. One testable line in a spec saying what "done" means. Numbered so tests can point at it.
Example AC-3: the fee never goes above the day rate.
Principles. Numbered rules for the whole codebase. Breaking one needs an ADR.
Example P11: money is exact, in whole cents, end to end.
Design spec. One file per feature: why, goals, what it will not do, and the ACs.
Example docs/specs/2026-03-05-late-fees-design.md
Build plan. The tasks that build a spec. Every task names the ACs it serves.
Example T1: compute the fee. Serves AC-2, AC-3, AC-5.
The API contract (OpenAPI). The exact shape of the data between the API and the web app, generated from the code.
Example late_fee_minor is in it; item_name is not, so the screen cannot use it.
Fact-forcing gate. A hook that blocks Claude until it states what it read, such as the exact field names.
Example The first edit to return-screen.tsx waits until Claude names ReturnRecord.
Hook. A small script Claude Code runs at a fixed moment, such as before a push. It can block or warn.
Example push-tracker-gate: no push with code unless work.md was updated.
Skill. A recipe Claude follows for a change the team makes often.
Example new-endpoint: every API endpoint built the same way.
Reviewer agent. A read-only helper with one checklist. It reports problems; it never fixes them.
Example field-security-reviewer: is any hidden field reaching the screen?
Evidence table. One row per AC in the pull request, each with proof: a test, an output or a screenshot.
Example AC-3 met: test_ac3_capped passes, and fails if the cap is removed.
Module handoff. A short file saying where the work stands. Its last line is the next step.
Example Next step: T5 in fee-panel.tsx.
Status board. One row per module: its status and next step. Read first in every session.
Example rentals: in progress. billing: blocked on OQ-07.
Work tracker. A checklist per branch of what is done and what is left. Updated on every push.
Example [x] T1 to T3 [ ] T5
Changelog. One plain line per pull request saying what changed, for readers outside the team.
Example ACME-41: a late return shows its fee at the desk.
Context drop. A dated note on what a session learned that the code cannot show: traps, dead ends, numbers.
Example docs/context/2026-03-07-late-fees.md
Remember: the codes are just labels for files. A REQ is a line in the requirements, an ADR is a file in the decisions folder, an AC is a line in a spec. The number after the code, like REQ-041, never changes, so anything can point at it.
The map
One line runs through all eleven blocks, in the order a ticket meets them, from the first requirement to the merge. Choose any station to open its note and see what it connects to.
Follow the ticket from ACME-41 to Merged. Choose any station to open its note and see what it connects to.
The paper trail
Every requirement, decision and open question gets an ID that never changes: REQ-041, DEC-018, OQ-07. Specs, tests, commits and reviews cite them, so anyone can follow a line of code back to the reason it exists.
In the kitdocs/prd/, docs/plan/ Read the post
Principles and rules
Numbered principles (P1 to P12) that bind the code, a short root CLAUDE.md, and one CLAUDE.md per module. Claude reads the closest one, so each module carries its own rules.
In the kitCLAUDE.md, principles.md Read the post
Decision records
One numbered file per decision that binds the code, with the options rejected and why. Going against a principle needs an ADR, not a judgement call in a pull request.
In the kitdocs/architecture/decisions/, skill write-adr Read the post
Definitions and questions
Business words written once by their owner, each computed by one function. Questions only someone outside engineering can answer stay open on purpose, restated where the code depends on them.
Specs and plans
Before code: a design spec with why, goals and numbered acceptance criteria, then a plan whose every task points at an AC.
In the kitdocs/specs/, docs/plans/, skill write-spec Read the post
The contract
The API’s OpenAPI schema is generated from the code, copied to the web repo, and turned into typed hooks. CI fails if either side drifts. A field that is not in the code cannot reach the screen.
In the kitexport-openapi.sh, orval.config.ts, CI drift gates Read the post
Fact-forcing gates
Hooks that make Claude state facts before it acts: which generated types it uses, which fields the role receives. Others stop it loosening a config or adding a package to make a build pass.
In the kitcontract-fact-force, config-protection, deps-allowlist Read the post
Skills and reviewers
Recipes for the common changes, so every endpoint and screen is built the same way, and read-only reviewers that check a change against one set of rules each.
In the kitskills/, agents/ Read the post
Guardrail hooks
Alarms on the moments that go wrong: a force-push to a shared branch, a pull request without a changelog line, a push without a tracker update, a rule broken in an edit.
In the kitmerge-safety-gate, changelog-gate, push-tracker-gate, edit-warnings Read the post
Proof of done
Done means every acceptance criterion has evidence. One verify command, tests named after ACs, a coverage matrix, and a person walking the real product.
In the kitskill verify-done, docs/qa/ Read the post
Memory and handoffs
A status board, a handoff per module with its next step, a running tracker, one changelog line per pull request and dated context drops. Tomorrow’s session starts where today’s stopped.
In the kitdocs/modules/, work.md, CHANGELOG.md, skill handoff Read the post
One ticket, end to end
All twelve blocks in the order a real ticket meets them, from the requirement to the merge.
In the kitall of it Read the post
Four layers
The blocks sort into four layers. Each one leans on the layer above it.
- Know what and why. Before any code: what we are building (requirements), why (decisions), the binding rules (principles, ADRs), the exact meaning of the words (definitions) and what nobody can answer yet (open questions). Then a spec for this one feature.
- Build to the contract. The backend’s API shape is generated into the frontend’s types, so both sides build to one shape. Skills make every change the same way. Gates make Claude say what it read.
- Guard the work. Hooks catch the moments that quietly go wrong: a force-push, a stale merge, a missing changelog line, a loosened config.
- Prove and remember. Evidence for every acceptance criterion, then a handoff that names the next step.
Why bother
Without the blocks, Claude is a capable newcomer working from a chat message. It fills each gap with a sensible guess: a field name, a rounding rule, which role sees the price. Most guesses are fine. The rest surface in review, after the code exists, which is the most expensive time to find them.
With the blocks, the gaps are closed before the code, and each one is closed in a file the next session will read. That is what lets you hand Claude real work, not just help.
Under the hood: where this came from
- This setup was extracted from two production repositories, a Django API and a React client, built largely with Claude Code over several months. The names and the product here are replaced with an invented example; the mechanisms are the real ones.
- The spec-first loop builds on GitHub’s open source Spec Kit and Panaversity’s Spec-Kit Plus. What this series adds is what a team needed around it: generated contracts, gates that force facts, reviewers, proof and handoffs.
- Claude Code features used throughout: hooks, skills, subagents, memory and plugins. The series How Claude Code works explains each one simply.
The real files
Every post ships the files for its block. They live in one open repository, spec-driven-kit, installable as a Claude Code plugin.
/plugin marketplace add Zeeshan138063/spec-driven-kit /plugin install spec-driven-kit@spec-driven-kit # then, in each repository /spec-driven-kit:kit-init
CLAUDE.md rules, kept under about 200 lines spec-kit.json settings for the hooks CHANGELOG.md work.md one line per PR; what is true now .gitattributes trackers merge without conflicts docs/ prd/ plan/ REQ, DEC, OQ: what and why architecture/principles.md P1 to P12 architecture/decisions/ one ADR per decision definitions/ questions/ words signed once; questions left open specs/ plans/ AC IDs, then tasks that point at them modules/STATUS.md the board, plus one handoff per module context/ runbooks/ qa/ catch-up notes, incidents, evidence .github/workflows/ CI with the contract drift gate
Important: the hooks are disciplines, not security boundaries. Each one fails open if something unexpected happens, and each has an off switch for a session. A hook that wedges a session teaches people to switch hooks off, which is worse than the risk it guards.
Where should you start?
- Claude keeps building the wrong thing: Start with specsPart 6: a spec with numbered acceptance criteria, approved before the plan.
- Claude invents API fields: Start with the contractParts 7 and 8: generate the types from OpenAPI, and gate the first edit until Claude states them.
- The same arguments keep coming back: Start with ADRsPart 4: one file per decision, with the option you rejected and why.
- Every session starts from zero: Start with handoffsPart 12: a status board and a handoff whose last line is the next step.
- Work disappears after merges: Start with the merge gatePart 10: refuse force-pushes, and check every merge for staleness and deletions.
- I want the whole thing: Read in orderPart 2 onwards, then Part 13 walks one ticket through every block.
Three rules for the whole series
Every requirement, decision, term and status has exactly one home, with an ID.
Hooks block the action until the file has been read and the facts stated. Asking "did you check?" is not enough.
Evidence per criterion, then a handoff that names the next step.
QuizMaya asks Claude whether it checked the API schema before writing a screen. Claude says yes. What does this series do instead of asking?
Show the answer
Answer: Blocks the first edit until Claude states the exact generated types and fields it is using
Asked “did you check?”, a model says yes. Made to name the types and fields, it has to read them. Part 8 builds that gate.
Words in this post:
- Spec-driven development: building from written specs and records, not from the chat.
- ID: a short permanent label like
REQ-041that other files cite. - Hook: a script Claude Code runs at a fixed moment, which can block an action.
- Contract: the exact shape of the data between the API and the client.
- Handoff: a short file saying where the work stands and what to do next.
Next, Part 2: The paper trail gives every requirement, decision and question an ID, and shows why that one habit holds everything else together.
Setting up Claude Code or AI agents for your team?
I help teams build this: agents, RAG search and Claude Code setups that hold up in production.
Series
Spec-driven development, for real
- Spec-driven development, for realThe building blocksyou are here
- Spec-driven development, for realThe paper trail
- Spec-driven development, for realPrinciples and scoped rules
- Spec-driven development, for realDecision records
- Spec-driven development, for realDefinitions and open questions
- Spec-driven development, for realFeature specs and plans
- Spec-driven development, for realThe contract
- Spec-driven development, for realGates that make Claude show its work
- Spec-driven development, for realSkills and reviewers
- Spec-driven development, for realGuardrail hooks
- Spec-driven development, for realProof of done
- Spec-driven development, for realMemory and handoffs
- Spec-driven development, for realOne ticket, end to end