Spec-Driven Development
Goal
Invert the usual order: write the specification first, make it concrete and testable, and
treat it as the single source of truth that the implementation must satisfy and the tests must
verify against. In a spec-driven (Spec Kit-style) workflow the spec is not prose that rots in a
wiki — it is an executable contract. Work flows spec → acceptance criteria → tasks →
implementation, mapping onto the project phases S01 (Requirements) → S02 (Design) → S03
(Specification) → S04 (Tasks) before S05 (Implementation). The deliverable is a spec-driven
workflow plan: the spec, the acceptance criteria derived from it, the task decomposition, and
the verification linkage that keeps code, tests, and spec in agreement.
Steps
- Capture requirements as the spec's intent (S01). Before writing the spec, pin down what
and why — the user need, scope, and non-goals — separate from how. This anchors the spec
so it specifies behavior, not a premature implementation. Record explicit out-of-scope items
so the spec can't quietly expand.
- Resolve design constraints (S02). Settle the architectural decisions and constraints the
spec must respect (interfaces, quality attributes, tech constraints) via
arch-design.skill,
so the specification is grounded in a feasible design rather than wishful behavior.
- Write the executable/testable specification (S03). Make the spec verifiable: every
requirement stated so a test can pass or fail against it. Prefer concrete, observable behavior
(inputs, outputs, error cases, edge cases, invariants) over adjectives. Where possible express
it in an executable form — given/when/then scenarios, contract/schema definitions, or runnable
examples — so the spec itself can be checked, not just read. This spec is now the single source
of truth.
- Derive acceptance criteria from the spec. Turn each spec requirement into explicit,
binary acceptance criteria ("given X, when Y, the system returns Z"; "rejects W with error E").
Acceptance criteria are the bridge between the spec and the tests — each criterion becomes one
or more verifications. No criterion may introduce behavior absent from the spec; if it must,
the spec is amended first.
- Decompose into tasks (S04). Break the spec + acceptance criteria into atomic, independently
verifiable tasks (small units, each traceable to specific criteria). Every task carries a link
back to the spec section and acceptance criteria it fulfills, so the traceability is explicit
and gaps are visible.
- Implement against the spec (S05). Write code and tests to satisfy the acceptance criteria.
Tests verify against the spec — they assert the specified behavior, so a passing suite means
"matches the spec," and a spec change forces a test change. Pair with
tdd-cycle.skill to write
the criterion's test before its code.
- Keep the spec authoritative. When reality diverges (a missed case, a changed requirement,
an impossible criterion), update the spec first, then propagate to acceptance criteria,
tasks, tests, and code. Code that drifts from the spec is a defect in one of the two — never
let undocumented behavior accumulate. Maintain the spec→criteria→task→test traceability as the
record that the system does what it claims.
Constraints
- The spec is the single source of truth. When code and spec disagree, one of them is wrong;
resolve by amending the spec deliberately, never by silently letting code define behavior.
- A spec is only useful if it is testable. Requirements that cannot be turned into a
pass/fail criterion are aspirations, not spec — rewrite them as observable behavior or remove
them.
- Tests verify against the spec, so a green suite means "conforms to the current spec," not
"is correct" — the spec itself can be wrong or incomplete. State this honestly; spec-driven
development moves correctness questions up to spec review, it does not eliminate them.
- Every acceptance criterion and task MUST trace to a spec section; untraced work is either
gold-plating or a spec gap. Surface both rather than absorbing them.
- Changes flow spec → criteria → tasks → tests → code, never the reverse. A code change that
alters behavior without a spec update is an undocumented divergence to flag.
Output Format
Produce a spec-driven workflow plan containing:
- The specification: requirements and non-goals (S01), respected design constraints (S02), and
the executable/testable behavior statements (S03) — inputs, outputs, error and edge cases,
invariants.
- The acceptance criteria derived from each spec requirement, each binary and observable.
- The task decomposition (S04), each task linked to its spec section and acceptance criteria.
- The verification linkage: which test verifies which criterion, and the spec→criteria→task→test
traceability map.
- An honesty note: tests confirm conformance to the spec, not absolute correctness; the spec must
be reviewed on its own merits. Cross-reference
tdd-cycle.skill for the test-first inner loop
and arch-design.skill for the design phase.
Limits and safety
- Change the spec explicitly and show the change to the human; never edit the spec only to make a failing test pass.
- Security, authorisation, data-handling and compliance requirements are spec items with their own acceptance criteria and tests.
- Code or an endpoint that maps to no spec section is a divergence: list it in the traceability map.
- Every criterion and task traces to a spec section; mark requirements you proposed as unconfirmed until the human confirms them.
- Derive tests from the acceptance criteria, not from the code, and make each one fail once; a green suite means "conforms to the spec", not "correct".