Turn an informal, partly ambiguous feature request into a specification with numbered requirements, testable acceptance criteria and an ordered implementation plan.
Outcome: Define requirements, acceptance criteria and an implementation plan.
Note
Reading as a visitor
Everything in this lesson is free to read. Sign in and enrol to answer the questions and record your progress.
Find the ambiguities in an informal request and resolve each one as a recorded decision, an open question or a scope exclusion.
Write requirements that each state one observable behaviour and can be referred to by a stable id.
Write acceptance criteria as concrete Given/When/Then statements linked to the requirements they verify.
Order an implementation plan into small steps that each name the criteria they satisfy.
Use an AI coding agent to critique a specification without letting it make your decisions for you.
Prerequisites
Familiarity with the booking service's API, including cancellation (POST /bookings/:id/cancel).
Reading HTTP status codes and JSON error responses.
Writing Markdown: headings, bulleted lists and numbered lists.
Concepts
What makes a specification actionable
A specification is actionable when someone else, a colleague or a coding agent, can build from it without coming back to ask what you meant, and someone can check the result without asking you either. That takes five things: why the work matters (context), what must be true afterwards (requirements), what is deliberately left out (scope), how anyone will know it is done (acceptance criteria) and a sensible order of work (plan).
The point is not paperwork. An informal request leaves dozens of decisions open. If nobody makes them before building starts, they are still made, by whoever writes the code, one if statement at a time, and nobody finds out which way they went until a user complains. A coding agent makes these decisions faster and more quietly than a person: given an ambiguous request, it picks a plausible default and carries on.
The format used in this exercise
SPEC.md at the repository root, with five level-2 headings in any order. Extra sections, such as Open questions, are welcome.
## Context
Who asked, what problem they have, what exists today.
## Requirements
- R1: One observable behaviour per requirement.
- R2: ...
## Out of scope
- Things a reader might expect that this work will not do.
## Acceptance criteria
- C1 (R1): Given a starting state, when one action happens, then an observable result.
- C2 (R1, R2): Given ..., when ..., then ...
## Implementation plan
1. A small step that can be checked on its own (C1).
2. The next step (C2, C3).
The rules: requirements are list items that start with R1, R2 and so on, at least three; acceptance criteria start with C1, C2 and so on, at least four, each naming the requirement or requirements it verifies in parentheses and written as Given, when, then; the plan is a numbered list of at least three steps, each naming the criteria it satisfies. There are no placeholders: no , , or text in angle brackets waiting to be filled in.
Worked example
This walk-through turns a different informal request into a specification in the format the exercise uses. The feature, maintenance closures, is not part of the exercise; it is here to show the reasoning, not to be copied.
The request
From: Facilities
We need to be able to close a room for maintenance: painting, a new projector, that kind of thing. Nobody should be able to book it while it's closed, and people who already booked need to know. Closures are usually a day or two. Can we have this before the end of the month?
1. List what the request leaves open
Reading it with the booking service in mind turns up at least these questions:
Question
How it was handled
Who can create a closure? The service has users but no roles.
Decided: a new operator flag on users; operators are set in the database. Recorded as an assumption under Open questions.
How is a closure created?
Decided:POST /resources/:id/closures with starts_at, ends_at and reason, in the same instant format as bookings.
What happens to bookings already made for that time?
Concept questions
Sign in and enrol to answer and save your progress.
Exercise
The situation
Your workspace holds the booking service described in README.md, including cancellation (POST /bookings/:id/cancel). The operations lead has sent the team a request for a waitlist, in docs/waitlist-request.md. It is clear about what she wants in some places and vague or silent in others, which is normal for a request like this.
Your job is to write the specification the team will build from: SPEC.md at the root of the repository. Do not change any code. This exercise is about the decisions, not the implementation.
Steps
Understand what exists. Read README.md for the current API and booking rules, including how cancellation and refunds work, since the waitlist depends on them.
Read the request and list its open questions. Read docs/waitlist-request.md twice: once for what the operations lead wants, once for every question it leaves open. For each question, decide it, record it as an open question with the assumption you are working on, or put it out of scope. Pay particular attention to the places where she says she does not know.
Write SPEC.md in this format:
Five level-2 headings: , , , and , in any order. Extra sections such as are welcome.
Reflection
Recorded for you to look back on. It is not graded and does not by itself show understanding.
Prompt: Which ambiguity in the operations lead's request was hardest to decide, what did you decide, and why? What would you ask the operations lead to confirm before anyone builds from your specification, and what would go wrong if your assumption turned out to be wrong?
Each requirement states one behaviour that can be observed from outside the code. "A user can leave a waitlist they have joined" is a requirement. "The waitlist works well" is a wish, and "Store entries in a table" is a design decision that belongs in the plan.
Watch for words that cannot be tested: fast, fair, sensible, appropriate, user-friendly. Each one hides a decision. "Fair" might mean first come, first served by the time of joining, with no exceptions; write that. Where the request leaves a number open, choose one and say so. Use "must" and "can" consistently, and keep ids stable once others have read the spec: renumbering breaks every reference to it.
Acceptance criteria
A good criterion names a starting state (Given), exactly one action (When) and a result anyone can observe (Then), with concrete people, times and values. "Given Ada has a confirmed booking starting in 48 hours, when she cancels it, then the response is 200 and refund_cents equals price_cents" can be turned into a test without further questions.
Cover the unhappy paths as well as the main one: each error, limit and conflict a requirement implies needs a criterion, with its status and error code. Describe behaviour, not implementation. A criterion that says a particular function is called tests the code's structure, passes even if the endpoint never uses that function, and breaks on harmless refactoring.
Ambiguity is most of the work
Before writing requirements, list every question the request leaves open, then deal with each in one of three ways:
Decide it, and write the decision into a requirement, if it is within your authority and the request gives you enough to go on.
Ask, and record it under Open questions with the assumption you are working on, if only the requester can answer it.
Exclude it under Out of scope if it is real but not part of this work, so nobody assumes it is included.
Typical questions for any feature that involves time and queues: how long does something last, what happens when it expires, what happens when two events coincide, what limits apply per person, how do people find out about a change, and how does it interact with existing rules such as refunds.
The implementation plan
Order the plan so each step can be built and checked before the next begins: schema first, then the behaviour that depends on it, then the behaviour that depends on that. Each step names the criteria it makes true, so you can hand an agent one step at a time and check it against named criteria when it reports back. A final "write all the tests" step is a warning sign; tests belong with the steps they verify.
Working with an agent
Agents are good at drafting structure and, when asked directly, at finding gaps. Useful prompts: "List every question this request leaves open." "For each requirement, describe two implementations that both satisfy its wording but behave differently." "Check that every requirement appears in a criterion and every criterion in a plan step." Do not let the agent make decisions that belong to you or the requester. If its draft says offers last 15 minutes, ask yourself where that number came from, and check every number before you accept it.
What the checks can and cannot tell you
The platform's checks for this lesson verify structure only. They confirm that the sections exist and are filled in, that there are no placeholders, that requirements and criteria are numbered, that each criterion has the Given/When/Then form and names an existing requirement, and that the links from requirements to criteria and from criteria to plan steps are complete. They cannot tell whether your requirements are what the operations lead needs, whether your decisions are sensible, or whether your criteria are consistent and really testable. A specification that passes every check can still be wrong. Judging that is your job, and ideally a reviewer's.
Asked facilities; they want them cancelled with a full refund, whatever the notice, because the customer did nothing wrong.
"People need to know": how? The service sends no messages.
Excluded: notification is out of scope; the response lists the cancelled bookings so facilities can contact the people affected.
Does availability show the closure?
Decided: yes, a closed period is never reported as free.
"A day or two": is there a limit?
Decided: at most 14 days, to catch typing mistakes such as the wrong year.
Can a closure be edited or removed?
Excluded: not in this version; recorded as an open question.
Each row became either a requirement, an out-of-scope item or an open question. None was left to whoever writes the code.
2. Write the requirements
Each requirement is one behaviour that can be observed through the API. Note how the cancellation rule from the existing service is explicitly overridden by R5, rather than left for an implementer to notice.
3. Write criteria for each requirement, including the refusals
For every requirement, the question is: what would a test do, and what would it see? The criteria use real resources from the seed data, concrete times and exact status and error codes. R2 gets two criteria, because "only operators" has two ways to fail (wrong user, no user).
4. Order the plan and check the links
Schema first, then the endpoint, then the effects on existing endpoints. Each step names the criteria it makes true. The final check is mechanical: every R appears in at least one criterion's parentheses, and every C in at least one plan step.
The result
# Maintenance closures
## Context
Facilities need to take resources out of service for maintenance, usually for a day or two. Today the
service has no notion of a closed period: POST /bookings checks only opening hours and overlaps with
confirmed bookings, and availability subtracts only confirmed bookings. Users have no roles.
## Requirements
- R1: An operator can close a resource for a period by sending POST /resources/:id/closures with
starts_at, ends_at and reason; the response is 201 with the closure.
- R2: Only users marked as operators can create closures. Other users get 403 NOT_AN_OPERATOR;
requests without a valid token get 401 UNAUTHENTICATED.
- R3: POST /bookings refuses any booking that overlaps a closure with 409 RESOURCE_CLOSED.
- R4: Availability never reports a closed period as free.
- R5: Creating a closure cancels every confirmed booking that overlaps it with a full refund, whatever
the notice, and the closure response lists the ids of those bookings.
- R6: A closure must end after it starts and last at most 14 days; otherwise the response is
400 INVALID_PERIOD.
## Out of scope
- Notifying affected users by email or any other channel. The response lists the cancelled bookings so
facilities can contact people themselves.
- Editing, shortening or deleting a closure.
- Recurring closures, such as every Sunday.
- An API or screen for granting the operator flag; it is set in the database.
## Acceptance criteria
- C1 (R1): Given Grace is an operator, when she closes the Table Mountain meeting room from
2027-03-01T08:00:00+02:00 to 2027-03-02T18:00:00+02:00 with reason "Projector replacement", then the
response is 201 with the closure's id, period and reason.
- C2 (R2): Given Ada is not an operator, when she sends the same request, then the response is 403
with error code NOT_AN_OPERATOR and no closure is stored.
- C3 (R2): Given no Authorization header, when anyone sends the same request, then the response is
401 UNAUTHENTICATED.
- C4 (R3): Given the closure from C1 exists, when Ada books the room for 2027-03-01 from 09:00 to
10:00 local time, then the response is 409 with error code RESOURCE_CLOSED.
- C5 (R3): Given the closure from C1 exists, when Ada books the room for 2027-03-03 from 09:00 to
10:00 local time, then the response is 201.
- C6 (R4): Given the closure from C1 exists and the room has no bookings, when anyone asks for its
availability from 2027-03-01T00:00:00Z to 2027-03-04T00:00:00Z, then no free window overlaps the closure.
- C7 (R5): Given Ada has a confirmed one-hour booking on 2027-03-01 that cost 30000 cents, when Grace
creates the closure from C1, then Ada's booking has status CANCELLED and refund_cents 30000, and its
id is in the closure response's cancelled_booking_ids.
- C8 (R6): Given Grace is an operator, when she requests a closure lasting 15 days, or one whose end is
not after its start, then the response is 400 with error code INVALID_PERIOD.
## Implementation plan
1. Add a new migration with users.is_operator (default false) and a closures table: resource_id,
starts_at, ends_at, reason, created_by (C1, C2).
2. Add POST /resources/:id/closures with validation, the operator check and the insert, in a transaction
that locks the resource row (C1, C2, C3, C8).
3. In the same transaction, cancel overlapping confirmed bookings with a full refund and return their
ids (C7).
4. In POST /bookings, after locking the resource row, refuse periods that overlap a closure (C4, C5).
5. In availability, treat closures as busy periods alongside bookings, still sorted by start (C6).
## Open questions
- Who should be operators? Assumed: the facilities team, set by hand in the database.
- Should closures ever be removable early, for example when work finishes ahead of schedule? Assumed
not for now; a closure that ends early leaves the resource closed until the recorded end.
What to notice
The Context says what exists today, so a reader can see what changes.
R5 states a rule that contradicts an existing one (late cancellations normally refund nothing) and says so plainly.
Every refusal has a status and an error code, and the codes are new where the meaning is new (RESOURCE_CLOSED rather than reusing SLOT_UNAVAILABLE).
C4 and C5 test both sides of the closure; one criterion alone would pass for a service that refuses everything.
The plan's steps are each small enough to hand to an agent and check against the criteria named in parentheses.
Passing the structural checks would show only that this document has the right shape. Whether a 14-day limit is right, or whether facilities really wanted bookings cancelled, is a question for a person.
## Context
## Requirements
## Out of scope
## Acceptance criteria
## Implementation plan
## Open questions
Requirements as list items starting with an id, at least three: - R1: A user can join the waitlist for ….
Acceptance criteria as list items starting with an id, at least four, each naming the requirement or requirements it verifies in parentheses and written as Given, when, then: - C1 (R1): Given a slot is fully booked, when Ada joins its waitlist, then ….
The implementation plan as an ordered list (1., 2., …) of at least three steps, each naming the criteria it satisfies: 1. Add a waitlist_entries table in a new migration (C1, C2).
No placeholders: no TODO, TBD, lorem, ??? or text in angle brackets waiting to be filled in.
The examples above show the format only; your requirements, criteria and plan will differ.
Check it yourself. Every requirement appears in at least one criterion's parentheses. Every criterion appears in at least one plan step. Every error, limit and conflict you introduced has a criterion with a status code. Read each criterion and ask: could someone write a test from this without asking me anything?
Get a critical reading. Ask an agent, or a colleague, to find requirements that could be implemented in two incompatible ways, and to point out anything in the request your spec does not address. Fix what they find, but make the decisions yourself.
Constraints
Put the specification in SPEC.md at the repository root, not under docs/.
Leave the code, tests, package.json and package-lock.json unchanged. The service is not started or tested in this exercise.
Write it in Markdown that renders as plain headings and lists; keep code blocks for anything you want ignored, because the checks do not read inside fenced code blocks.
What Check work assesses
Check work takes a snapshot of your workspace and reads SPEC.md. All five criteria are structural checks: they confirm the required sections are present and filled in, that there are no placeholders, that requirements and criteria are numbered, that each criterion has the Given/When/Then form and names an existing requirement, that every requirement is covered by a criterion, and that the plan is ordered and covers every criterion.
These checks prove the document has the agreed shape. They do not prove the specification is correct. They cannot tell whether your requirements capture what the operations lead asked for, whether your decisions are sound, or whether your criteria could really be tested. A specification can pass every check and still be wrong; judging that is up to you and the people who will read it. Your reflection is recorded but not graded.
Tools
You can do this exercise with Claude Code, OpenCode or OpenHands in the lab. An agent can draft structure, find gaps and check the links between ids. It should not choose your answers to the open questions: if a number or rule appears in its draft that you did not decide, find out where it came from before you keep it.
Acceptance criteria
AC1SPEC.md has every required section and no placeholdersStructure check
AC2Requirements are numbered R1, R2, … (at least three)Structure check
AC3Acceptance criteria are numbered, testable Given/When/Then statements linked to requirements (at least four)Structure check
AC4Every requirement is covered by at least one acceptance criterionStructure check
AC5The implementation plan is ordered and covers every acceptance criterionStructure check
Verified behaviour is checked by running your submitted work from outside the lab. A structure check confirms that something is present and in the expected format; it does not prove it is correct.
Not assessed
Whether your requirements capture what the operations lead asked for, and whether your decisions on the ambiguous points are sound.
Whether your acceptance criteria are actually testable, consistent with each other and with the existing API.
Whether the implementation plan is feasible and sensibly ordered, beyond being numbered and linked.
The quality of the writing in Context, Out of scope and any other sections, beyond their presence.
Your reflection: it is recorded, not graded.
Hints
Try the exercise first. Each hint gives away a little more than the one before.
Check your work
Submit your work from the lab's Check work panel. Hidden checks run your submitted code from outside the lab; your own test output is never taken as a result. You can revise and resubmit.
GitHub's open source toolkit that gives AI coding agents structured processes, starting with spec-driven development from specification to plan, tasks and code.