specgate/docs v1.8.0

From a client brief to a spec#

A project usually starts as a brief: a page, a document, a few screenshots. This is the path from that page to requirements the gate and the harness can work with — the one the six pilot products were built on, from briefs as different as a detailed booking document and a five-line description of a credit shop.

At the end you will have a draft, a change whose requirements were written from the brief and checked against it, reviewed by a person and ready to build. Steps 1 to 3 turn the brief into that draft; step 4 is the same loop as any other change: a person approves it (specgate change approve), specgate apply delivers each requirement through the gate, then specgate archive merges the draft (ADR-0035).

You need: a project where Specgate is set up (Getting started) and the client's brief. A coding agent is optional but saves most of the writing.

Your work arrives as Jira stories with acceptance criteria rather than as a brief? Use the ticket path instead: From a Jira ticket.

The lifecycle of a requirement Three phases in order. Specify: keep the brief in the repository, draft a module as a change with specgate propose --from-brief, run the same command until the draft is Ready to review, and a person approves it at a terminal with specgate change approve; an agent cannot, and approval writes the feature files. Build: status names the next requirement, a test that names it comes first, then the code, by a person or by the harness in its own branch. Prove: specgate apply is the gate and marks the requirement Implemented only if it passes; specgate archive merges the change once every requirement in it is applied; check runs the whole gate in CI. A requirement that arrives waiting for an answer stays out of Build until the client answers; the answer changes it, so a person approves it again before it rejoins. SPECIFY BUILD PROVE 1 Brief docs/brief.md 2 Draft one module specgate propose --from-brief 3 Check: Ready to review the same command, until it passes 4 A person approves specgate change approve <id> 5 What is next specgate status 6 A test that names it // REQ-007 SCN-007a — … 7 The code by a person or the harness 8 Apply — the gate specgate apply 9 Archive — all applied specgate archive <change-id> 10 The gate, in CI specgate check Waiting for an answer apply and the harness refuse it answered → approve again (4) Nothing is built before a person approves it; nothing counts as delivered until the gate has checked it.
From the client's brief to a reviewed draft, one module at a time Seven steps. One: the brief is kept as docs/brief.md, with a front matter on top — product, surfaces, actors and modules — and a section per module. Two: specgate propose --from-brief lists the modules, where each stands and which is next. Three: propose --from-brief with a module name opens the change draft-module, with DRAFTING.md as the prompt. Four: your agent drafts it, called with --agent "claude -p", or you write it by hand: the delta and its scenarios. Five: the same command run again is the checklist, D1 to D12, each finding with its fix — D6, every value in a scenario is in the brief or written down as an assumption; D3, a scenario per actor and surface; D12, an actor can reach the ids it acts on. Findings go back to the agent, and the loop runs until the checklist says Ready to review. Six: beside the delta, the ready draft holds assumptions.md, every value the brief does not give with the requirements that use it, and questions.md, what only the client can answer and the requirement each question blocks. A requirement whose value only the client can give is marked status="Needs Clarification" and waits: apply and the harness refuse it until someone answers. Seven: a person approves the draft with specgate change approve draft-module, and the rest is applied one requirement at a time — a test that names it, then the gate, with specgate apply. 1 The brief docs/brief.md on top: product, surfaces, actors, modules — then a section per module 2 See the modules propose --from-brief lists the modules: where each stands, and which is next 3 Open one --from-brief <module> opens the change draft-<module> DRAFTING.md: its prompt 4 Your agent drafts --agent "claude -p" or you, by hand: the delta and its scenarios 5 The checklist propose --from-brief <module> again: D1–D12, each with its fix D6 every value in the brief or an assumption D3 a scenario per actor and surface D12 an actor can reach the ids it acts on 6 Beside the delta assumptions.md every value the brief does not give — prices, limits, status codes — with the requirements that use it questions.md what only the client can answer, and the requirement each question blocks Needs Clarification — it waits a value only the client can give, such as a fee: apply and the harness refuse the requirement until someone answers its question 7 A person approves the draft specgate change approve draft-<module> then the rest, one requirement at a time: a test that names it, the gate — specgate apply draft findings: fix, run it again ✔ Ready to review blocks a person reads it
The brief's modules become drafts one at a time; the checklist loops until every value is in the brief or an assumption, and only what the client must answer waits.

1. Keep the brief in the repository#

Save it as docs/brief.md, as the client wrote it. Add a front matter that names who uses the product and how, and a section per module with its rules, examples and questions. specgate propose --from-brief explains every field, specgate propose --from-brief --agent "claude -p" has your agent propose the fields and then the sections from the client's text, and specgate propose --from-brief --check checks the brief before anything is drafted. Step by step: Write the brief.

