π End-to-end tutorial β building Smart Parking#
A step-by-step walk through the commands you use most in
specgate, and many of the others. We build one real backend project β Smart
Parking β on top of the public demo pack
rsaglobaltech/parking-management-specops.
You do not need to understand the whole tool up front. Each step
explains the concept first, then the command, then what you should see.
If you have not installed the CLI globally, replace every specgate in
this guide with npx @rsaglobaltech/specgate@latest.
This tutorial follows domain packs. For work from a client's brief, see
From a client brief and the
From scratch journey: specgate propose --from-brief turns the brief into requirements module by module. For work
from a Jira ticket, see From a Jira ticket. Everything
from Step 3 on applies to all three.
The daily loop is four verbs: propose opens a change, apply delivers
one requirement through the gate, status says what is left, and archive
closes the change once its code is done. init runs once; check is the
same gate in CI. Steps 3β6 walk through all of them.
Before anything else: the two places you will work#
This is the single most important idea in the tool, and the one that trips
people up. There are two separate folders on your disk, and they are not
the same thing:
text
βββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββ
β THE PACK REPO β β YOUR IMPLEMENTATION PROJECT β
β parking-management-specops/ β β smart-parking/ β
β β β β
β β’ pack.yaml (the domain model) β β β’ spec.md β
β β’ templates/ (Gherkin templates) β β β’ features/**/*.feature β
β β βββΆ β β’ docs/specs/traceability.md β
β Reusable knowledge, versioned β β β’ src/, test/ (the code YOU write)β
β with git tags (v0.1.0, v0.2.0β¦). β β β’ .specops.lock β the link β
β You only open this if you AUTHOR β β β
β packs. β β Where you spend 95% of your time. β
βββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββ
the SOURCE of specs the project that CONSUMES them
The pack repo is a library of domain knowledge. Think of it like a
package on npm β you usually just consume a published version of it,
you do not edit it.
Your implementation project is the app you are building. It is a
normal git repo with your real source code. init created it; expand /
specops add copied rendered specs into it; and .specops.lock (a file
inside your project) remembers which pack and version it came from.
The rule of thumb: unless a step explicitly says "the pack repo", you
run the command from inside your implementation project
(smart-parking/). Every step below carries a π badge so you are never in
doubt.
Network access the first time you run specops add β it clones the pack
repo into a per-user cache (~/.cache/specgate/packs/β¦). After that it is
offline.
Optionally install the CLI globally so specgate works everywhere:
bash
npm install -g @rsaglobaltech/specgate@latest
specgate--version# 1.8.0specgate--help# the six you start with: init; propose, apply, status, archive; checkspecgate--help--all# the whole surface
init does not write any business logic. It creates an empty-but-valid
spec-driven project: the folders, the requirements document, and the
traceability matrix β the skeleton everything else fills in. It is the
git init of spec-driven development.
You describe the project in a small config file. It can be a YAML
mapping (.yaml / .yml) or the legacy KEY="value" format (.config);
init picks the parser from the file extension. We use YAML here.
smart-parking/
βββ spec.md # the requirements document β prose
βββ AGENTS.md # stack guardrails for AI agents
βββ README.md
βββ features/ # Gherkin scenarios will live here
βββ docs/specs/
βββ traceability.md # the requirement β code matrix β the spine
βββ adr/
The scaffold ships with one requirement, REQ-000 β The service reports its own health, so the project is already valid; --no-sample-req leaves it out.
docs/specs/traceability.md is generated from spec.md, the scenario
tags and your tests β nobody edits it, and specgate matrix regenerates it.
Now we give the project a real domain.
3. Step 2 β Apply the domain pack (specops add)#
π Run from: inside your project β smart-parking/.
A domain pack is reusable, versioned domain knowledge: requirements,
use cases, commands, aggregates, events, and the Gherkin scenarios that pin
them down. It lives in its own repo (here:
parking-management-specops), tagged with versions like v0.1.0.
specops add is the npm-install of spec-driven development. It:
clones the pack repo (at the version you pin),
renders the pack's templates into your project β this is the arrow
in the diagram at the top: knowledge flows from the pack repo intosmart-parking/,
writes a .specops.lock file in your project that remembers the
repo, version, commit and variables β so you never retype them.
You are not editing the pack. You are pulling a snapshot of it into your
project.
.specops.lock β the link back to the pack. Records repo, version,
resolved commit, and your --var values.
.specops/baseline/β¦ β a verbatim copy of exactly what the pack
rendered. This is the "known-good ancestor" that makes a later
specops sync able to merge safely instead of clobbering your edits.
β Commit .specops.lock and .specops/ to git. A teammate who
clones your project needs both for specops sync to work.
Useful flags:--dry-run, --cache-dir <path>, --pack-root <path>
(point at a local pack folder instead of a git URL β handy offline or for
testing).
expand is the low-level version of this.specops add is the
friendly wrapper; expand does the same rendering with more explicit
flags and no lockfile bookkeeping. Use specops add day to day.
check is the gate: the one command that says whether the project is
honest. It runs validate --strict β required files, every .feature
claimed by a requirement, scenarios tagged @REQ-NNN @SCN-NNN, valid
statuses, Gherkin that parses, and no requirement past Draft without a test
that names it β and then your own test suite. This is what CI runs, and
it is the same command you run locally.
Tell it once how to run your tests. init wrote no build β no pom.xml,
no mvnw β so create your Quarkus/Maven project in smart-parking/ first
(code.quarkus.io, or your own), then set your build's test command:
bash
specgate config set test_cmd "./mvnw -B verify"# your build's: mvn -B test, npm test, pytestβ¦
text
β test_cmd = ./mvnw -B verify
harness.config.yaml
`check` and `apply` now run it.
Right after specops add it passes: every pack requirement is still
Draft, and a Draft requirement owes nothing yet. Without a test command it
still passes, and says so β "this checked the specification, not the
code" β because a gate that never ran your tests should not claim it did.
The rule that matters most is [TDD-1]: a requirement whose status has
left Draft must have a test that mentions its id. That mention is the
whole link β there is nothing to register. [TDD-2] (a row with no scenario)
and [TDD-3] (a REQ-NNN in spec.md with no row) catch the rest.
After specops add, your project has scenarios but no code. status
answers "what do I do next?" β requirement by requirement, what each one
still needs, and the single next command to run.
β specgate Β· status smart-parking
Requirements ββββββββββββββββββββ 0 of 6 done
To do ββββββββββββββββββββββββββββββββββββββββββββββββββ
β REQ-000 Health baseline its test
β REQ-001 Monitor Capacity Threshold a test and code
β REQ-002 Register Vehicle Entry a test and code
β REQ-003 Calculate Parking Fee a test and code
β REQ-004 Detect Overstay a test and code
β REQ-005 Send Payment Receipt a test and code
Next βββββββββββββββββββββββββββββββββββββββββββββββββββ
β specgate apply REQ-000
once a test mentions REQ-000 β that mention is the link; apply checks first
(Output trimmed; the layout is the CLI's.) Start every day with it; you never
have to remember which command applies. Requirements of a change that is still
open are listed too β they count while the change is in flight.
Before a change exists, specgate explore "<question>" prints a brief of
the project's state to think through with a person or an agent; it writes
nothing. See the command reference.
plan is the detailed view behind status for the requirements already in
the specification β an open change's requirements are listed by status, not
by plan, until the change is archived. Per requirement, whether its
feature, test and code exist, in a bucket (NEEDS_FEATURE,
NEEDS_EVERYTHING, NEEDS_TEST, NEEDS_IMPLEMENTATION,
NEEDS_STATUS_UPDATE, DONE). Its JSON is the task queue the harness
consumes in Step 12, and what an agent reads to know what to work on.
6. Step 5 β Implement a requirement and deliver it (apply)#
π Run from: inside your project β smart-parking/.
apply refuses while no test names the requirement:
bash
specgate apply REQ-001
text
β specgate Β· apply REQ-001 Implemented
β REQ-001 REQ-001 has no test that names it yet (TDD-1). [apply_no_test]
fix: write a test that names REQ-001 (and its scenario SCN-001), then run specgate apply REQ-001
Write the test, naming the requirement and its scenario:
java
// REQ-001 SCN-001: operators are alerted at the capacity threshold@Testvoid alertsAtNinetyPercentOccupancy() { β¦ }
β¦then the code, until your suite passes, and run it again:
bash
specgate apply REQ-001
text
β Specification the gate, for REQ-001
β Tests ./mvnw -B verify
β REQ-001 β Implemented (1 row updated)
apply runs the gate β the specification and your test_cmd β and marks
the requirement Implemented only if it passes; when the gate fails it writes
nothing. Without an id it takes the next requirement status names.
--status Verified (or Released) targets a later state; apply REQ-001 REQ-002 β¦ delivers several with one run of the suite; --no-check skips the
gate, and says so.
7. Step 6 β Add a NEW requirement (propose Β· archive)#
π Run from: inside your project β smart-parking/. You do not
touch the pack repo here.
The pack covers parking operations in general, but your project needs
something extra β say, "operators can reserve a parking spot in advance."
You add it locally, in your project. It is yours, not the pack's.
New work arrives as a change: a folder under docs/specs/changes/ with
its discovery notes, a design, a task list and a delta β the requirements it adds, with their
scenarios. The change stays open while you build it, and its requirements
already count: status lists them, apply delivers them. When every one is
Implemented, archive merges the delta into the specification. A change
is archived when its code is done β spec and code land in the same pull
request.
β Change add-reservations created Β· lite Β· REQ ids REQ-006β¦REQ-008 reserved
+ docs/specs/changes/add-reservations/change.yaml
+ docs/specs/changes/add-reservations/discover.md
+ docs/specs/changes/add-reservations/design.md
+ docs/specs/changes/add-reservations/tasks.md
+ docs/specs/changes/add-reservations/specs/reservations/spec.md
Next βββββββββββββββββββββββββββββββββββββββββββββββββββ
β specgate apply
after you write the delta, a test that names each requirement, and the code
The reserved range means two changes in flight never hand out the same
REQ-NNN. Any id inside it will do; this one takes REQ-007, because the
pack's next version (Step 7) adds a REQ-006 of its own. Write the delta in
docs/specs/changes/add-reservations/specs/reservations/spec.md β
specgate change instructions specs prints the template and the rules:
markdown
# Delta β reservations
## ADDED Requirements
### Requirement: REQ-007 β Reserve a spot in advance
The system SHALL let an operator reserve a free spot for a future window.
#### Scenario: Reserving an available spot
- GIVEN spot "A-12" is free between "09:00" and "11:00"
- WHEN an operator reserves spot "A-12" for that window
- THEN spot "A-12" is marked "Reserved" for that window
<!-- specgate:trace kind=functional actor=Operator -->
Steps are plain - GIVEN bullets, and the body needs SHALL, MUST,
SHOULD or MAY. The trace comment's kind= (functional, non-functional or
business-rule) is required: without it change validate reports
change_not_approvable and change approve refuses the change. actor=
names who uses the requirement; change instructions specs asks for it too,
and the use-case views group requirements by it. specgate status now lists
REQ-007 with a test and code to go. archive refuses while it is pending:
text
β add-reservations Change 'add-reservations' has 1 requirement(s) not delivered yet: REQ-007. [archive_requirements_pending]
fix: specgate apply REQ-007
apply also waits for a person: it refuses a requirement of a change nobody
approved (change_not_approved). Read the delta, then approve the change
yourself, in your terminal. An agent cannot: approving refuses a session with
no terminal (approve_needs_person).
bash
specgate change approve add-reservations
Approving also writes the scenarios to
features/reservations/REQ-007.feature, so they exist before any code. The
approval seals each requirement by its hash; edit one afterwards and the
gate fails (approved_requirement_changed) until you approve it again.
So do what Step 5 did β a test that names REQ-007, the code β then deliver
it and close the change:
β REQ-007 β Implemented (1 row updated)
Next βββββββββββββββββββββββββββββββββββββββββββββββββββ
β specgate archive add-reservations
every requirement of add-reservations is delivered
β Archived as 2026-10-19-add-reservations
Specs 1 added Β· 0 modified Β· 0 removed
Traceability 1 row(s) added Β· 0 updated Β· 0 removed
Features 0 materialised
Archiving writes the requirement into docs/specs/capabilities/reservations/,
its matrix row, and files the change under docs/specs/changes/archive/<date>-<id>/;
the feature file is already there from the approval, so Features says 0. Tick
tasks.md as you go; once every requirement passed the gate, an unticked task
is a warning, not a refusal. --force never skips the requirement check.
One requirement, no change folder?specgate new "<title>" still writes
a draft ## REQ-NNN straight into spec.md, with a scenario of
<placeholders> under features/ β the quick path for a project that keeps
everything in spec.md. Rewrite the placeholders, then apply as above.
A whole new module, not one requirement? Write it down in
docs/brief.md and let specgate propose --from-brief turn it into a draft
change, module by module β see Write the brief.
A draft follows the same path: reviewed, applied, then archived.
Watch the ids when you upgrade the pack.propose reserves the next
free ids, and a later pack version can add the same one. Had this change
kept REQ-006, Step 7's sync would stop: both versions write a
REQ-006 row in docs/specs/traceability.md, so sync reports it as the
conflicting file (CONFLICT (markers written)) and exits non-zero. Keep
both rows and check fails with Duplicate Requirement ID in traceability.md: REQ-006. Read the diff before syncing, and give your local
requirement a free id first if the pack claims its id.
8. Step 7 β Upgrade the pack version (specops diff + specops sync)#
π Run from: inside your project β smart-parking/.
β οΈ This is the step people get wrong.diff and sync run from
your implementation project, not from the pack repo. The pack repo is
just the source. diff/sync reconcile your project against a newer
pack version, using the .specops.lock that lives inside your project.
You never cd into parking-management-specops for this.
+ is a new file, ~ is a modified one. Nothing is written. --json emits
the same data for tooling.
Why the --vars?v0.2.0 of this pack requires four variables v0.1.0
did not. Without them diff and sync stop with
Missing required variable 'STACK'. Provide it using --var STACK=.... Pass
them once; sync writes them back to .specops.lock.
specgate status # new REQs from the pack now show as pendingspecgate check
git add .specops.lock .specops/ docs/ features/
git commit -m"chore: sync parking pack to v0.2.0"
Read status after a sync. A requirement you had closed can come back
as Ready to close when the sync rewrote its files β run specgate apply
for it again; its test is still there, so the gate passes.
Running specgate specops syncwithout--pack-version just re-renders
everything at the versions already pinned in .specops.lock β handy
after a fresh clone, or to regenerate a file someone deleted.
π Run from: inside your project β smart-parking/.
bash
specgate specops remove backend
remove drops the pack's entry from .specops.lock. It deliberately does
not delete the generated files β you may have hand-edited tests that
point at them. Review with git status and delete what you no longer want
by hand. --dry-run shows what would be removed.
π¦ Run from: the pack repo β a folder for your pack (e.g.
~/sandbox/domain-packs/β¦), not your implementation project. This is
the one place in the tutorial where you leave smart-parking/.
So far you have consumed a pack. Eventually you will want to package
your own domain knowledge so other projects (or your future self) can
specops add it. Four commands cover the authoring lifecycle.
cd ~/sandbox
specgate pack init --out ./domain-packs --name"Reservations Backend"--type backend
# flavours: backend Β· frontend Β· mobile Β· contracts
Writes ./domain-packs/reservations-backend/backend/pack.yaml plus a
templates/ folder: the pack id is the slug of --name, then --type β
reservations-backend/backend, the id every --pack below uses.
The scenario-quality rules flag vague or thin Gherkin β a Scenario Outline with no Examples, a scenario missing a When/Then, fewer than
three steps, a generic title, vague step language (works, correctly,
as expected, etc, TODO, ...), or a pack.yaml scenario name that
has drifted from its template title.
bash
# In CI β and before a pack feeds the harness β promote those to errors:specgate pack lint --pack-root ./domain-packs --pack reservations-backend/backend --strict
This matters because the pack's scenarios become the reward signal for
the harness (Step 12): weak scenarios let the harness wave through weak
code.
10.3 See the reference graph β pack lint --graph#
The hardest part of authoring a pack is keeping the
REQ β UC β CMD/QUERY/AGG β EVT cross-references consistent by hand.
--graph draws that spine so you can see it:
bash
# Mermaid (default) β renders natively in GitHub and VS Codespecgate pack lint --pack-root ./domain-packs --pack reservations-backend/backend --graph# Graphviz DOTspecgate pack lint --pack-root ./domain-packs --pack reservations-backend/backend --graph--graph-format dot
A reference to an ID/name that does not exist becomes a red missing
node in the diagram and is listed on stderr β and the command exits
non-zero, so --graph doubles as a CI link-check.
Writing the model first (requirements β use cases β commands β events) and
the scenarios last has a waterfall smell. pack infer flips it: write the
.feature first, get a proposed pack.yaml skeleton back.
bash
# still in ~/sandbox β a draft scenario, outside the packmkdir-p drafts
cat > drafts/reserve_spot.feature <<'EOF'
@REQ-001
Feature: Reserve a spot in advance
Scenario: Reserving an available spot
Given spot "A-12" is free between "09:00" and "11:00"
When an operator reserves spot "A-12"for that window
Then spot "A-12" is marked "Reserved"for that window
And a "SpotReserved" event is emitted
EOF
specgate pack infer --from ./drafts/reserve_spot.feature
It heuristically maps a @REQ-NNN tag β a requirement reference; the
Feature: name β the use case name; each When step β a command or a
query; a quoted PascalCase token in a Then step β an event; each
Scenario: β a scenarios[] entry. Anything it cannot infer is left as an
explicit TODO: β a skeleton to review, never a silent guess. Output goes to
stdout (--format json for tooling); it never mutates pack.yaml.
Five things it does that are worth knowing, because each one used to be a
correction you made by hand:
The same operation is proposed once. A happy path and its failure
exercise one command; they used to arrive as two entries with two ids.
A When that reads becomes a query, with a QRY- id β "searches",
"views", "lists". The pack model already separates queries from commands;
inference now does too.
Names drop the glue. "10 more vehicles enter the facility" gives
MoreVehiclesEnterFacility, not MoreVehiclesEnterThe.
Field names are proposed from the Gherkin β <placeholders> in a
Scenario Outline and key: value pairs β each with a TODO for its type.
The names are in the file; the types are not, and a guessed type that looked
confident is exactly what ADR-0014
refuses.
--from repeats, and takes a directory. A capability is rarely one file,
and inferring per file proposes a shared command once per file:
bash
specgate pack infer --from ./drafts/ # every .feature in itspecgate pack infer --from a.feature --from b.feature
bash
# Keep the proposal in a file of its own to review:specgate pack infer --from ./drafts/reserve_spot.feature > drafts/reserve_spot.inferred.yaml
Do not append it to pack.yaml: the fragment has its own requirements:,
use_cases:, events: and scenarios: keys, and pack.yaml already has
them, so >> leaves every key twice. Copy each entry you keep into the list
of the same name in pack.yaml, resolve its TODOs and UC-XXX, then run
pack lint (10.2).
11. Step 10 β Add a NEW requirement (as a pack author)#
π¦ Run from: the pack repo (e.g. a clone of
parking-management-specops, or your own pack folder). This is the
other half of "adding a requirement" β Step 6 added one to a single
project; this adds one to the pack, so every project that
specops syncs will receive it.
# inside the pack repomkdir-p drafts
cat > drafts/waitlist.feature <<'EOF'
@REQ-006
Feature: Capacity waitlist
Scenario: Joining the waitlist when the facility is full
Given the facility is at full capacity
When a driver requests entry
Then the driver is added to the waitlist
And a "DriverWaitlisted" event is emitted
EOF
specgate pack infer --from drafts/waitlist.feature
Add the new requirement, use_case, command, event and scenario
entries to pack.yaml, replacing every TODO: with real values and fixing
the IDs so they fit the pack's numbering. Add the feature template under
templates/features/β¦ and point the scenario's template: / target:
fields at it.
--strict catches a weak new scenario; --graph shows the new
REQ-006 β UC-006 β β¦ β DriverWaitlisted spine and shouts if you mistyped
a reference.
# bump metadata.version in pack.yaml β this pack's went 1.1.0 β 1.2.0; the tag is separate:git commit -am"feat: add capacity waitlist (REQ-006)"git tag v0.2.0git push --tags
11.5 Consumers adopt it β back in their projects#
Now anyone with a project that uses this pack picks up REQ-006 through
the normal Step 7 flow β from inside their own implementation project:
bash
# π inside smart-parking/ (NOT the pack repo)specgate specops diff --pack-version v0.2.0--var β¦ # preview: + waitlist feature, ~ matrixspecgate specops sync --pack-version v0.2.0--var β¦ # three-way merge into the projectspecgate status # REQ-006 now shows as pending
That is the full pack-author loop: draft scenario β pack infer β merge
β pack lint --strict --graph β version + tag β consumers diff +
sync.
12. Step 11 β Change a requirement that already shipped (propose)#
π Run from: inside your project β smart-parking/.
Step 6 added a requirement. This is the other case, the one you hit for the
rest of the project's life: a requirement shipped, and now it has to
change. It is the same loop β propose, change approve, apply,
archive β with a delta
that states only what moves, so the review reads the modification as intent.
This works on the requirements under docs/specs/capabilities/ β the ones
changes and drafts create. A requirement written
with specgate new lives only in spec.md: change that one by editing its
section and its scenario, and check and apply hold it to the same gate.
# Delta β reservations
## MODIFIED Requirements
### Requirement: REQ-007 β Reserve a spot in advance
The system SHALL require a deposit before confirming a reservation, and SHALL
release the spot if the deposit is not paid within 15 minutes.
#### Scenario: A reservation without a deposit expires
- GIVEN spot "A-12" is reserved but unpaid
- WHEN 15 minutes pass
- THEN the reservation is cancelled and the spot is free again
<!-- specgate:trace kind=functional -->
MODIFIED replaces the whole requirement block; it does not merge scenario
by scenario. While the change is open, REQ-007 is judged as it will be after
archive: status lists it again and archive refuses until it is applied.
A person approves the change again, at a terminal; then extend its test to
cover the deposit, change the code, and deliver it:
bash
specgate change approve reservations-need-a-deposit # you, not the agentspecgate apply REQ-007specgate archive reservations-need-a-deposit --dry-run# the plan, nothing writtenspecgate archive reservations-need-a-deposit
text
β Archived as 2026-10-19-reservations-need-a-deposit
Specs 0 added Β· 1 modified Β· 0 removed
Traceability 0 row(s) added Β· 1 updated Β· 0 removed
Features 1 materialised
β² features/reservations/REQ-007.feature features/reservations/REQ-007.feature rewritten from REQ-007's modified scenarios. [archive_feature_regenerated]
fix: Review the diff: the feature file now matches the delta.
Archiving applies the delta to docs/specs/capabilities/, rewrites the
scenario under features/, updates the matrix row, and files the change. If a
test disproves the delta's wording while you build, fix the delta in the same
change β nothing was merged yet.
It composes with packs. When the pack itself changes,
specgate specops diff --pack-version v0.2.0 --as-change --var β¦ writes a
change folder, docs/specs/changes/upgrade-backend-v0.2.0/, in the older
layout: proposal.md, tasks.md and a delta with one
ADDED/MODIFIED/REMOVED requirement per requirement the version moves
(here, REQ-006 added) β no discover.md or design.md. It writes no
generated file β sync still does that. As written, it fails check: the
pack's REQ-006 body has no SHALL, an error under the standard preset
(no_rfc2119_keyword). To make it pass, give each body a SHALL and its
trace a kind= (approval refuses one without), then approve it:
bash
# in specs/backend/spec.md: "The system SHALL let drivers join a waitlist β¦"# <!-- specgate:trace kind=functional uc=UC-006 β¦ -->specgate check # passesspecgate change approve upgrade-backend-v0.2.0# you, at a terminal
change validate still warns layer_no_design until it has a design.md
(specgate migrate 1.0 adds one from the proposal). You review an upstream
upgrade as intent rather than as a file diff.
Everything in Steps 4β6 β read the scenario, write the test, write the
code, run apply β is a loop a machine can drive. harness run is that
driver. For each pending requirement, in an isolated git worktree on a
fresh harness/REQ-NNN branch, it:
builds a self-contained prompt (the Gherkin scenario + AGENTS.md +
the exact artifact paths + any previous failure),
shells out to your AI agent,
gates the result with validate --strict + your test command,
on green β marks it Implemented and commits; on red β retries, feeding the
failure back into the next prompt,
prints a pass/fail/attempts report.
It is vendor-neutral: the agent is any shell command that contains
the {prompt_file} placeholder. The harness never merges a branch β you
review and merge harness/* yourself β unless you ask for --chain, which
merges each green requirement before cutting the next
(The harness).
13.1 Configure it β using opencode as the agent, with a project-wide prompt prefix#
Start by generating the two files rather than copying them out of this page:
bash
specgate harness init
It writes harness.config.yaml and .harness/prompt-prefix.md, detects your
gate from the build files it finds (mvn -B test here, from pom.xml), and
deliberately leaves agent: unset β which agent runs this is your choice and
your credentials. Read the prefix it generates and make it sound like your
team; the rest of this section is what a filled-in version looks like.
If you drive your editor with opencode, point the
harness at it. The harness writes each prompt to a temp file and substitutes
its path for {prompt_file}; opencode run takes a prompt string, so read
the file in:
yaml
# harness.config.yaml β at the root of smart-parking/harness_version: 1agent: 'opencode run "$(cat {prompt_file})"'test_cmd: "mvn -q test"max_attempts: 3# Project-wide directives prepended to every per-REQ prompt: Role,# Active Project Boundary, Execution Policy. Use prompt_prefix for a# one-liner; prompt_prefix_file for the realistic multi-line case.prompt_prefix_file: ./.harness/prompt-prefix.md
markdown
<!-- .harness/prompt-prefix.md -->
# Role
You are the Lead Technical Architect and Senior Backend Engineer.
# Active Project Boundary
- Current directory is the only scope. Do NOT scan siblings.
# Execution Policy
- Start coding. No planning-only output.
- Hexagonal architecture is non-negotiable (see AGENTS.md).
- Never modify AGENTS.md, spec.md, or features/**/*.feature.
With a config file you do not have to retype anything. (Any other agent
works the same way β e.g. claude -p < {prompt_file} or
aider --yes --message-file {prompt_file}.) The prompt_prefix /
prompt_prefix_file rides along on every per-REQ prompt, so your
universal directives are not duplicated and not forgotten.
--dry-run builds and prints the prompt for every pending requirement
without invoking the agent or touching git. Read what opencode would
receive before you spend tokens.
# the working tree must be clean β the harness refuses a dirty treespecgate harness run --agent'opencode run "$(cat {prompt_file})"'--test-cmd"mvn -q test"
(If you put the agent and test command in harness.config.yaml, plain
specgate harness run is enough.)
Flags:--req REQ-NNN (limit to specific requirements, repeatable β
great for trying one first), --max-attempts <n>, --base-branch <ref>,
--timeout <seconds>, --keep-worktrees, --force (recreate existing
harness/* branches), --setup-cmd <cmd|none> (the install each new worktree
runs), --format json. To watch a run as it happens, specgate studio shows
it in its Live section (/live) β see The studio.
The command exits non-zero if any requirement did not pass, so CI can gate
on it. Each result is a branch you can check out, inspect, and merge β or
throw away.
13.4 Inspect what the agent will receive (harness prompt)#
bash
specgate harness prompt REQ-004# still pending: the run above left it failing (REQ-001 shipped in Step 5)
Prints the exact prompt the harness would hand the agent for one REQ β
prefix included β without invoking the agent, creating worktrees, or
touching git. Use it to:
iterate on AGENTS.md and prompt_prefix and see the effect immediately;
copy-paste the prompt into a web AI when no CLI agent is available;
review what the team's standing directives currently say.
Every prompt the harness actually sends during harness run is also
mirrored to .specops/harness-prompts/REQ-NNN-<timestamp>-attempt-N.md
for after-the-fact review. Commit or gitignore that folder per your
team's preference.
13Β½. Multi-stack: one pack, many implementations#
The pack/implementation split lets you ship the same domain spec in
multiple stacks without duplicating requirements or scenarios. Each
implementation is its own repo:
Each project runs its own specgate init with a different STACK in the
config, its own specgate specops add against the same pack repo +
version + domain --vars, and its own harness loop. spec.md and
features/** are identical across stacks (rendered from the same pack).
AGENTS.md differs because its {{STACK}} substitution does, and so does
each traceability matrix: it maps a requirement to the file that implements
and the file that proves it, and those files differ per stack. In one
repository, specgate init --multi-stack spring,quarkus,micronaut sets up the
same arrangement under one root.
Useful for migration POCs, framework comparisons, educational material
("same problem, three stacks"). The architecture explicitly supports it β
see docs/specs/architecture.md Β§5.
The vscode-spec-driven extension turns the editor into a pack-authoring
surface: live JSON Schema squigglies on pack.yaml, dangling-reference
diagnostics, reference-field autocomplete (offers the IDs/names that
actually exist), go-to-definition on a reference, a CodeLens showing
how many use cases and scenarios point at each requirement,
validate-on-save, and the Spec-Driven: Show Pack Graph command β a
side-panel Mermaid render of the pack graph that refreshes as you edit.
specgate mcp install --client claude # or cursor β writes the client's MCP configspecgate mcp serve # what that config starts, over stdio
The server exposes the CLI as MCP tools β specgate_status, specgate_check,
specgate_done, specgate_change_new, specgate_change_archive and the rest
(the four verbs under their older names) β so an MCP-aware client
can drive the same loop natively. See MCP server.
That writes /specgate:explore, /specgate:draft, /specgate:new, /specgate:apply, /specgate:check,
/specgate:done, /specgate:propose, /specgate:archive and /specgate:onboard, plus the instruction file each tool reads
β .cursor/rules/, .github/copilot-instructions.md, CONVENTIONS.md and so
on. They are thin on purpose: rather than restating the delta grammar, which
would be stale the moment it moved, they call specgate change instructions <artifact> --json for it.
After a CLI upgrade, specgate update three-way merges those files so your edits
survive.
This tutorial started from init, on a blank page. On a repository that
already has code, specgate init adopts it: it reads the layout, proposes the
capabilities the code already implies and writes the spec skeleton without
touching a line of source. specgate onboard --tour runs the whole loop β
propose, a test, status, apply, archive, check β on a temporary copy of
it and narrates each step (command reference).
specgate doctor reports what has drifted, with a fix per finding.
write the delta under specs/<cap>/spec.md, then a person runs change approve <id>
rewrite its section and scenario
merge the inferred skeleton into pack.yaml
3
a test that names the REQ, the code
a test that names the REQ, the code
add the feature template under templates/
4
apply, then archive
apply
pack lint --strict --graph
5
reviewable as intent, archived with a date
β
bump version, tag; consumers specops diff + sync
In none of them do you edit the matrix: it is generated. The first column is
the daily loop β it leaves an audit trail of why a requirement was added or
changed, and check runs the same gate in CI for all three.