/sdd:writing-specfrom sdd
Use before building a feature, story or change that needs agreement first - the user asks to plan, spec, design, scope or "grill" something, or asks for cases, acceptance criteria or a test plan, or the work touches data, schema, an API, or several parts at once. Grows one spec per story, asking the user only the key decisions and listing the ones it assumed, drills each decision down to expected and unexpected cases, and asks in one message for the only approval, with the choice of building solo or as a team. Uses Trellis as the store when it is installed. Not for a one-line fix or a spike.
Ships in sdd. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The tests are the ground the work stands on, and the tests come from the spec. This skill settles the decisions, turns them into cases, and gets the cases approved.
Prose decays: text nobody re-reads goes stale while still looking true. So the spec holds only what something re-reads: decisions later work must respect, and cases that tests execute. Everything else stays in the conversation.
Scripts live in <this skill's directory>/../../scripts/.
Say which, in one line, before anything else:
Run python3 <scripts>/store.py and use its answer. Do not decide the store yourself.
store: trellis: the spec lives in the Trellis vault under specs/<story>/,
one entry per segment. Pass bodies on stdin so no scratch file lands in the
repository: trellis vault new --in specs/<story> --title "..." --body - <<'EOF',
and change one with trellis vault edit <entry> --body - --if-version <n>.
Run trellis search "<topic>" for related specs. Operate the CLI as the
trellis skill says.store: files: the spec lives at specs/<story>/*.md, or specs/<story>.md
while it is one segment.If a spec for this story exists, grow it in place. Never start a second spec for the same story. History is in git or in Trellis revisions, not in the text.
Say which, in one line, so the user can override it.
Work like a senior engineer: settle what you can, and bring the user only the decisions that are theirs.
Map the work as a tree of decisions. The frontier is every decision whose prerequisites are settled. Each round, sort the frontier:
Assumed., and list it in the same message under Assumed (say if not),
one line each, so the user can veto any of them in a word.Ask through AskUserQuestion, at most four per call, your recommended option
first and labelled (Recommended). Put the assumed list in the text before
the call. Without the tool (under claude -p, for instance), write the asked
ones in exactly this form, which a hook reads so unanswered questions are not lost:
Q1. <question> — recommended: <your answer, one line why>
Q2. ...
Assumed. and list them, and put work the user did not ask for under
Not in this story. The case approval still happens.After each round, write what was settled into the spec before the next round.
A decision you made, not the user, ends with Assumed. in the spec itself, not
only in your message: the next session must tell it from one the user made.
If the answered question is in the open-items queue
(python3 <scripts>/open_items.py list), end the decision with Answers: <id>.
One story, split into segments once it passes about 150 lines or spans areas:
an index segment linking the others ([[specs/<story>/<area>]] in Trellis, a
relative link in files), and one segment per area. Pick a short uppercase story
key (PIN); every ID starts with it.
# <Story or area>
Status: cases pending approval
Intent: <two to four lines: what it is for, and what it is not for>
## Decisions
- **PIN-D1** <the decision>. Why: <one line>. Governs: <what it constrains, comma-separated>.
- **PIN-D3** <a decision you made>. Why: <...>. Governs: <...>. Assumed.
- **PIN-D4** <new decision>. Why: <...>. Governs: <...>. Supersedes: PIN-D2.
## Cases
| ID | Covers | Kind | Case |
|---|---|---|---|
## Open
- <question not yet settled>
cards.ref), an
endpoint (api:/cards), a file, a behaviour. Two active decisions governing
the same thing collide unless one supersedes the other.When the frontier is empty, turn the decisions into cases.
For every active decision, ask:
Expected: when the decision holds, what does the user see? Write it as Given / when / then.
Unexpected: walk this list, every item, every decision:
Each item becomes a case, or you say in one line why it does not apply.
A decision with no unexpected case at all ends its bullet with
Unexpected: n/a — <reason>.
Pick the key examples, not every combination. More than four cases per
decision is a sign to merge them: spec_check reports it as crowded.
Under ## Cases in the segment they belong to. Covers names the decisions
a case exercises:
| ID | Covers | Kind | Case |
|---|---|---|---|
| PIN-C1 | PIN-D1 | expected | Given a card, when it is pinned, then it sorts first |
| PIN-C2 | PIN-D1 | unexpected | Given a card id that does not exist, when it is pinned, then exit 3 and nothing changes |
expected (normal use) or unexpected (anything from the list above).python3 <scripts>/spec_check.py specs/<story> # files
python3 <scripts>/spec_check.py --trellis specs/<story> # Trellis
Before approval, untested is expected. Fix every uncovered, collision,
bad_ref, duplicate and no_unexpected first, or tell the user why one stands.
List every decision that ends Assumed. above the cases; leave the list out
when nothing was assumed. Recommend solo or team from facts: how many case
groups are independent, whether migrations are involved, whether the store is
Trellis. Team needs
Trellis: without it, do not offer team and say that it needs Trellis.
Group the cases into user stories, the way the user would read them: what
someone can do, and what they get. Each story is a heading with one
"As a , " line, and each case under it is one plain sentence led
by its ID and its kind in brackets, [expected] or [unexpected]. A case
keeps its Given/when/then meaning but drops the decision IDs, arrows and exit
codes a reader has to decode; those stay in the spec's table.
Put the order of stories where one builds on another, and the unexpected cases
beside the expected ones they guard.
Assumed (say if not)
PIN-D3 <one line>
...
Cases (N: a expected, b unexpected; per decision: PIN-D1 3, PIN-D2 2)
### 1. <Story: what the user can do>
*As a <who>, <outcome>.*
- **PIN-C1** [expected] <one plain sentence: when I do this, that happens>.
- **PIN-C2** [unexpected] <one plain sentence: when this goes wrong, that happens>.
### 2. <Story>
*As a <who>, <outcome>.*
- **PIN-C3** [expected] <one plain sentence>.
Approve these cases?
Build — recommended: solo (<reason from the facts>)
solo: I build them in order, test-first
team: cases become Trellis cards worked by several agents
This is the only approval before code. When the user approves, write the
status line under the title, with today's date and the short HEAD commit:
Status: cases approved <date> at <commit>. From then on, a case changes only
with the user: a wrong case is a decision change.
On approval, continue with /sdd:solo-building-from-cases for solo, or
/sdd:team-workflow for team.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mtch3n/trellis --plugin sdd7 skills in this plugin
/releasing-migrationsThe user merges the draft migrations written during development into numbered migrations, once, right before tagging a release, and runs the migration checks./solo-building-from-casesUse when a story's cases are approved and one agent builds them - the user chose solo at the approval, or asks to implement an approved spec. Builds each case test-first with the case ID in the test name, never edits an approved case's test to make it pass, and writes migrations as drafts./systematic-debuggingUse when a bug is reported or a test fails unexpectedly, before proposing any fix - "debug this", "why is this failing", "it's broken", a regression, a flaky test, or a slow path. Registers a loop that goes red on the bug by script first, ranks falsifiable hypotheses, counts failed fixes by script and stops at three, bisects when a good version exists, and turns the fixed bug into a case.Other plugins' skills for the same job