←   Spec-Driven Development

SAMPLE SESSION · MODULES 01–03

From an ambiguous request to a specification an agent can build from

A representative lecture from the first half of the course. It takes a one-line feature request, shows what a coding agent actually does with it, and rebuilds it as a specification with acceptance criteria and traceable evidence.

14 slidesAbout 45 minutes of teaching plus a 30-minute exerciseInstructor notes included

Illustrative teaching material for Spec-Driven Development. Condensed for the web; the live session includes the walkthrough, the handout and the exercise review.

Slide 1 of 14

SPEC-DRIVEN DEVELOPMENT · SESSION 03

Make intent precise.
Make delivery verifiable.

What a specification has to settle before anyone — human or agent — writes a line of code.

THE PREMISE

A model can write the implementation.
It cannot decide what correct means.

Correctness is a claim about your users, your obligations and your existing system. None of that is in the weights. It arrives only if someone puts it there.

WHERE THE HOUR GOES

The work did not disappear. It moved.

Before assisted development

  • 10 min — understand the request
  • 10 min — decide the approach
  • 35 min — write the implementation
  • 05 min — write the tests

After, done badly

  • 02 min — paste the request
  • 03 min — accept the output
  • 40 min — review, rework, re-review
  • 15 min — defect found in staging

After, done well

  • 25 min — specify behaviour and evidence
  • 05 min — bound the agent task
  • 10 min — implement and iterate
  • 05 min — verify against the spec

The third column is not slower than the second. It is the same hour, spent where it compounds instead of where it repeats.

THE PROBLEM, DRAWN

One sentence, four defensible readings

THE SAME REQUEST, TWICEPROMPT“Add registration”One sentence,many readingsNo duplicate checkDeadline ignoredPayment before validationEmail silently droppedSPECIFICATION17 stated criteriaNon-goals andfailure statesOne convergent implementationAmbiguity is not removed by abetter model. It is removed bysomeone deciding, and writingthe decision down.
Every branch on the left is an implementation a competent engineer could justify from the same request. The agent picks one and states it with total confidence.

THE MISSING DECISIONS

Four questions a prompt almost never answers

  1. 01
    What must never happen?

    Non-goals and forbidden states. Most agent over-reach is enthusiasm, not incompetence — it built the thing you did not ask it to stop building.

  2. 02
    What happens when it fails?

    Timeouts, partial writes, a payment that succeeded while the confirmation did not. Failure behaviour is behaviour.

  3. 03
    Who is allowed to do this?

    Authorisation is a requirement, not an implementation detail, and it is the one most often inferred wrongly.

  4. 04
    How will we know it worked?

    If no one can name the evidence, the requirement is a preference with good posture.

THE ARTEFACT

What a working specification contains

ANATOMY OF A WORKING SPECIFICATION01Problem & usersWho has the need, what job they are doing, how success is measured.02Scope & non-goalsWhat this slice covers — and what it must deliberately not do.03BehaviourHappy path, edge cases, failure states, given–when–then examples.04Contracts & dataEntities, validation rules, API shapes, state transitions, idempotency.05ConstraintsSecurity, privacy, authorisation, performance budgets, accessibility.06Acceptance & evidenceBinary criteria, and the test or check that settles each one.Read top to bottom, a reader should be able to build the right thing. Read bottom to top, a reviewer should be able to prove it was built.
Six layers. Not six documents — in practice this is one page for a small slice and four for a significant one.

WORKED EXAMPLE

The same feature, specified

Specification excerpt · course registration
# Slice: paid registration for a published cohort

## Problem
A learner can currently pay twice for the same cohort. Finance reconciles
the duplicates by hand, roughly four times a month.

## Non-goals
- Refunds and partial refunds (handled by finance, out of scope).
- Waiting lists for full cohorts (separate slice, not this one).
- Any change to pricing or currency conversion.

## Behaviour
B1  A learner may hold at most one paid registration per cohort.
B2  A second completed payment for a cohort the learner already holds
    MUST NOT create a second registration, and MUST be recorded for
    finance review with the original registration referenced.
B3  Registration is refused at or after the published deadline instant.
    The instant is inclusive of the final second and evaluated in UTC.
B4  A payment that fails, expires, or is disputed leaves no confirmed
    registration behind and sends no welcome message.

## Contracts
registration := { id, application_id, cohort_id, learner_email,
                  paid_at (UTC), payment_ref (unique) }
UNIQUE (cohort_id, learner_email) WHERE status = 'paid'