Two sections say what the modules do not. ## Why gives the problem, the objectives and a success you can measure — a Why with no number gets the warning B15_why_unmeasured. ## Quality says how well the product must work, one line per need opened with its ISO/IEC 25010 characteristic — - performance efficiency (reservas): A slot is confirmed in under 2 seconds. — and each line becomes a non-functional requirement in the draft of the module it names, or of the first module when it names none. A line no test can check stops the draft (B14_quality_unmeasured). Step by step: Quality.

A tool that edits the brief as a form — specgate-studio — reads it with specgate propose --from-brief --form --json, each field with its line, and writes it back with --form <file>: only the fields and card lists that changed are rewritten, every other byte of the file stays as it was.

markdown
---
product: Bookings for local businesses
surfaces: [api, web]
actors:
  - { name: Cliente, surfaces: [api, web] }
  - { name: Propietario, surfaces: [api, web] }
modules: [calendario, reservas, cupones]
---

# The brief, unchanged

…

## Module: reservas

Rules

- A slot is booked by one Cliente at a time.

Examples

- The one where Ana books the 10:00 slot of "Corte de pelo".

Questions

- Can a Cliente book two slots in a row?

2. Draft one module#

bash
specgate propose --from-brief            # the brief's modules: where each stands, which is next
specgate propose --from-brief reservas   # opens draft-reservas, linked to the brief

Opening a module creates the draft, a change folder kept apart from the specification until a person reviews it: change.yaml, discover.md, design.md, tasks.md, use-cases.md, the delta, and DRAFTING.md. That file holds the module's section of the brief with its values and questions, the reserved ids, a scenario to write per actor and surface from the front matter, and the formats below. It is the prompt for your agent. Tell your agent Draft the reservas module: follow docs/specs/changes/draft-reservas/DRAFTING.md, or let Specgate call it:

bash
specgate propose --from-brief reservas --agent "claude -p"

The prompt goes to the agent on standard input, or in a file when the command contains {prompt_file}. Anything the agent writes outside the draft folder is undone — a file you had changed returns to your version — and the draft is checked when the agent finishes. In Claude Code, /specgate:draft reservas does the same from inside the session.

The agent writes the delta under specs/<module>/spec.md, and two files go next to it:

  • assumptions.md — every value the brief does not give: prices, limits, button labels, status codes. A row names the requirements or scenarios that use it, one by one or as a range (REQ-004..REQ-010).
  • questions.md — what the brief cannot answer, and the requirements each question blocks. A blocked requirement carries status="Needs Clarification" in its trace; the harness and apply refuse it until someone answers, and status lists it under "Waiting for an answer" with the question that blocks it.

The same from the studio: its Brief section writes the brief as a form, and its Changes section drafts each module in the background with the agent you pick (--profile <name> in the terminal).

3. Check the draft#

Run the same command again — on a draft that exists, it is the check:

bash
specgate propose --from-brief reservas

(specgate propose --from-brief --check <change-id> runs the same checklist on any change; --check alone checks the brief itself.)

CodeAsks
D1every requirement has a scenario
D2every requirement has a kind (functional, non-functional, business-rule)
D3each actor's surfaces have a scenario of that actor — an API call and a screen. surfaces=web on a requirement narrows it (a menu has no API)
D4a non-functional requirement that promises a quantity states a number with a unit
D5a rule that cites a law, standard or contract names its source (Source: and a link)
D6every value in a scenario is in the brief, the project's specification, assumptions.md, or its own sourced obligation
D7every open question blocks a requirement, and that requirement waits ("none" says it blocks nothing); "TBD" or "se decidirá" is not an answer
D8the draft is small enough to review (25 requirements by default)
D9every scenario passes the rules the harness gate will apply (titles, Given/When/Then)
D10no requirement or scenario id another requirement already owns
D11reserved: not checked
D12an actor who acts on an id (…/{id}/…) has a scenario that lists or creates it, or an assumption says where it comes from
D13an assumption written from an answer (specgate answer) waits until its author says the requirements reflect it (--reviewed)
D14every requirement names its use case (uc=UC-NNN in its trace), one use-cases.md lists, with the requirement in its row
D15each use case the draft adds or modifies has its specification, use-cases/UC-NNN.md, whose flows name the scenarios (D15_no_spec)
D16a scenario's steps are in the project's language; a state machine the draft writes applies and holds

D6 is the one that keeps a draft honest: on a vague brief it lists almost every value, and that list is the conversation to have with the client.

D12 catches a gap every pilot found only by running the product: each scenario was right on its own, yet an operator could settle a transfer by its id with no way to see which transfers were pending.

