Existing project · 2 — Write down what you rely on#
The short version of an existing project, in six commands: Start. This page is the same step in detail, with recorded output.
In this phase
When you finish: one behaviour the business already depends on, written as a requirement with a concrete example, in an open change — the first thing the gate can hold your code to.
Before you start: phase 1 is done — Specgate is
adopted and specgate check passes.
| Who | Does what in this phase |
|---|---|
| You | Pick the behaviour; write the requirement and its example |
| Your agent | Can write both from the code and the tests — you review |
| Specgate | Opens the change and reserves its requirement ids |
1. See where you start#
specgate status$ specgate status
◆ specgate · status invoicing
Requirements ░░░░░░░░░░░░░░░░░░░░ 0 of 0 done
· REQ-001 Preserve existing behaviour: your test suite holds it on every check.
To close it, name REQ-001 in a test that starts the product.
Next ───────────────────────────────────────────────────
➜ specgate new "<a behaviour you rely on>"
only the adoption baseline is specified — add one requirement your code already meetsThe adoption baseline, REQ-001, is the only requirement so far, and your test
suite already holds it: status says so, and does not count it as work to do.
The areas adoption found in your
layout — Invoices, Customers — are listed in docs/specs/adoption.md with their
folders and tests: a map to pick from, not requirements. Start smaller than an
area.
2. Pick one behaviour you would hate to break#
Not a module — one rule. The one a customer would call about. Here: an invoice total is rounded to the cent.
3. Open a change — specgate propose#
A change is a folder that holds one piece of work until it is built:
discover.md (why), design.md (how), tasks.md, and a delta — the
requirements and scenarios the change adds or modifies. Open one for the rounding rule:
specgate propose invoice-rounding$ specgate propose invoice-rounding
◆ specgate · propose invoice-rounding
✔ Change invoice-rounding created · lite · REQ ids REQ-002…REQ-004 reserved
+ docs/specs/changes/invoice-rounding/change.yaml
+ docs/specs/changes/invoice-rounding/discover.md
+ docs/specs/changes/invoice-rounding/design.md
+ docs/specs/changes/invoice-rounding/tasks.md
+ docs/specs/changes/invoice-rounding/specs/invoice-rounding/spec.md
Next ───────────────────────────────────────────────────
➜ specgate apply
after you write the delta, a test that names each requirement, and the codeThe change reserves a range of requirement ids, so two changes in flight never
pick the same one. Nothing in spec.md or features/ changes yet.
4. Write the delta#
propose wrote a template of <placeholders>. Replace it with the real
requirement: one sentence that says what the system SHALL do, and a scenario
with a real example — the numbers your existing test already uses are a good
start. You can write it yourself, or ask your agent to write it from the code
and the test, and review what it wrote.
$ cat docs/specs/changes/invoice-rounding/specs/invoice-rounding/spec.md
# Delta — invoice-rounding
## ADDED Requirements
### Requirement: REQ-004 — An invoice total is rounded to the cent
<!-- specgate:trace kind=business-rule -->
The system SHALL round an invoice total, VAT included, to the cent.
#### Scenario: SCN-002 — Three lines at 21% VAT
- GIVEN an invoice with lines of 3 × 0.10, 1 × 19.99 and 2 × 4.55
- WHEN its total is computed at 21% VAT
- THEN the total is 35.56REQ-004is one of the ids the change reserved,REQ-002…REQ-004; any of them will do.SCN-002names the scenario (SCN-001is the baseline scenario from adoption).kind=business-rulesays what sort of requirement it is:functional,non-functionalorbusiness-rule.- A scenario with numbers is a claim someone can check. "Totals are correct" is not.
Tick the first tasks in the change's tasks.md as you finish them.
5. See it in flight#
specgate status$ specgate status
◆ specgate · status invoicing
Requirements ░░░░░░░░░░░░░░░░░░░░ 0 of 1 done
To do ──────────────────────────────────────────────────
○ REQ-004 An invoice total is rounded to the cent a test and code
· REQ-001 Preserve existing behaviour: your test suite holds it on every check.
To close it, name REQ-001 in a test that starts the product.
Next ───────────────────────────────────────────────────
➜ specgate change approve invoice-rounding
invoice-rounding waits for a person to approve it, at their terminal — apply delivers nothing beforestatus, check and apply read the requirements of an open change too:
REQ-004 is in flight — specified, not yet built or merged into the
specification. It joins the specification when you archive the change, after
it is proved, in the next phase.
The whole module, when you are ready#
To describe all of src/invoices rather than one rule at a time, open a
change for the capability and let your agent write its delta from the code
and the tests:
specgate propose describe-invoices --capability invoices
specgate propose --from-brief --check describe-invoicesThe second command runs the drafting checklist on the delta: every
requirement has a scenario and a kind, no scenario is left as a template, no
id is used twice. Review it with whoever knows the business, then build and
archive it like any other change. Its area in docs/specs/adoption.md is a
map, not a requirement: there is nothing in the specification to remove.
You're done when…#
docs/specs/changes/invoice-rounding/holds REQ-004 with a real sentence, not the template.- Its scenario has a concrete GIVEN/WHEN/THEN and no
<placeholder>. specgate statuslists REQ-004.
If something goes wrong#
| You see | It means | Do |
|---|---|---|
Change invoice-rounding — delta not written yet, not judged until it is | The delta is still the template, so REQ-004 is not listed | Write the requirement and its scenario |
unfilled placeholder in "given <precondition>" | A scenario step still has the template's text | Write the real steps |