How Claude Code worksPart 7
Specs as the source of truth
On this page
In short: A builder works from the drawings, not from what someone said on site last Tuesday. In spec-driven development, a short written spec says what to build and how you will know it works, using acceptance criteria with IDs. Claude plans from the spec, you approve the plan, and every task points back to a criterion. The chat is where you talk; the spec is where decisions live.
Part 6 kept the desk clear. This part puts one page in the middle of it. The project in the examples, the Acme storefront, is made up.
Why a chat message is not enough
Think of it like this: “Add a porch” leaves the builder to guess the size, the material and where the door goes. The drawings answer all of it before anyone picks up a hammer.
Ask Claude to “add gift cards” and it will fill every gap with a guess. Some guesses will be good. You will find the rest in review, after the code is written. A spec moves those decisions to the start, when they are cheap to change.
The loop
Spec-driven development breaks the work into steps, each producing a file. The files are what carry the work from one session to the next.
- 1 · Principles (once per project)
The house rules every feature follows: tests first, money in cents, no new dependency without a reason.
memory/constitution.md or CLAUDE.md
- 2 · Spec: what and why
What the user can do, and how you will know it works. No code, no tech choices. Each acceptance criterion gets an ID.
specs/012-gift-cards/spec.md
- 3 · Clarify
Claude lists what the spec leaves open and asks. You answer in the spec, not in the chat.
- 4 · Plan: how
Files, data, the API change, the risks. You read it and approve before any code.
specs/012-gift-cards/plan.md
- 5 · Tasks
Small steps, each pointing at the criteria it satisfies. Each one testable on its own.
specs/012-gift-cards/tasks.md
- 6 · Build, one task at a time
Test first, then code, then tick the task. The spec is the yardstick, Part 9 shows how to check it.
Credit: this loop follows the spec-driven approach taught by Panaversity in Spec-Kit Plus, which builds on GitHub’s open source Spec Kit. Spec-Kit Plus adds commands for each step (/constitution, /specify, /plan, /tasks, /implement), records of the prompts used, and decision records you write with /adr. You can use it as it is, or build the same steps with your own skills as shown below.
What a spec looks like
Short, plain and testable. No code and no technology choices: those belong in the plan.
# Gift cards at checkout ## Why Shoppers ask to pay with a gift card. Today support applies them by hand. ## What the shopper can do - Enter a gift card code at checkout and see the new total. - Pay the rest by card if the gift card does not cover it. ## Acceptance criteria - AC-1 A valid code reduces the total by the card balance, up to the total. - AC-2 An unknown or used-up code shows "This card can't be used" and changes nothing. - AC-3 Only one gift card per order. - AC-4 The balance left on the card is shown after the order. - AC-5 Amounts are integer cents end to end. ## Out of scope - Buying gift cards. Partial refunds to a gift card. ## Open questions - Q1 Do gift cards combine with coupons? (answer: yes, coupon first)
- Why in one or two sentences.
- Acceptance criteria with IDs, each one testable.
- Out of scope, so nothing extra is built.
- Open questions, answered in the file.
- How to build it, before what to build.
- "Should be fast" or "nice UX": nothing you can test.
- No IDs, so tasks and tests cannot point back.
- Decisions that only live in a chat.
Under the hood: why IDs matter
- Tasks point at IDs. “T3: block a second gift card (AC-3)”. A task with no ID is outside the spec.
- Tests point at IDs. A test named
AC-3 rejects a second gift cardshows which promise it checks. - Reviews point at IDs. A reviewer subagent (Part 3) can go through the list and report each criterion as met, not met or not tested. Part 9 builds that.
- Coverage is visible. If AC-4 has no task and no test, you can see the gap before shipping.
The Acme storefront, step by step
Here the steps are built from pieces you already have: a skill (Part 3), the tracker line (Part 4) and plan mode (Part 5).
- 1 · A skill that writes specs
A recipe card (Part 3) so every spec has the same shape.
.claude/skills/write-spec/SKILL.md --- name: write-spec description: Draft a feature spec with numbered acceptance criteria. Use when starting any new feature. --- 1. Read the ticket and CLAUDE.md principles. 2. Write specs/NNN-name/spec.md: Why, What, Acceptance criteria (AC-1...), Out of scope, Open questions. 3. No code and no tech choices in the spec.
- 2 · Draft from the ticket
The ticket comes in through the phone line from Part 4.
> Read ACME-160 and write the spec with /write-spec. Ask me the open questions before you finish.
- 3 · Answer the questions in the file
The answer goes into the spec, where the next session will find it.
- 4 · Plan in plan mode
Part 5's plan mode: Claude reads the code and proposes. Nothing changes until you approve.
> Plan specs/012-gift-cards. Map every task to the AC IDs.
- 5 · Tasks that point back
Each task names the criteria it serves, so nothing is built that the spec did not ask for.
T1 Validate code against the gift card API AC-1, AC-2 T2 Apply balance after coupons, in cents AC-1, AC-5 T3 Block a second gift card AC-3 T4 Show remaining balance on the receipt AC-4
- 6 · Build task by task
One task, test first, then the next. Part 8 keeps the data honest, Part 9 proves each AC.
Rule: plan in plan mode and approve before code. This is the same “plan first, then wait for approval” rule many teams already put in their CLAUDE.md.
Where this fits in the bigger picture
Think of it like this: A colleague who works from the drawings can be handed a new job without you standing over them. That is the point of this whole series.
Parts 1 to 6 set up where Claude works, what it remembers, how it behaves, what it can reach, what it may do and how it stays focused. From here, the spec is the centre:
- Part 8 keeps the data honest: Claude may use only fields the contract defines.
- Part 9 proves the work: each acceptance criterion gets evidence.
- Part 10 carries the spec and decisions across sessions.
Which one fits?
- It is a new feature: Write a spec firstWhy, acceptance criteria with IDs, out of scope. Then plan, then tasks.
- It is a one-line fix: Just do itA typo or a colour change needs no spec. A clear request and a test are enough.
- The request is vague: Clarify in the specAsk Claude to list the open questions, and write the answers into the file.
- We keep making the same choice: Put it in the principlesA rule every feature follows goes into the constitution or CLAUDE.md, once.
- I want a ready-made toolkit: Spec-Kit Plus or Spec KitCommands for each step, templates, and records of prompts and decisions. Or build your own with a skill, as above.
Your setup so far
- Part 1 · where it worksYou know which machine does what, and which folders Claude can reach.
- Part 2 · what it remembersOne task per notebook; photocopies in their own folder; helpers for noisy side jobs.
- Part 3 · how it behavesFridge rules for what is always true, recipe cards for procedures, alarms for musts, specialists for checks.
- Part 4 · what it can reachPhone lines to your tracker and tools, checked before trusted; your setup packed as one toolbox.
- Part 5 · what it may doKeys for routine work, a knock for anything that publishes, locked doors for secrets.
- Part 6 · how it stays sharpA clear desk: fresh sessions, focused summaries, helpers for big reads, rules only where they apply.
- Part 7 · what it builds fromA written spec with acceptance criteria, rules with IDs, and a plan agreed before code.
- NextPart 8 · contract first
Three rules of thumb
The spec says what and why. The plan says how. Do not mix them.
If a decision is only in the chat, the next session will not know it.
If a task serves no criterion, it is not in scope. If a criterion has no task, the plan has a gap.
QuizHalfway through building, you and Claude agree in chat that gift cards apply after coupons. Where should that decision go?
Show the answer
Answer: Into the spec, as an answered question or a criterion
The chat ends with the session. The spec is what the next session, the reviewer and the tests read. If it is not in the file, it did not happen.
Words in this post:
- Spec: a short document saying what to build and why, with acceptance criteria.
- Acceptance criterion (AC): one testable statement of what “done” means, with an ID.
- Plan: how the spec will be built: files, data, risks. Approved before code.
- Constitution: the principles every feature in the project follows.
- Spec-driven development: working from the written spec, not from the chat.
Spec-Kit Plus details were checked against its documentation in November 2026. Tools change, so the docs are the final word for your version.
Next, Part 8: Contract first stops Claude from inventing fields that the system does not have.
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
How Claude Code works
- How Claude Code worksWhere Claude runs
- How Claude Code worksSessions and forks
- How Claude Code worksSkills, hooks and subagents
- How Claude Code worksMCP servers and plugins
- How Claude Code worksPermissions and safety
- How Claude Code worksContext and cost
- How Claude Code worksSpecs as the source of truthyou are here
- How Claude Code worksContract first
- How Claude Code worksVerify against the spec
- How Claude Code worksHandoffs and memory
- How Claude Code worksYour setup as a kit
- How Claude Code worksRolling it out