D12 is satisfied when the same actor has one of these, in the draft or in the project's specification:

  • a GET on the collection;
  • the POST that creates the item;
  • a list nested under its parent with the same name (GET /api/eventos/{id}/sesiones for POST /api/sesiones/{id}/sala);
  • a row in assumptions.md, naming the requirement and the collection path, that says where the id comes from. Use it when the id reaches the actor outside the API (a customer reads their IBAN to the teller) or through a list under another name (an agenda).

The actor is the one the step names before the call, or else the requirement's actor. For a MODIFIED requirement, the assumptions.md rows of the archived change that first wrote it count too.

D6 also accepts a value the requirement's own obligation states under a Source: line: "24 characters" of a cited ISO norm needs no assumption row.

Answering a question#

An answered question gets an Answer column (Respuesta works too), or a line below the table such as Answer (Q1): free shipping from 50 €:

markdown
| #   | Question                         | Blocks  | Answer               | Status   |
| --- | -------------------------------- | ------- | -------------------- | -------- |
| Q1  | From what amount is it free?     | REQ-004 | From 50 €, per order | answered |
| Q2  | Should it export a backup later? | none    |                      | open     |

Then, for each requirement the question blocked:

  1. Remove status="Needs Clarification" from its specgate:trace. Nothing lifts it for you: the person who answered decides it is ready.
  2. Write the answer into its text and scenarios, and record any value the brief still does not give as a row of assumptions.md naming the requirement.
  3. Run specgate propose --from-brief <module> again until Ready to review.
  4. If the draft was already approved, the requirement is no longer what was approved: apply refuses it (approved_requirement_changed) until a person runs specgate change approve draft-<module> again.

An answer that puts the decision off ("TBD", "pending", "se decidirá") leaves the question open. A question nothing in the draft depends on says so with none (or —, ninguno) in its Blocks column: it stays in questions.md as a warning, and nothing waits for it. An empty Blocks cell is still refused. A Status column is for the reader; the checklist reads the answer. The studio, specgate questions and the checklist read an answer the same way — the cell or the Answer (Qn): line — and the studio's The spec says it lifts Needs Clarification from the requirements the question held once their text says the answer.

4. Review, approve, apply, then archive#

A draft is a change like any other, and its review is the pull request. Once the checklist says Ready to review, a person reads the requirements and assumptions.md with whoever knows the business, answers what they can, and approves the draft at a terminal — an agent cannot (approve_needs_person). Then the requirements are built one at a time:

bash
specgate change approve draft-reservas   # a person, once it reads right; apply waits for it
specgate status                          # the draft's requirements, listed while it is open
specgate apply                           # the next one: refused until a test names it, then the gate
specgate archive draft-reservas          # once every requirement in it is Implemented

Approval refuses a requirement with no kind= in its trace (approve_blocked), and writes the draft's feature files — one per requirement, its scenarios ready to run before any code. apply refuses a draft nobody approved (change_not_approved).

Leave a requirement in Draft until its test exists. Every status past Draft, Approved included, owes a test under TDD-1, so apply --status Approved refuses a requirement no test names; marked by hand, it would turn validate --strict, and every harness gate, red for the whole project.

While the draft is open its requirements already count: status lists them, apply, check and harness run judge the project as it will be after archive, and apply writes each status into the trace comment of the draft's delta (the matrix is regenerated from it). Nothing is written into docs/specs/capabilities/ before archive.

archive refuses while a requirement is still pending (archive_requirements_pending, with specgate apply REQ-… as the fix), and --force does not skip that. A change opened from a brief (brief: in change.yaml) also needs its checklist to pass; --force skips only the checklist, and says so in review. Unticked boxes in the draft's tasks.md are only a warning (archive_tasks_incomplete).

Archiving merges the requirements into docs/specs/capabilities/ and adds their rows to the matrix; the feature files are already there from approval, so it reports 0 materialised — the spec and the code it describes land in the same pull request. A test that disproves the spec text is fixed in the same draft, not in a second change. Then specgate propose --from-brief names the next module. specgate harness run can deliver the requirements instead of a person, one per worktree.

Writing in Spanish#

Write scenarios with DADO / CUANDO / ENTONCES / Y; the requirement body keeps SHALL (or DEBE). Approval writes Spanish Gherkin (# language: es, Característica, Escenario), and every rule above reads both languages.

What the checklist cannot see#

It checks that a scenario exists for each surface, and (D12) that an actor can reach the ids they act on, not that the draft asks for everything. In every pilot, an action with only an API scenario (upload a photo, add to cart) was built as an API with no button, and the gate stayed green. Run the product once, by hand or headless, after each module: that is where those gaps show, and each became a short follow-up change.

The design is ADR-0029 and draft-from-brief.

Next#