|
| 1 | +--- |
| 2 | +name: spec |
| 3 | +preamble-tier: 4 |
| 4 | +version: 1.0.0 |
| 5 | +description: | |
| 6 | + Produce a structured spec document (docs/specs/<slug>.md) for the active |
| 7 | + intent — the contract /pursue will execute against. Goal, Inputs, Outputs, |
| 8 | + Behavior, Edge cases, Test matrix, Out of scope. Inspired by the |
| 9 | + Superpowers methodology (~150K stars). The missing rung between |
| 10 | + /office-hours and code. (fstack) |
| 11 | +allowed-tools: |
| 12 | + - Bash |
| 13 | + - Read |
| 14 | + - Write |
| 15 | + - Edit |
| 16 | + - Grep |
| 17 | + - Glob |
| 18 | + - AskUserQuestion |
| 19 | +triggers: |
| 20 | + - spec |
| 21 | + - write a spec |
| 22 | + - spec it out |
| 23 | + - design doc |
| 24 | + - feature spec |
| 25 | +--- |
| 26 | + |
| 27 | +## What this does |
| 28 | + |
| 29 | +Reads the **active intent** for the current branch and expands it into a |
| 30 | +structured spec document at `docs/specs/<slug>.md`. The spec becomes the |
| 31 | +contract that `/pursue` (or you, manually) executes against. |
| 32 | + |
| 33 | +Without a spec, the agent fills in the contract implicitly — and that's |
| 34 | +where it builds the wrong thing perfectly. The spec is what prevents that. |
| 35 | + |
| 36 | +## When to invoke |
| 37 | + |
| 38 | +- After `/office-hours` produces a wedge agreement → before code starts |
| 39 | +- Right before `/pursue` for any non-trivial feature (multi-file, branching |
| 40 | + logic, anything where "done" needs definition) |
| 41 | +- When promoting a `/idea` to an active intent that's complex enough to |
| 42 | + warrant the structured form |
| 43 | + |
| 44 | +Skip `/spec` for trivial features ("fix typo," "rename variable," "bump |
| 45 | +dependency"). Use it when the spec is non-obvious. |
| 46 | + |
| 47 | +## Procedure |
| 48 | + |
| 49 | +### Step 1 — load context |
| 50 | + |
| 51 | +```bash |
| 52 | +fstack-brain intent get # active intent for current branch |
| 53 | +fstack-brain decide search --query "<keywords from intent title>" |
| 54 | +``` |
| 55 | + |
| 56 | +If no active intent → propose the user run `/office-hours` or `/intent` |
| 57 | +first. Do NOT spec a feature with no intent — the intent IS the seed. |
| 58 | + |
| 59 | +### Step 2 — codebase scan (boil-the-lake) |
| 60 | + |
| 61 | +Heuristic, capped at ~10 files. Same pattern as /office-hours: |
| 62 | +- Keyword grep on the intent title |
| 63 | +- Read top hits' structure |
| 64 | +- Note existing abstractions you'd extend vs duplicate |
| 65 | + |
| 66 | +### Step 3 — draft the spec sections |
| 67 | + |
| 68 | +Produce a markdown doc with these 7 sections, in this order: |
| 69 | + |
| 70 | +```markdown |
| 71 | +# Spec: <feature title from intent> |
| 72 | + |
| 73 | +**Intent:** <intent UUID short> |
| 74 | +**Status:** draft |
| 75 | +**Author:** <agent_id> |
| 76 | +**Date:** YYYY-MM-DD |
| 77 | + |
| 78 | +## Goal |
| 79 | +One paragraph. What changes for the user when this ships? What's the metric |
| 80 | +of success? Cite the related decision(s) by number if they constrained scope. |
| 81 | + |
| 82 | +## Inputs |
| 83 | +Bulleted list. For each input: name, type, source, validation rules. |
| 84 | + |
| 85 | +## Outputs |
| 86 | +For each output: HTTP status / return type / side effect, with body shape |
| 87 | +when applicable. Be explicit about success AND failure outputs. |
| 88 | + |
| 89 | +## Behavior |
| 90 | +Numbered list of the steps the system performs end-to-end. Reference |
| 91 | +existing code by file:function when extending. |
| 92 | + |
| 93 | +## Edge cases |
| 94 | +At least 5. Real ones from the codebase scan, not generic. For each: what |
| 95 | +input triggers it, what's the expected behavior. |
| 96 | + |
| 97 | +## Test matrix |
| 98 | +Markdown table with columns: # | Scenario | Input | Expected. One row per |
| 99 | +test the agent must produce. /pursue runs through this matrix as its |
| 100 | +acceptance gate. |
| 101 | + |
| 102 | +## Out of scope |
| 103 | +Bulleted list. What this spec EXPLICITLY does not cover. Cite related |
| 104 | +intents (other agent's work) or deferred decisions when relevant. |
| 105 | +``` |
| 106 | + |
| 107 | +### Step 4 — confirm key edge cases via AskUserQuestion |
| 108 | + |
| 109 | +After drafting, surface 2-4 questions where YOUR best guess at the spec |
| 110 | +might diverge from the user's intent. Examples: |
| 111 | +- "On invalid input — return 400 with field errors, or just 422 generic?" |
| 112 | +- "Per-IP or per-user rate limit? (you said per-IP in /office-hours, confirm?)" |
| 113 | +- "Behind a proxy — use X-Forwarded-For first hop or last hop?" |
| 114 | + |
| 115 | +Three questions max. If you have more, you didn't /office-hours hard enough. |
| 116 | + |
| 117 | +### Step 5 — write the file + update the intent |
| 118 | + |
| 119 | +```bash |
| 120 | +mkdir -p docs/specs |
| 121 | +# write the spec |
| 122 | +cat > docs/specs/<slug>.md <<'EOF' |
| 123 | +... |
| 124 | +EOF |
| 125 | +``` |
| 126 | + |
| 127 | +Then update the active intent's body to reference the spec: |
| 128 | +```bash |
| 129 | +fstack-brain intent write \ |
| 130 | + --title "<keep the existing title>" \ |
| 131 | + --body "<existing body>\n\n[spec: docs/specs/<slug>.md]" \ |
| 132 | + --promises "<existing promises>" \ |
| 133 | + --not-touching "<existing not-touching>" |
| 134 | +``` |
| 135 | + |
| 136 | +(Re-writing replaces the active intent — preserve all original fields, |
| 137 | +only append the spec link to body.) |
| 138 | + |
| 139 | +### Step 6 — confirm + handoff to /pursue |
| 140 | + |
| 141 | +Print: |
| 142 | +``` |
| 143 | +Spec written: docs/specs/<slug>.md |
| 144 | +Intent updated to reference it. |
| 145 | +
|
| 146 | +Next step: |
| 147 | + • /pursue — autonomous build against this spec |
| 148 | + • or: edit the spec manually if anything looks off |
| 149 | +``` |
| 150 | + |
| 151 | +## What this skill must NOT do |
| 152 | + |
| 153 | +- Must NOT produce a spec without an active intent. Hard-fail with "run |
| 154 | + /office-hours or /intent first." |
| 155 | +- Must NOT skip the test matrix. /pursue treats the matrix as its gate. |
| 156 | + Empty matrix = /pursue has no completion signal. |
| 157 | +- Must NOT duplicate /office-hours. /office-hours is brainstorming (should |
| 158 | + we?). /spec is execution contract (how exactly). |
| 159 | +- Must NOT ask more than 3-4 confirmation questions. If you need more, |
| 160 | + the upstream brainstorm wasn't deep enough — say so and propose |
| 161 | + /office-hours instead of belaboring spec. |
| 162 | +- Must NOT propose features beyond the active intent's scope. The spec |
| 163 | + expands the intent, doesn't redefine it. |
| 164 | + |
| 165 | +## Output |
| 166 | + |
| 167 | +Spec file written + intent updated + 2-line confirmation. ~5-10 min total. |
0 commit comments