## Acceptance criteria
AC1 (B1) Two completed payments, same learner and cohort → exactly one
         row in registrations; second attempt recorded as duplicate.
AC2 (B3) A payment completed at deadline − 1s registers; at deadline
         + 0s is refused with a deadline-passed reason.
AC3 (B4) A failed payment webhook produces zero registrations and zero
         sent messages, asserted against the outbox.

Every line above is a decision someone had to make. The agent makes all of them either way — the only question is whether a human saw them first.

CRAFT

An acceptance criterion you cannot argue with

Not yet a criterion

  • “Registration should be reliable.”
  • “Handle duplicate payments gracefully.”
  • “The deadline should be respected.”
  • “Send the learner a confirmation.”

A criterion

  • “Two completed payments for the same learner and cohort produce exactly one registration row.”
  • “The second payment is recorded with a reference to the first and does not send a second message.”
  • “A payment completing at deadline + 0s is refused with reason deadline_passed.”
  • “Exactly one message is queued per created registration, asserted against the outbox.”

The test: could two reasonable people disagree about whether it passed? If yes, it is still a preference.

THE METHOD

The loop you will run for the rest of the course

HUMANIntentProblem, users,success measuresHUMANSpecificationBehaviour, constraints,non-goals, contractsHUMANTask packBounded slice,permitted actionsAGENTImplementationCode, tests,migration, docsHUMANVerificationEvidence traced toevery requirementChange request · impact analysis · new specification version01 → 05   EACH ARROW IS A CHECKPOINT WHERE A HUMAN CAN STOP, CORRECT OR ACCEPT
The specification is upstream of the agent and downstream of verification. The feedback arc is what stops it becoming waterfall.

CONTEXT

This is not a replacement for the methods you already use

THE METHODS ARE LAYERS, NOT RIVALSProblem & domainDomain-Driven Design gives you the language.DDDSpecificationBehaviour, constraints, non-goals — the decision record.SDDInterface contractThe shape two sides agree on before building.CDD / API-firstExecutable examplesAcceptance criteria that a machine can run.BDD / ATDDUnit tests & typesFeedback at the smallest scale.TDD / TyDDImplementationWritten by a human, an agent, or both.AI-assistedEach layer constrains the one below it. Spec-driven development is the layer that became load-bearing once the implementation stopped being written by hand.
Spec-driven development occupies the layer that became load-bearing once implementation stopped being written by hand.

EVIDENCE

Every requirement names the evidence that settles it

REQUIREMENT → EVIDENCE · A REQUIREMENT WITH AN EMPTY ROW IS AN UNVERIFIED CLAIMPositive caseNegative caseBoundary / regressionREQ-01A learner may hold only one paid place per cohort.unit + e2esecond attemptregressionREQ-02A duplicate payment never creates a second registration.integrationreplayed eventregressionREQ-03Registration closes exactly at the published deadline instant.integrationafter deadlinedeadline ± 1sREQ-04A failed payment must leave no confirmed enrolment behind.integrationfailed webhookREQ-04 has no boundary evidence. In a spec-driven review that is a blocking finding, not a nice-to-have.
The matrix is boring and it is the artefact that survives review, handover and audit. An empty cell is a finding.

BEFORE YOU DELEGATE

The pre-delegation checklist

Run this before any task pack goes to an agent. It takes four minutes and removes most of the rework.

  • The slice is small enough that a wrong answer is cheap to discard.
  • Non-goals are written down, not assumed.
  • Every acceptance criterion is binary and observable.
  • Failure behaviour is specified, not left to the implementation.
  • Data contracts and validation rules are stated.
  • Permitted actions are explicit — what may be created, changed, deleted.
  • The definition of done names the evidence, not the effort.
  • A review checkpoint exists before anything irreversible happens.

THE HONEST CAVEAT

Specifying is a cost.
Spend it where correctness is contested.

A throwaway prototype does not need a specification. A payment path does. Judgment about which is which is part of the skill, and this course grades it.

YOUR TURN

The exercise

Take the ambiguous request in your handout. Produce a one-page specification with non-goals, four behaviours, one data contract, and an acceptance criterion for each. Then hand it to an agent and see what you forgot.

  • 30 minutes to write
  • 10 minutes with the agent
  • 10 minutes reviewing a neighbour’s spec against their result

Use the arrow keys to move through the deck. Press N for instructor notes, A to read every slide on one page.

THIS IS ONE SESSION OF 7

The full course goes
considerably deeper.

7 modules, three applied assignments, a capstone and a final exam. Starts 28 September 2026.