spec-gen-cli 1.2.6 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -55
- package/dist/api/analyze.d.ts.map +1 -1
- package/dist/api/analyze.js +6 -1
- package/dist/api/analyze.js.map +1 -1
- package/dist/api/audit.d.ts +10 -0
- package/dist/api/audit.d.ts.map +1 -0
- package/dist/api/audit.js +117 -0
- package/dist/api/audit.js.map +1 -0
- package/dist/api/generate.d.ts.map +1 -1
- package/dist/api/generate.js +10 -1
- package/dist/api/generate.js.map +1 -1
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/run.d.ts.map +1 -1
- package/dist/api/run.js +5 -1
- package/dist/api/run.js.map +1 -1
- package/dist/api/types.d.ts +15 -4
- package/dist/api/types.d.ts.map +1 -1
- package/dist/cli/commands/analyze.d.ts +3 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +112 -17
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/audit.d.ts.map +1 -0
- package/dist/cli/commands/audit.js +98 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/drift.d.ts.map +1 -1
- package/dist/cli/commands/drift.js +8 -10
- package/dist/cli/commands/drift.js.map +1 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +15 -37
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts +102 -2
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +134 -2
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +9 -47
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +17 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +201 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/verify.d.ts.map +1 -1
- package/dist/cli/commands/verify.js +7 -8
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/index.js +14 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/constants.d.ts +14 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/analyzer/ai-config-generator.d.ts +54 -0
- package/dist/core/analyzer/ai-config-generator.d.ts.map +1 -0
- package/dist/core/analyzer/ai-config-generator.js +85 -0
- package/dist/core/analyzer/ai-config-generator.js.map +1 -0
- package/dist/core/analyzer/artifact-generator.d.ts +27 -2
- package/dist/core/analyzer/artifact-generator.d.ts.map +1 -1
- package/dist/core/analyzer/artifact-generator.js +86 -8
- package/dist/core/analyzer/artifact-generator.js.map +1 -1
- package/dist/core/analyzer/codebase-digest.d.ts.map +1 -1
- package/dist/core/analyzer/codebase-digest.js +12 -11
- package/dist/core/analyzer/codebase-digest.js.map +1 -1
- package/dist/core/analyzer/env-extractor.d.ts +33 -0
- package/dist/core/analyzer/env-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/env-extractor.js +196 -0
- package/dist/core/analyzer/env-extractor.js.map +1 -0
- package/dist/core/analyzer/http-route-parser.d.ts +36 -1
- package/dist/core/analyzer/http-route-parser.d.ts.map +1 -1
- package/dist/core/analyzer/http-route-parser.js +276 -0
- package/dist/core/analyzer/http-route-parser.js.map +1 -1
- package/dist/core/analyzer/middleware-extractor.d.ts +29 -0
- package/dist/core/analyzer/middleware-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/middleware-extractor.js +195 -0
- package/dist/core/analyzer/middleware-extractor.js.map +1 -0
- package/dist/core/analyzer/schema-extractor.d.ts +41 -0
- package/dist/core/analyzer/schema-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/schema-extractor.js +229 -0
- package/dist/core/analyzer/schema-extractor.js.map +1 -0
- package/dist/core/analyzer/spec-snapshot-generator.d.ts +17 -0
- package/dist/core/analyzer/spec-snapshot-generator.d.ts.map +1 -0
- package/dist/core/analyzer/spec-snapshot-generator.js +201 -0
- package/dist/core/analyzer/spec-snapshot-generator.js.map +1 -0
- package/dist/core/analyzer/ui-component-extractor.d.ts +43 -0
- package/dist/core/analyzer/ui-component-extractor.d.ts.map +1 -0
- package/dist/core/analyzer/ui-component-extractor.js +245 -0
- package/dist/core/analyzer/ui-component-extractor.js.map +1 -0
- package/dist/core/generator/openspec-format-generator.d.ts.map +1 -1
- package/dist/core/generator/openspec-format-generator.js +8 -0
- package/dist/core/generator/openspec-format-generator.js.map +1 -1
- package/dist/core/generator/spec-pipeline.d.ts +9 -0
- package/dist/core/generator/spec-pipeline.d.ts.map +1 -1
- package/dist/core/generator/spec-pipeline.js +94 -2
- package/dist/core/generator/spec-pipeline.js.map +1 -1
- package/dist/core/generator/stages/stage1-survey.d.ts.map +1 -1
- package/dist/core/generator/stages/stage1-survey.js +43 -0
- package/dist/core/generator/stages/stage1-survey.js.map +1 -1
- package/dist/core/generator/stages/stage2-entities.d.ts.map +1 -1
- package/dist/core/generator/stages/stage2-entities.js +6 -2
- package/dist/core/generator/stages/stage2-entities.js.map +1 -1
- package/dist/core/generator/stages/stage3-services.d.ts.map +1 -1
- package/dist/core/generator/stages/stage3-services.js +9 -2
- package/dist/core/generator/stages/stage3-services.js.map +1 -1
- package/dist/core/generator/stages/stage4-api.d.ts.map +1 -1
- package/dist/core/generator/stages/stage4-api.js +6 -2
- package/dist/core/generator/stages/stage4-api.js.map +1 -1
- package/dist/core/services/llm-service.d.ts +26 -10
- package/dist/core/services/llm-service.d.ts.map +1 -1
- package/dist/core/services/llm-service.js +171 -16
- package/dist/core/services/llm-service.js.map +1 -1
- package/dist/core/services/mcp-handlers/analysis.d.ts +32 -1
- package/dist/core/services/mcp-handlers/analysis.d.ts.map +1 -1
- package/dist/core/services/mcp-handlers/analysis.js +185 -2
- package/dist/core/services/mcp-handlers/analysis.js.map +1 -1
- package/dist/core/verifier/verification-engine.d.ts +67 -6
- package/dist/core/verifier/verification-engine.d.ts.map +1 -1
- package/dist/core/verifier/verification-engine.js +316 -90
- package/dist/core/verifier/verification-engine.js.map +1 -1
- package/dist/types/index.d.ts +70 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pipeline.d.ts +9 -0
- package/dist/types/pipeline.d.ts.map +1 -1
- package/dist/utils/command-helpers.d.ts +30 -0
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +69 -1
- package/dist/utils/command-helpers.js.map +1 -1
- package/examples/bmad/README.md +113 -0
- package/examples/bmad/agents/architect.md +226 -0
- package/examples/bmad/agents/dev-brownfield.md +69 -0
- package/examples/bmad/setup/architect.customize.yaml +14 -0
- package/examples/bmad/tasks/implement-story.md +254 -0
- package/examples/bmad/tasks/onboarding.md +169 -0
- package/examples/bmad/tasks/refactor.md +178 -0
- package/examples/bmad/tasks/sprint-planning.md +168 -0
- package/examples/bmad/templates/story.md +108 -0
- package/examples/cline-workflows/spec-gen-analyze-codebase.md +100 -0
- package/examples/cline-workflows/spec-gen-check-spec-drift.md +102 -0
- package/examples/cline-workflows/spec-gen-execute-refactor.md +194 -0
- package/examples/cline-workflows/spec-gen-implement-feature.md +238 -0
- package/examples/cline-workflows/spec-gen-plan-refactor.md +255 -0
- package/examples/cline-workflows/spec-gen-refactor-codebase.md +16 -0
- package/examples/drift-demo/openspec/config.yaml +14 -0
- package/examples/drift-demo/openspec/specs/architecture/spec.md +30 -0
- package/examples/drift-demo/openspec/specs/auth/spec.md +71 -0
- package/examples/drift-demo/openspec/specs/database/spec.md +33 -0
- package/examples/drift-demo/openspec/specs/overview/spec.md +20 -0
- package/examples/drift-demo/openspec/specs/projects/spec.md +55 -0
- package/examples/drift-demo/openspec/specs/tasks/spec.md +78 -0
- package/examples/drift-demo/package.json +21 -0
- package/examples/drift-demo/src/auth/auth-middleware.ts +30 -0
- package/examples/drift-demo/src/auth/auth-routes.ts +29 -0
- package/examples/drift-demo/src/auth/auth-service.ts +45 -0
- package/examples/drift-demo/src/database/connection.ts +27 -0
- package/examples/drift-demo/src/index.ts +16 -0
- package/examples/drift-demo/src/projects/project-model.ts +15 -0
- package/examples/drift-demo/src/projects/project-service.ts +34 -0
- package/examples/drift-demo/src/tasks/task-model.ts +37 -0
- package/examples/drift-demo/src/tasks/task-routes.ts +53 -0
- package/examples/drift-demo/src/tasks/task-service.ts +60 -0
- package/examples/drift-demo/src/utils/validation.ts +11 -0
- package/examples/drift-demo/tests/auth.test.ts +4 -0
- package/examples/drift-demo/tests/tasks.test.ts +4 -0
- package/examples/drift-demo/tsconfig.json +10 -0
- package/examples/drift-test/run-drift-test.sh +1087 -0
- package/examples/gsd/README.md +119 -0
- package/examples/gsd/commands/gsd/spec-gen-drift.md +111 -0
- package/examples/gsd/commands/gsd/spec-gen-orient.md +191 -0
- package/examples/mistral-vibe/README.md +101 -0
- package/examples/mistral-vibe/antipatterns-template.md +18 -0
- package/examples/mistral-vibe/skills/spec-gen-analyze-codebase/SKILL.md +123 -0
- package/examples/mistral-vibe/skills/spec-gen-brainstorm/SKILL.md +379 -0
- package/examples/mistral-vibe/skills/spec-gen-debug/SKILL.md +320 -0
- package/examples/mistral-vibe/skills/spec-gen-execute-refactor/SKILL.md +210 -0
- package/examples/mistral-vibe/skills/spec-gen-generate/SKILL.md +245 -0
- package/examples/mistral-vibe/skills/spec-gen-implement-story/SKILL.md +274 -0
- package/examples/mistral-vibe/skills/spec-gen-plan-refactor/SKILL.md +251 -0
- package/examples/openspec-analysis/README.md +59 -0
- package/examples/openspec-analysis/SUMMARY.md +72 -0
- package/examples/openspec-analysis/config.json +16 -0
- package/examples/openspec-analysis/dependencies.mermaid +35 -0
- package/examples/openspec-analysis/dependency-graph.json +12116 -0
- package/examples/openspec-analysis/llm-context.json +119 -0
- package/examples/openspec-analysis/repo-structure.json +871 -0
- package/examples/openspec-cli/README.md +67 -0
- package/examples/openspec-cli/openspec/config.yaml +26 -0
- package/examples/openspec-cli/openspec/specs/architecture/spec.md +178 -0
- package/examples/openspec-cli/openspec/specs/artifact-graph/spec.md +143 -0
- package/examples/openspec-cli/openspec/specs/cli/spec.md +138 -0
- package/examples/openspec-cli/openspec/specs/overview/spec.md +60 -0
- package/examples/openspec-cli/openspec/specs/parsing/spec.md +123 -0
- package/examples/openspec-cli/openspec/specs/validation/spec.md +108 -0
- package/examples/spec-kit/README.md +104 -0
- package/examples/spec-kit/commands/drift.md +87 -0
- package/examples/spec-kit/commands/orient.md +138 -0
- package/examples/spec-kit/extension.yml +54 -0
- package/package.json +3 -6
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec-gen-brainstorm
|
|
3
|
+
description: Transform a feature idea into an annotated story. Detects greenfield vs brownfield automatically — uses Domain Sketch for greenfield (no existing code), Constrained Option Tree for brownfield (existing codebase with spec-gen analysis).
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: spec-gen MCP server
|
|
6
|
+
user-invocable: true
|
|
7
|
+
allowed-tools:
|
|
8
|
+
- ask_followup_question
|
|
9
|
+
- use_mcp_tool
|
|
10
|
+
- read_file
|
|
11
|
+
- write_file
|
|
12
|
+
- str_replace_based_edit
|
|
13
|
+
- run_command
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# spec-gen: Brainstorm
|
|
17
|
+
|
|
18
|
+
## When to use this skill
|
|
19
|
+
|
|
20
|
+
Trigger this skill when the user wants to **explore or design a new feature** before
|
|
21
|
+
writing any code, with phrasings like:
|
|
22
|
+
- "I want to add feature X"
|
|
23
|
+
- "how should I approach this?"
|
|
24
|
+
- "let's brainstorm this story"
|
|
25
|
+
- explicit command `/spec-gen-brainstorm`
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Step 1 — Detect mode
|
|
30
|
+
|
|
31
|
+
Capture `$PROJECT_ROOT`, `$FEATURE_DESCRIPTION`, and
|
|
32
|
+
`$FEATURE_SLUG` (kebab-case, ≤ 5 words, e.g. `payment-retry-flow`).
|
|
33
|
+
|
|
34
|
+
Then probe the structural index:
|
|
35
|
+
|
|
36
|
+
```xml
|
|
37
|
+
<use_mcp_tool>
|
|
38
|
+
<server_name>spec-gen</server_name>
|
|
39
|
+
<tool_name>orient</tool_name>
|
|
40
|
+
<arguments>{
|
|
41
|
+
"directory": "$PROJECT_ROOT",
|
|
42
|
+
"task": "$FEATURE_DESCRIPTION",
|
|
43
|
+
"limit": 7
|
|
44
|
+
}</arguments>
|
|
45
|
+
</use_mcp_tool>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Set `$MODE` based on the result:
|
|
49
|
+
|
|
50
|
+
| Result | `$MODE` | Meaning |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| Returns functions with score > 0 | `brownfield` | Existing indexed codebase |
|
|
53
|
+
| Returns `"error": "no cache"` or 0 functions | `greenfield` | No structural index yet |
|
|
54
|
+
|
|
55
|
+
Inform the user:
|
|
56
|
+
- Brownfield: "I found existing code related to this feature. Using structural analysis to guide design."
|
|
57
|
+
- Greenfield: "No structural index found. Using Domain Sketch — structural analysis will be available after `spec-gen analyze` is run on the first implementation."
|
|
58
|
+
|
|
59
|
+
**Load project antipatterns (both modes):**
|
|
60
|
+
|
|
61
|
+
If `.claude/antipatterns.md` exists, read it and store as `$ANTIPATTERNS`.
|
|
62
|
+
These will be used as a failure mode source in Step 5. If absent, `$ANTIPATTERNS = none`.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Steps 2–4 — Structural analysis (brownfield only)
|
|
67
|
+
|
|
68
|
+
*Skip to Step 5 if `$MODE = greenfield`.*
|
|
69
|
+
|
|
70
|
+
### Step 2 — Architecture overview
|
|
71
|
+
|
|
72
|
+
```xml
|
|
73
|
+
<use_mcp_tool>
|
|
74
|
+
<server_name>spec-gen</server_name>
|
|
75
|
+
<tool_name>get_architecture_overview</tool_name>
|
|
76
|
+
<arguments>{"directory": "$PROJECT_ROOT"}</arguments>
|
|
77
|
+
</use_mcp_tool>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Note hub functions and cross-domain dependencies in `$DOMAINS_AFFECTED`.
|
|
81
|
+
|
|
82
|
+
### Step 3 — Generate change proposal
|
|
83
|
+
|
|
84
|
+
```xml
|
|
85
|
+
<use_mcp_tool>
|
|
86
|
+
<server_name>spec-gen</server_name>
|
|
87
|
+
<tool_name>generate_change_proposal</tool_name>
|
|
88
|
+
<arguments>{
|
|
89
|
+
"directory": "$PROJECT_ROOT",
|
|
90
|
+
"description": "$FEATURE_DESCRIPTION",
|
|
91
|
+
"slug": "$FEATURE_SLUG"
|
|
92
|
+
}</arguments>
|
|
93
|
+
</use_mcp_tool>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Chains `orient` + `search_specs` + `analyze_impact` and writes
|
|
97
|
+
`openspec/changes/$FEATURE_SLUG/proposal.md`.
|
|
98
|
+
|
|
99
|
+
Extract:
|
|
100
|
+
- **`$MAX_RISK_SCORE`** — overall risk level
|
|
101
|
+
- **`$REQUIREMENTS_TOUCHED`** — existing requirements this feature overlaps
|
|
102
|
+
- **`$BLOCKING_REFACTORS`** — functions with risk ≥ 70
|
|
103
|
+
|
|
104
|
+
### Step 4 — Risk gate
|
|
105
|
+
|
|
106
|
+
| Score | Action |
|
|
107
|
+
|---|---|
|
|
108
|
+
| 🟢 < 40 | Proceed to Step 5 |
|
|
109
|
+
| 🟡 40–69 | Proceed, flag impacted callers to protect during design |
|
|
110
|
+
| 🔴 ≥ 70 | Stop — propose a blocking refactor story before continuing |
|
|
111
|
+
|
|
112
|
+
If blocked:
|
|
113
|
+
> "This feature touches `$BLOCKING_FUNCTION` (risk score: $SCORE).
|
|
114
|
+
> A refactor story must be completed first. I can create it now if you'd like."
|
|
115
|
+
|
|
116
|
+
Do not continue until the user accepts the refactor story or explicitly overrides.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Step 5 — Brainstorming
|
|
121
|
+
|
|
122
|
+
### If `$MODE = brownfield` — Constrained Option Tree
|
|
123
|
+
|
|
124
|
+
**5a — Establish the constraint space**
|
|
125
|
+
|
|
126
|
+
Derive from Steps 2–4 and present before generating options:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
Hard constraints (non-negotiable):
|
|
130
|
+
- Functions with riskScore ≥ 70: $BLOCKED_FUNCTIONS
|
|
131
|
+
- Requirements that must be preserved: $REQUIREMENTS_TOUCHED
|
|
132
|
+
- Domain boundaries that must not be crossed: $DOMAIN_BOUNDARIES
|
|
133
|
+
|
|
134
|
+
Soft constraints (preferred):
|
|
135
|
+
- Existing insertion points: $INSERTION_POINTS
|
|
136
|
+
- Patterns already used in $DOMAINS_AFFECTED
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Ask: "Are there additional constraints before we explore approaches?"
|
|
140
|
+
|
|
141
|
+
**5b — Generate 2–3 options**
|
|
142
|
+
|
|
143
|
+
Each option must respect hard constraints. Name them clearly
|
|
144
|
+
(e.g. Option A — Extend existing, Option B — New service, Option C — Facade).
|
|
145
|
+
|
|
146
|
+
If `$ANTIPATTERNS ≠ none`, cross-check each option against the list.
|
|
147
|
+
Flag any option that would reproduce a known failure pattern with ⚠ and the relevant AP-NNN.
|
|
148
|
+
|
|
149
|
+
| | Option A | Option B | Option C |
|
|
150
|
+
|---|---|---|---|
|
|
151
|
+
| Insertion point | | | |
|
|
152
|
+
| Domains touched | | | |
|
|
153
|
+
| Risk score impact | | | |
|
|
154
|
+
| Requirements affected | | | |
|
|
155
|
+
| Estimated scope (files) | | | |
|
|
156
|
+
| Trade-off | | | |
|
|
157
|
+
|
|
158
|
+
**5c — Recommend**
|
|
159
|
+
|
|
160
|
+
State one recommendation with a single structural reason:
|
|
161
|
+
|
|
162
|
+
> "Recommend Option B — inserts at `$SAFE_FUNCTION` (risk 18), avoids `$HUB`
|
|
163
|
+
> (fan-in 14) entirely. Option A is valid but adds unnecessary blast radius."
|
|
164
|
+
|
|
165
|
+
**5d — Confirm**
|
|
166
|
+
|
|
167
|
+
Do not proceed to Step 5e until the user chooses. If they want a hybrid,
|
|
168
|
+
produce a revised option table.
|
|
169
|
+
|
|
170
|
+
**5e — Adversarial challenge**
|
|
171
|
+
|
|
172
|
+
Before writing the story, switch roles: challenge the chosen option as a skeptic.
|
|
173
|
+
|
|
174
|
+
State exactly 2 failure modes grounded in the structural data and, if `$ANTIPATTERNS ≠ none`,
|
|
175
|
+
any applicable antipatterns from `.claude/antipatterns.md`:
|
|
176
|
+
|
|
177
|
+
> "Devil's advocate on Option B:
|
|
178
|
+
> 1. `$CALLER_A` calls `$INSERTION_POINT` with `$EDGE_CASE` — this path is not covered
|
|
179
|
+
> by the proposed approach and could silently break.
|
|
180
|
+
> 2. The proposal scores risk at $SCORE but `$HUB` (fan-in $N) is one hop away —
|
|
181
|
+
> a regression there would not be caught until `check_spec_drift`."
|
|
182
|
+
|
|
183
|
+
Then ask the user: "Do these failure modes change your choice, or should we add
|
|
184
|
+
mitigations to the story constraints?"
|
|
185
|
+
|
|
186
|
+
Only proceed to Step 6 once the user has acknowledged the failure modes.
|
|
187
|
+
Mitigations go into `## Technical Constraints` in the story.
|
|
188
|
+
|
|
189
|
+
> Note: this IS a gate (waits for user input) because brainstorm is a design phase
|
|
190
|
+
> where changing course is cheap. In contrast, `spec-gen-implement-story` Step 4b
|
|
191
|
+
> is a mandatory self-check that does NOT gate — because by implementation time
|
|
192
|
+
> the design decision is already made.
|
|
193
|
+
|
|
194
|
+
Ask: "What is explicitly out of scope for this story?" List the answers as `$WONT_DO`.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### If `$MODE = greenfield` — Domain Sketch
|
|
199
|
+
|
|
200
|
+
No existing structure to constrain — the method builds the structure from scratch.
|
|
201
|
+
|
|
202
|
+
**5a — Entities**
|
|
203
|
+
|
|
204
|
+
Ask the user: "What are the core data objects this feature creates or transforms?"
|
|
205
|
+
|
|
206
|
+
List them as nouns with a one-line definition each:
|
|
207
|
+
```
|
|
208
|
+
$ENTITY_1 — definition
|
|
209
|
+
$ENTITY_2 — definition
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**5b — Operations**
|
|
213
|
+
|
|
214
|
+
For each entity, identify the operations the feature needs (create, read,
|
|
215
|
+
transform, delete, emit, receive…):
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
$ENTITY_1: $OP_1, $OP_2
|
|
219
|
+
$ENTITY_2: $OP_1
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Identify which operations cross a system boundary (external API, database,
|
|
223
|
+
event bus, CLI…) — these are the riskiest integration points.
|
|
224
|
+
|
|
225
|
+
**5c — Boundaries**
|
|
226
|
+
|
|
227
|
+
Define where the feature sits relative to the system:
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
Entry point: $HOW_IT_IS_TRIGGERED (HTTP request / CLI command / event / cron)
|
|
231
|
+
Data in: $INPUT_FORMAT
|
|
232
|
+
Data out: $OUTPUT_FORMAT or side-effects
|
|
233
|
+
External deps: $THIRD_PARTY_SERVICES or "none"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**5d — Architecture decisions**
|
|
237
|
+
|
|
238
|
+
State 2–3 decisions that must be made before coding. For each, list the options
|
|
239
|
+
and a recommendation:
|
|
240
|
+
|
|
241
|
+
| Decision | Options | Recommendation |
|
|
242
|
+
|---|---|---|
|
|
243
|
+
| e.g. Storage | in-memory / DB / file | DB — survives restarts |
|
|
244
|
+
| e.g. Coupling | new module / extend existing | new module — clear boundary |
|
|
245
|
+
|
|
246
|
+
Ask the user to confirm or override each decision before proceeding to Step 6.
|
|
247
|
+
|
|
248
|
+
Ask: "What is explicitly out of scope for this story?" List the answers as `$WONT_DO`.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Step 6 — Write the story
|
|
253
|
+
|
|
254
|
+
Produce a story file at `$STORIES_DIR/$FEATURE_SLUG.md`.
|
|
255
|
+
|
|
256
|
+
If a story template exists at `$PROJECT_ROOT/_bmad/spec-gen/templates/story.md`
|
|
257
|
+
or `$PROJECT_ROOT/examples/bmad/templates/story.md`, use it. Otherwise:
|
|
258
|
+
|
|
259
|
+
**Brownfield template:**
|
|
260
|
+
|
|
261
|
+
```markdown
|
|
262
|
+
# $STORY_TITLE
|
|
263
|
+
|
|
264
|
+
## Goal
|
|
265
|
+
|
|
266
|
+
$FEATURE_DESCRIPTION
|
|
267
|
+
|
|
268
|
+
## Acceptance Criteria
|
|
269
|
+
|
|
270
|
+
Each AC must be verifiable by a test. State the observable outcome, not the intent.
|
|
271
|
+
✗ "Should handle errors correctly" — ✓ "Returns HTTP 400 with `{error: 'X'}` when Y is absent"
|
|
272
|
+
|
|
273
|
+
- [ ] $AC_1
|
|
274
|
+
- [ ] $AC_2
|
|
275
|
+
|
|
276
|
+
## Won't Do
|
|
277
|
+
|
|
278
|
+
- $WONT_DO_1
|
|
279
|
+
- $WONT_DO_2
|
|
280
|
+
|
|
281
|
+
## Risk Context
|
|
282
|
+
|
|
283
|
+
<!-- Filled by annotate_story in Step 7 -->
|
|
284
|
+
|
|
285
|
+
## Technical Constraints
|
|
286
|
+
|
|
287
|
+
$BLOCKING_REFACTORS and caller protection notes from the proposal.
|
|
288
|
+
|
|
289
|
+
## Notes
|
|
290
|
+
|
|
291
|
+
- Chosen approach: $CHOSEN_OPTION — $TRADE_OFF
|
|
292
|
+
- Domains affected: $DOMAINS_AFFECTED
|
|
293
|
+
- Requirements touched: $REQUIREMENTS_TOUCHED
|
|
294
|
+
- Max risk score: $MAX_RISK_SCORE
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Greenfield template:**
|
|
298
|
+
|
|
299
|
+
```markdown
|
|
300
|
+
# $STORY_TITLE
|
|
301
|
+
|
|
302
|
+
## Goal
|
|
303
|
+
|
|
304
|
+
$FEATURE_DESCRIPTION
|
|
305
|
+
|
|
306
|
+
## Acceptance Criteria
|
|
307
|
+
|
|
308
|
+
Each AC must be verifiable by a test. State the observable outcome, not the intent.
|
|
309
|
+
✗ "Should handle errors correctly" — ✓ "Returns HTTP 400 with `{error: 'X'}` when Y is absent"
|
|
310
|
+
|
|
311
|
+
- [ ] $AC_1
|
|
312
|
+
- [ ] $AC_2
|
|
313
|
+
|
|
314
|
+
## Won't Do
|
|
315
|
+
|
|
316
|
+
- $WONT_DO_1
|
|
317
|
+
- $WONT_DO_2
|
|
318
|
+
|
|
319
|
+
## Domain Sketch
|
|
320
|
+
|
|
321
|
+
### Entities
|
|
322
|
+
$ENTITIES
|
|
323
|
+
|
|
324
|
+
### Operations
|
|
325
|
+
$OPERATIONS
|
|
326
|
+
|
|
327
|
+
### Boundaries
|
|
328
|
+
$BOUNDARIES
|
|
329
|
+
|
|
330
|
+
## Architecture Decisions
|
|
331
|
+
|
|
332
|
+
$DECISIONS_TABLE
|
|
333
|
+
|
|
334
|
+
## Notes
|
|
335
|
+
|
|
336
|
+
- First implementation — run `spec-gen analyze && spec-gen generate` after
|
|
337
|
+
to enable structural analysis for future stories.
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Step 7 — Annotate the story
|
|
343
|
+
|
|
344
|
+
**Brownfield only.** Skip if `$MODE = greenfield`.
|
|
345
|
+
|
|
346
|
+
```xml
|
|
347
|
+
<use_mcp_tool>
|
|
348
|
+
<server_name>spec-gen</server_name>
|
|
349
|
+
<tool_name>annotate_story</tool_name>
|
|
350
|
+
<arguments>{
|
|
351
|
+
"directory": "$PROJECT_ROOT",
|
|
352
|
+
"storyFilePath": "$STORY_FILE_PATH",
|
|
353
|
+
"description": "$STORY_TITLE"
|
|
354
|
+
}</arguments>
|
|
355
|
+
</use_mcp_tool>
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Patches `## Risk Context` directly. Story is now ready for `spec-gen-implement-story`.
|
|
359
|
+
|
|
360
|
+
**Greenfield:** confirm to the user:
|
|
361
|
+
> "Story written to `$STORY_FILE_PATH`. No risk context yet — run
|
|
362
|
+
> `spec-gen analyze` after the first implementation sprint to enable
|
|
363
|
+
> structural analysis for future stories."
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Absolute constraints
|
|
368
|
+
|
|
369
|
+
- Do not ask design questions before Step 5 (both modes)
|
|
370
|
+
- Brownfield: do not proceed past Step 4 if `$MAX_RISK_SCORE ≥ 70` without acknowledgement
|
|
371
|
+
- Brownfield: do not fill `## Risk Context` manually — always use `annotate_story`
|
|
372
|
+
- Greenfield: do not call `annotate_story` — there is nothing to annotate yet
|
|
373
|
+
- Do not propose implementation steps — this skill ends at story creation
|
|
374
|
+
- Every AC must be verifiable by a test — reject vague ACs ("should work", "handles errors") and rewrite them before proceeding
|
|
375
|
+
- `## Won't Do` is mandatory in the story — at minimum one item
|
|
376
|
+
- Brownfield: `generate_change_proposal` creates `openspec/changes/$FEATURE_SLUG/proposal.md`
|
|
377
|
+
on disk. Inform the user at session end:
|
|
378
|
+
"A proposal file was created at `openspec/changes/$FEATURE_SLUG/proposal.md`.
|
|
379
|
+
Delete it if this idea is not pursued."
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec-gen-debug
|
|
3
|
+
description: Debug a problem by anchoring root-cause analysis in spec-gen structural knowledge. Uses orient + search_specs + analyze_impact to form an explicit hypothesis before reading code. Enforces RED/GREEN test verification.
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: spec-gen MCP server
|
|
6
|
+
user-invocable: true
|
|
7
|
+
allowed-tools:
|
|
8
|
+
- ask_followup_question
|
|
9
|
+
- use_mcp_tool
|
|
10
|
+
- read_file
|
|
11
|
+
- write_file
|
|
12
|
+
- str_replace_based_edit
|
|
13
|
+
- replace_in_file
|
|
14
|
+
- run_command
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# spec-gen: Debug
|
|
18
|
+
|
|
19
|
+
## When to use this skill
|
|
20
|
+
|
|
21
|
+
Trigger this skill when the user reports **a bug or unexpected behaviour** on a codebase
|
|
22
|
+
that has spec-gen analysis available, with phrasings like:
|
|
23
|
+
- "this is broken"
|
|
24
|
+
- "X is not working"
|
|
25
|
+
- "something is wrong with Y"
|
|
26
|
+
- "debug this"
|
|
27
|
+
- explicit command `/spec-gen-debug`
|
|
28
|
+
|
|
29
|
+
**The rule**: form an explicit hypothesis before reading any code. Do not browse
|
|
30
|
+
files speculatively.
|
|
31
|
+
|
|
32
|
+
**Prerequisite**: spec-gen analysis must exist (`spec-gen analyze` has been run).
|
|
33
|
+
If `orient` returns `"error": "no cache"` → run `analyze_codebase` first, then retry.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Step 1 — Reproduce
|
|
38
|
+
|
|
39
|
+
Ask the user for:
|
|
40
|
+
1. **Steps to reproduce** — minimal sequence that triggers the bug
|
|
41
|
+
2. **Expected behaviour** — what should happen
|
|
42
|
+
3. **Observed behaviour** — what actually happens
|
|
43
|
+
4. **`$PROJECT_ROOT`** — project root directory
|
|
44
|
+
|
|
45
|
+
Do not proceed to Step 2 until all four are known.
|
|
46
|
+
|
|
47
|
+
If the user cannot reproduce the bug reliably, note it and proceed anyway — but
|
|
48
|
+
flag that the fix may be speculative until reproduction is confirmed.
|
|
49
|
+
|
|
50
|
+
Capture:
|
|
51
|
+
- `$BUG_DESCRIPTION` — one-line summary of the symptom (e.g. "payment retry does not reset counter after success")
|
|
52
|
+
- `$REPRO_STEPS` — reproduction sequence
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Step 2 — Orient
|
|
57
|
+
|
|
58
|
+
```xml
|
|
59
|
+
<use_mcp_tool>
|
|
60
|
+
<server_name>spec-gen</server_name>
|
|
61
|
+
<tool_name>orient</tool_name>
|
|
62
|
+
<arguments>{
|
|
63
|
+
"directory": "$PROJECT_ROOT",
|
|
64
|
+
"task": "$BUG_DESCRIPTION",
|
|
65
|
+
"limit": 7
|
|
66
|
+
}</arguments>
|
|
67
|
+
</use_mcp_tool>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Extract:
|
|
71
|
+
- **`$CANDIDATE_FUNCTIONS`** — top 3–5 functions structurally related to the symptom
|
|
72
|
+
- **`$DOMAINS_AFFECTED`** — spec domains involved
|
|
73
|
+
- **`$CALL_PATHS`** — call chains relevant to the symptom
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Step 3 — Search specs
|
|
78
|
+
|
|
79
|
+
If `openspec/specs/` exists:
|
|
80
|
+
|
|
81
|
+
```xml
|
|
82
|
+
<use_mcp_tool>
|
|
83
|
+
<server_name>spec-gen</server_name>
|
|
84
|
+
<tool_name>search_specs</tool_name>
|
|
85
|
+
<arguments>{
|
|
86
|
+
"directory": "$PROJECT_ROOT",
|
|
87
|
+
"query": "$BUG_DESCRIPTION",
|
|
88
|
+
"limit": 5
|
|
89
|
+
}</arguments>
|
|
90
|
+
</use_mcp_tool>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Look for:
|
|
94
|
+
- **Documented constraints** that the buggy behaviour violates
|
|
95
|
+
- **Requirements** that define what "correct" means for `$DOMAINS_AFFECTED`
|
|
96
|
+
- **Known edge cases** documented in the spec that may explain the symptom
|
|
97
|
+
|
|
98
|
+
If no specs exist, skip this step and note the absence.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Step 4 — Isolate and hypothesize
|
|
103
|
+
|
|
104
|
+
For the top 2 candidate functions from Step 2, check their structural properties:
|
|
105
|
+
|
|
106
|
+
```xml
|
|
107
|
+
<use_mcp_tool>
|
|
108
|
+
<server_name>spec-gen</server_name>
|
|
109
|
+
<tool_name>analyze_impact</tool_name>
|
|
110
|
+
<arguments>{
|
|
111
|
+
"directory": "$PROJECT_ROOT",
|
|
112
|
+
"symbol": "$CANDIDATE_FUNCTION",
|
|
113
|
+
"depth": 2
|
|
114
|
+
}</arguments>
|
|
115
|
+
</use_mcp_tool>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
If the repro involves a request flow (HTTP request, event, message queue), confirm the call chain before forming the hypothesis:
|
|
119
|
+
|
|
120
|
+
```xml
|
|
121
|
+
<use_mcp_tool>
|
|
122
|
+
<server_name>spec-gen</server_name>
|
|
123
|
+
<tool_name>trace_execution_path</tool_name>
|
|
124
|
+
<arguments>{
|
|
125
|
+
"directory": "$PROJECT_ROOT",
|
|
126
|
+
"from": "$ENTRY_POINT",
|
|
127
|
+
"to": "$CANDIDATE_FUNCTION"
|
|
128
|
+
}</arguments>
|
|
129
|
+
</use_mcp_tool>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This replaces speculative file browsing — the path is structural fact, not inference. Skip if `$ENTRY_POINT` is unknown or the repro is not request-driven.
|
|
133
|
+
|
|
134
|
+
Using the call paths, risk scores, spec constraints, and traced path gathered so far,
|
|
135
|
+
**state an explicit hypothesis before reading any code**:
|
|
136
|
+
|
|
137
|
+
> "Hypothesis: `$FUNCTION` does not reset `$STATE` when `$CONDITION` because
|
|
138
|
+
> it is called from `$CALLER` which does not pass `$PARAMETER`."
|
|
139
|
+
|
|
140
|
+
The hypothesis must:
|
|
141
|
+
- Name a specific function
|
|
142
|
+
- State a specific mechanism (state not reset, condition not checked, wrong caller, etc.)
|
|
143
|
+
- Be falsifiable by reading the code
|
|
144
|
+
|
|
145
|
+
**Do not read source files before forming this hypothesis.**
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Step 5 — Verify the hypothesis
|
|
150
|
+
|
|
151
|
+
Read the source of the hypothesised function(s):
|
|
152
|
+
|
|
153
|
+
```xml
|
|
154
|
+
<use_mcp_tool>
|
|
155
|
+
<server_name>spec-gen</server_name>
|
|
156
|
+
<tool_name>get_function_skeleton</tool_name>
|
|
157
|
+
<arguments>{
|
|
158
|
+
"directory": "$PROJECT_ROOT",
|
|
159
|
+
"filePath": "$TARGET_FILE"
|
|
160
|
+
}</arguments>
|
|
161
|
+
</use_mcp_tool>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Then read the full function body if needed.
|
|
165
|
+
|
|
166
|
+
| Result | Action |
|
|
167
|
+
|---|---|
|
|
168
|
+
| Hypothesis confirmed | Proceed to Step 6 |
|
|
169
|
+
| Hypothesis refuted | Return to Step 4 with a revised hypothesis (max 3 iterations before asking the user for more context) |
|
|
170
|
+
| Cause is in a caller, not the function itself | Extend `analyze_impact` one level up, revise hypothesis |
|
|
171
|
+
|
|
172
|
+
Document the confirmed hypothesis explicitly before writing any fix.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Step 6 — Fix
|
|
177
|
+
|
|
178
|
+
Apply the **minimal fix** that resolves the confirmed hypothesis.
|
|
179
|
+
|
|
180
|
+
Do not modify functions outside the scope identified in Steps 2–5 without
|
|
181
|
+
re-running the gate (`orient` + `analyze_impact`) on the new scope.
|
|
182
|
+
|
|
183
|
+
**Small model constraint**: each edit must touch a contiguous block of at most
|
|
184
|
+
50 lines. Split larger fixes into sequential edits.
|
|
185
|
+
|
|
186
|
+
Do not refactor, rename, or clean up unrelated code while fixing the bug.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Step 7 — Verify
|
|
191
|
+
|
|
192
|
+
**RED first (if no existing test covers this case):**
|
|
193
|
+
|
|
194
|
+
Write a test that reproduces the bug using `$REPRO_STEPS`. Run it. It must fail
|
|
195
|
+
(RED) — confirming the bug is real and the test is meaningful.
|
|
196
|
+
|
|
197
|
+
**Apply the fix**, then run the test again. It must pass (GREEN).
|
|
198
|
+
|
|
199
|
+
**Full suite:**
|
|
200
|
+
|
|
201
|
+
Run the full test suite. If any pre-existing test breaks, fix the regression
|
|
202
|
+
before closing the bug.
|
|
203
|
+
|
|
204
|
+
| Situation | Action |
|
|
205
|
+
|---|---|
|
|
206
|
+
| New test RED → fix → GREEN, suite green | Proceed to Step 8 |
|
|
207
|
+
| Cannot reproduce in a test | Note it, apply fix, confirm manually, add a note in the story/issue |
|
|
208
|
+
| Suite regression introduced | Fix regression. Do not proceed. |
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Step 8 — Drift check
|
|
213
|
+
|
|
214
|
+
Only if the fix changes a documented behaviour:
|
|
215
|
+
|
|
216
|
+
```xml
|
|
217
|
+
<use_mcp_tool>
|
|
218
|
+
<server_name>spec-gen</server_name>
|
|
219
|
+
<tool_name>check_spec_drift</tool_name>
|
|
220
|
+
<arguments>{"directory": "$PROJECT_ROOT"}</arguments>
|
|
221
|
+
</use_mcp_tool>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
| Drift type | Resolution |
|
|
225
|
+
|---|---|
|
|
226
|
+
| `gap` on modified function | The spec described expected behaviour that changed — update the spec |
|
|
227
|
+
| `stale` | Fix the stale reference |
|
|
228
|
+
| `uncovered` | Not caused by this fix — note it, propose `spec-gen generate` |
|
|
229
|
+
| No drift | Proceed to Step 9 |
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Step 9 — Spec invariant feedback
|
|
234
|
+
|
|
235
|
+
Every real bug reveals an invariant that was not documented. Capture it so future
|
|
236
|
+
agents benefit from this discovery via `search_specs`.
|
|
237
|
+
|
|
238
|
+
**9a — Identify the invariant**
|
|
239
|
+
|
|
240
|
+
State the invariant that was violated, in one sentence:
|
|
241
|
+
|
|
242
|
+
> "`$FUNCTION` must always `$CONDITION` when `$TRIGGER` — violating this causes
|
|
243
|
+
> `$OBSERVED_SYMPTOM`."
|
|
244
|
+
|
|
245
|
+
If the bug was caused by a missing guard, a wrong assumption about caller order,
|
|
246
|
+
or an undocumented state constraint — that is the invariant.
|
|
247
|
+
|
|
248
|
+
**9b — Locate the spec**
|
|
249
|
+
|
|
250
|
+
```xml
|
|
251
|
+
<use_mcp_tool>
|
|
252
|
+
<server_name>spec-gen</server_name>
|
|
253
|
+
<tool_name>get_spec</tool_name>
|
|
254
|
+
<arguments>{
|
|
255
|
+
"directory": "$PROJECT_ROOT",
|
|
256
|
+
"domain": "$DOMAIN_AFFECTED"
|
|
257
|
+
}</arguments>
|
|
258
|
+
</use_mcp_tool>
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**9c — Add the invariant**
|
|
262
|
+
|
|
263
|
+
Append to the relevant domain spec under a `### Known Invariants` section
|
|
264
|
+
(create it if absent). Wrap the section in `<!-- manual -->` / `<!-- /manual -->`
|
|
265
|
+
markers so `spec-gen generate` preserves it on re-generation:
|
|
266
|
+
|
|
267
|
+
```markdown
|
|
268
|
+
<!-- manual -->
|
|
269
|
+
### Known Invariants
|
|
270
|
+
|
|
271
|
+
- `$FUNCTION`: $INVARIANT_STATEMENT
|
|
272
|
+
— discovered via bug fix on $DATE, root cause: $ROOT_CAUSE_SUMMARY
|
|
273
|
+
<!-- /manual -->
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
If the domain spec does not exist yet (`uncovered` from Step 8), note the
|
|
277
|
+
invariant in the story/issue instead and flag it for the next `spec-gen generate` run.
|
|
278
|
+
|
|
279
|
+
**9d — Evaluate cross-cutting scope**
|
|
280
|
+
|
|
281
|
+
Ask: is this bug an instance of a general failure pattern, or specific to this domain?
|
|
282
|
+
|
|
283
|
+
| Signal | Cross-cutting antipattern? |
|
|
284
|
+
|---|---|
|
|
285
|
+
| Bug involves an assumption about external state, ordering, or caller contract | Yes |
|
|
286
|
+
| Bug is reproducible in other domains with the same pattern | Yes |
|
|
287
|
+
| Bug is specific to a data invariant in `$DOMAIN` | No — domain spec only |
|
|
288
|
+
|
|
289
|
+
If cross-cutting, append to `.claude/antipatterns.md` (if absent, create it with the
|
|
290
|
+
header from the [antipatterns template](../../antipatterns-template.md)):
|
|
291
|
+
|
|
292
|
+
```markdown
|
|
293
|
+
## AP-{NNN} — {pattern name}
|
|
294
|
+
|
|
295
|
+
- **Class**: {state | concurrency | boundary | assumption | resource | ordering}
|
|
296
|
+
- **Symptom**: {what broke — one sentence}
|
|
297
|
+
- **Rule**: {detection rule — "When X, always verify Y"}
|
|
298
|
+
- **Discovered**: $DATE via $BUG_DESCRIPTION
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**9e — Inform the user**
|
|
302
|
+
|
|
303
|
+
> "Invariant added to `openspec/specs/$DOMAIN/spec.md`."
|
|
304
|
+
|
|
305
|
+
If an antipattern was added:
|
|
306
|
+
> "Cross-cutting antipattern AP-{NNN} added to `.claude/antipatterns.md`.
|
|
307
|
+
> Future brainstorm and implementation sessions will check this rule."
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Absolute constraints
|
|
312
|
+
|
|
313
|
+
- Do not read source code before forming a hypothesis in Step 4
|
|
314
|
+
- Hypothesis is mandatory — even when the cause seems obvious
|
|
315
|
+
- Do not skip Step 1 (reproduction) — a fix without reproduction is speculation
|
|
316
|
+
- Do not touch functions outside the confirmed scope without re-running the gate
|
|
317
|
+
- Do not run `check_spec_drift` before tests are green
|
|
318
|
+
- Each edit ≤ 50 lines on small models
|
|
319
|
+
- Do not skip Step 9 — every bug fix must produce a documented invariant or an
|
|
320
|
+
explicit note explaining why no invariant applies
|