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,119 @@
|
|
|
1
|
+
# spec-gen commands for get-shit-done (GSD)
|
|
2
|
+
|
|
3
|
+
Two Claude Code slash commands that add structural risk analysis and spec drift
|
|
4
|
+
verification to the [get-shit-done](https://github.com/gsd-build/get-shit-done) workflow.
|
|
5
|
+
|
|
6
|
+
Part of the [spec-gen agentic workflow pattern](../../docs/agentic-workflows/README.md).
|
|
7
|
+
|
|
8
|
+
## Commands
|
|
9
|
+
|
|
10
|
+
| Command | When | What it does |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| `/gsd:spec-gen-orient` | Before `/gsd:execute-phase` | orient + risk gate → writes `.planning/codebase/RISK-CONTEXT.md` |
|
|
13
|
+
| `/gsd:spec-gen-drift` | After `/gsd:verify-work` passes | drift check → appends spec status to `RISK-CONTEXT.md` |
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Copy the `commands/` directory into your project's `.claude/` folder:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cp -r examples/gsd/commands/.claude/commands/gsd/ .claude/commands/gsd/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or copy into your global Claude Code commands:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cp -r examples/gsd/commands/gsd/ ~/.claude/commands/gsd/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Prerequisites
|
|
30
|
+
|
|
31
|
+
1. spec-gen MCP server configured in `.claude/settings.json`
|
|
32
|
+
2. `spec-gen analyze $PROJECT_ROOT` run at least once
|
|
33
|
+
|
|
34
|
+
## Workflow
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart TD
|
|
38
|
+
MAP["/gsd:map-codebase\nnarrative docs\n(STACK, ARCHITECTURE…)"] --> ORIENT
|
|
39
|
+
|
|
40
|
+
subgraph SG_PRE ["spec-gen — pre-phase (brownfield)"]
|
|
41
|
+
ORIENT["/gsd:spec-gen-orient\norient + analyze_impact"]
|
|
42
|
+
ORIENT --> GATE{risk ≥ 70?}
|
|
43
|
+
GATE -- yes --> INSERT["🔴 /gsd:insert-phase\nadd refactor phase"]
|
|
44
|
+
GATE -- no --> RISK_CTX[".planning/codebase/\nRISK-CONTEXT.md"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
INSERT --> ORIENT
|
|
48
|
+
RISK_CTX --> PLAN["/gsd:plan-phase N"]
|
|
49
|
+
PLAN --> EXEC["/gsd:execute-phase N"]
|
|
50
|
+
EXEC --> VERIFY["/gsd:verify-work N"]
|
|
51
|
+
VERIFY --> TESTS{tests pass?}
|
|
52
|
+
TESTS -- no --> GAP["/gsd:execute-phase --gaps-only"]
|
|
53
|
+
GAP --> VERIFY
|
|
54
|
+
TESTS -- yes --> DRIFT
|
|
55
|
+
|
|
56
|
+
subgraph SG_POST ["spec-gen — post-phase"]
|
|
57
|
+
DRIFT["/gsd:spec-gen-drift N\ncheck_spec_drift"]
|
|
58
|
+
DRIFT --> RESULT{drift?}
|
|
59
|
+
RESULT -- stale --> FIX["fix ref now"]
|
|
60
|
+
RESULT -- gap --> NOTE["note → post-milestone\nspec-gen generate"]
|
|
61
|
+
RESULT -- none --> CLEAN["✅ clean"]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
CLEAN --> COMPLETE["/gsd:complete-milestone"]
|
|
65
|
+
NOTE --> COMPLETE
|
|
66
|
+
FIX --> COMPLETE
|
|
67
|
+
|
|
68
|
+
style INSERT fill:#fdd,stroke:#c00
|
|
69
|
+
style TESTS fill:#fff3cd,stroke:#ffc107
|
|
70
|
+
style CLEAN fill:#d4edda,stroke:#28a745
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
/gsd:new-project or /gsd:map-codebase ← existing GSD commands
|
|
75
|
+
|
|
76
|
+
# spec-gen pre-flight (brownfield)
|
|
77
|
+
/gsd:spec-gen-orient [phase] ← risk gate, writes RISK-CONTEXT.md
|
|
78
|
+
|
|
79
|
+
/gsd:plan-phase [N] ← existing GSD command
|
|
80
|
+
/gsd:execute-phase [N] ← existing GSD command
|
|
81
|
+
/gsd:verify-work [N] ← existing GSD command
|
|
82
|
+
|
|
83
|
+
# spec-gen post-flight (once verify-work passes)
|
|
84
|
+
/gsd:spec-gen-drift [N] ← drift check, appends to RISK-CONTEXT.md
|
|
85
|
+
|
|
86
|
+
/gsd:complete-milestone ← existing GSD command
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Risk gate
|
|
90
|
+
|
|
91
|
+
| Score | Level | Action |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| < 40 | 🟢 low | Proceed to execute-phase |
|
|
94
|
+
| 40–69 | 🟡 medium | Proceed — protect callers listed in RISK-CONTEXT.md |
|
|
95
|
+
| ≥ 70 | 🔴 high / critical | Stop — use `/gsd:insert-phase` to add a refactor phase first |
|
|
96
|
+
|
|
97
|
+
## OpenSpec spec baseline
|
|
98
|
+
|
|
99
|
+
`/gsd:spec-gen-orient` uses `search_specs` to surface relevant requirements, and
|
|
100
|
+
`/gsd:spec-gen-drift` uses `check_spec_drift` to verify alignment. Both require
|
|
101
|
+
OpenSpec specs to exist — without them, results are empty or everything shows as uncovered.
|
|
102
|
+
|
|
103
|
+
| State | What to do |
|
|
104
|
+
|---|---|
|
|
105
|
+
| No specs yet | Run `spec-gen generate $PROJECT_ROOT` before the first phase — or let `/gsd:spec-gen-drift` offer to do it |
|
|
106
|
+
| Specs exist | Both commands work as expected |
|
|
107
|
+
| New code not yet spec'd | `drift` flags it as `uncovered` — run `spec-gen generate` post-milestone |
|
|
108
|
+
|
|
109
|
+
Both commands detect missing specs automatically and prompt you to generate them.
|
|
110
|
+
|
|
111
|
+
## Relation to `/gsd:map-codebase`
|
|
112
|
+
|
|
113
|
+
`/gsd:map-codebase` uses parallel mapper agents to produce narrative documents
|
|
114
|
+
(STACK.md, ARCHITECTURE.md, etc.) — great for onboarding and big-picture understanding.
|
|
115
|
+
|
|
116
|
+
`/gsd:spec-gen-orient` is complementary: it produces **quantitative risk data** (fan-in,
|
|
117
|
+
fan-out, risk scores, call paths) from a pre-built static index. Both can coexist —
|
|
118
|
+
run `map-codebase` once for narrative context, `spec-gen-orient` before each phase for
|
|
119
|
+
risk-aware execution.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gsd:spec-gen-drift
|
|
3
|
+
description: Post-phase spec drift check via spec-gen MCP — verify implementation matches OpenSpec specifications. Run after verify-work and green tests.
|
|
4
|
+
argument-hint: "[phase number]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- mcp__spec-gen__check_spec_drift
|
|
7
|
+
- mcp__spec-gen__get_spec
|
|
8
|
+
- Read
|
|
9
|
+
- Write
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<objective>
|
|
13
|
+
Verify that the completed phase implementation is consistent with existing OpenSpec specifications.
|
|
14
|
+
Report gaps, stale references, and uncovered files.
|
|
15
|
+
|
|
16
|
+
Run this after `/gsd:verify-work` confirms the phase is working, not before.
|
|
17
|
+
</objective>
|
|
18
|
+
|
|
19
|
+
<when_to_use>
|
|
20
|
+
Run this command:
|
|
21
|
+
- After `/gsd:verify-work` passes (or gaps are resolved)
|
|
22
|
+
- Before `/gsd:complete-milestone` as a final quality check
|
|
23
|
+
- Any time you want to confirm implementation stays aligned with specs
|
|
24
|
+
|
|
25
|
+
Skip this command:
|
|
26
|
+
- Before verify-work passes (drift check on broken code is not useful)
|
|
27
|
+
|
|
28
|
+
**If no specs exist yet**: do not skip — use this command to trigger `spec-gen generate`
|
|
29
|
+
and create the baseline. See Step 1.
|
|
30
|
+
</when_to_use>
|
|
31
|
+
|
|
32
|
+
<prerequisites>
|
|
33
|
+
1. spec-gen MCP server configured in Claude Code settings
|
|
34
|
+
2. Tests passing — confirm with user before proceeding
|
|
35
|
+
3. `spec-gen analyze` cache exists
|
|
36
|
+
</prerequisites>
|
|
37
|
+
|
|
38
|
+
<process>
|
|
39
|
+
|
|
40
|
+
<step name="check_spec_baseline">
|
|
41
|
+
Check whether OpenSpec specs exist:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
ls $PROJECT_ROOT/openspec/specs/ 2>/dev/null | wc -l
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**If 0 specs found:**
|
|
48
|
+
> "No OpenSpec specs exist yet. Running drift check now will flag all files as uncovered,
|
|
49
|
+
> which is not actionable.
|
|
50
|
+
>
|
|
51
|
+
> Run `spec-gen generate $PROJECT_ROOT` to create a baseline from the current codebase.
|
|
52
|
+
> This takes a few minutes and only needs to be done once."
|
|
53
|
+
|
|
54
|
+
Ask: "Run `spec-gen generate` now? (yes/no)"
|
|
55
|
+
- Yes → run `spec-gen generate $PROJECT_ROOT`, then proceed
|
|
56
|
+
- No → stop, remind user to run before next drift check
|
|
57
|
+
|
|
58
|
+
**If specs exist**: proceed.
|
|
59
|
+
</step>
|
|
60
|
+
|
|
61
|
+
<step name="confirm_tests">
|
|
62
|
+
Ask the user: "Are tests passing for this phase?"
|
|
63
|
+
|
|
64
|
+
If no: "Fix test failures first. Drift check on a red test suite is not actionable."
|
|
65
|
+
Stop here.
|
|
66
|
+
</step>
|
|
67
|
+
|
|
68
|
+
<step name="run_drift">
|
|
69
|
+
```
|
|
70
|
+
spec-gen check_spec_drift
|
|
71
|
+
directory: $PROJECT_ROOT
|
|
72
|
+
```
|
|
73
|
+
</step>
|
|
74
|
+
|
|
75
|
+
<step name="interpret">
|
|
76
|
+
Classify each finding:
|
|
77
|
+
|
|
78
|
+
| Type | Meaning | Recommended action |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `uncovered` on new files | New code not yet in any spec | Batch for post-milestone spec update |
|
|
81
|
+
| `gap` on existing domain | Spec missing new behaviour | Run `spec-gen generate --domains $DOMAIN` now or post-milestone |
|
|
82
|
+
| `stale` | Spec references deleted/renamed function | Fix reference in spec file |
|
|
83
|
+
| No drift | ✅ Clean | Done |
|
|
84
|
+
</step>
|
|
85
|
+
|
|
86
|
+
<step name="output">
|
|
87
|
+
If drift found:
|
|
88
|
+
|
|
89
|
+
> Spec drift detected in {N} domain(s). These do not block shipping but should be addressed.
|
|
90
|
+
>
|
|
91
|
+
> **Now (blocking):** Fix any `stale` references — they indicate broken spec links.
|
|
92
|
+
> **Post-milestone (recommended):** Run `spec-gen generate` to refresh specs for domains with gaps or uncovered files.
|
|
93
|
+
|
|
94
|
+
Append a `## Spec Drift` section to `.planning/codebase/RISK-CONTEXT.md` (or create it if absent):
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
## Spec Drift — Phase {N}
|
|
98
|
+
|
|
99
|
+
> Checked on {date} after verify-work passed.
|
|
100
|
+
|
|
101
|
+
| Domain | Type | Action |
|
|
102
|
+
|--------|------|--------|
|
|
103
|
+
{rows}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If no drift:
|
|
107
|
+
|
|
108
|
+
> ✅ No spec drift. Phase implementation is consistent with existing OpenSpec specifications.
|
|
109
|
+
</step>
|
|
110
|
+
|
|
111
|
+
</process>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gsd:spec-gen-orient
|
|
3
|
+
description: Pre-phase structural risk check via spec-gen MCP — orient + analyze_impact before execute-phase. Writes .planning/codebase/RISK-CONTEXT.md.
|
|
4
|
+
argument-hint: "[phase number or task description]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- mcp__spec-gen__orient
|
|
7
|
+
- mcp__spec-gen__analyze_impact
|
|
8
|
+
- mcp__spec-gen__search_specs
|
|
9
|
+
- mcp__spec-gen__analyze_codebase
|
|
10
|
+
- Read
|
|
11
|
+
- Write
|
|
12
|
+
- Glob
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Run spec-gen structural analysis before executing a phase. Identify high-risk functions,
|
|
17
|
+
surface relevant spec requirements, and gate on riskScore ≥ 70 before any code is written.
|
|
18
|
+
|
|
19
|
+
Output: `.planning/codebase/RISK-CONTEXT.md` with structural risk summary for the phase.
|
|
20
|
+
</objective>
|
|
21
|
+
|
|
22
|
+
<when_to_use>
|
|
23
|
+
Run this command:
|
|
24
|
+
- Before `/gsd:execute-phase` on a brownfield codebase
|
|
25
|
+
- After `/gsd:plan-phase` when the plan touches existing code
|
|
26
|
+
- Any time you suspect a planned change touches a high-fan-in function
|
|
27
|
+
|
|
28
|
+
Skip this command:
|
|
29
|
+
- Greenfield projects with no existing codebase (nothing to analyse)
|
|
30
|
+
- Trivial changes (config edits, documentation only)
|
|
31
|
+
</when_to_use>
|
|
32
|
+
|
|
33
|
+
<prerequisites>
|
|
34
|
+
1. spec-gen MCP server configured in Claude Code settings
|
|
35
|
+
2. `spec-gen analyze` run at least once on this project
|
|
36
|
+
If not: this command will detect the missing cache and offer to run it.
|
|
37
|
+
</prerequisites>
|
|
38
|
+
|
|
39
|
+
<process>
|
|
40
|
+
|
|
41
|
+
<step name="load_context">
|
|
42
|
+
Load current project state:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cat .planning/STATE.md 2>/dev/null || echo "No STATE.md found"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Determine the active phase and extract the implementation intent from:
|
|
49
|
+
- `.planning/phases/PHASE-{N}-PLAN.md` if a phase number was provided or is active
|
|
50
|
+
- `$ARGUMENTS` if a task description was provided directly
|
|
51
|
+
|
|
52
|
+
If neither exists, ask the user: "What are you about to implement?"
|
|
53
|
+
Use the answer as `$TASK_DESCRIPTION`.
|
|
54
|
+
</step>
|
|
55
|
+
|
|
56
|
+
<step name="check_cache">
|
|
57
|
+
Run orient to verify cache exists:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
spec-gen orient
|
|
61
|
+
directory: $PROJECT_ROOT
|
|
62
|
+
task: $TASK_DESCRIPTION
|
|
63
|
+
limit: 7
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If orient returns `"error": "no cache"`:
|
|
67
|
+
> spec-gen has no analysis cache for this project.
|
|
68
|
+
> Run `spec-gen analyze $PROJECT_ROOT` first (takes ~1 min for most projects).
|
|
69
|
+
> Then re-run `/gsd:spec-gen-orient`.
|
|
70
|
+
|
|
71
|
+
Offer to run analysis now:
|
|
72
|
+
```
|
|
73
|
+
spec-gen analyze_codebase
|
|
74
|
+
directory: $PROJECT_ROOT
|
|
75
|
+
```
|
|
76
|
+
Wait for completion, then proceed.
|
|
77
|
+
</step>
|
|
78
|
+
|
|
79
|
+
<step name="check_spec_baseline">
|
|
80
|
+
Check whether OpenSpec specifications exist:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ls $PROJECT_ROOT/openspec/specs/ 2>/dev/null | head -5
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**If no specs exist** (`openspec/specs/` absent or empty):
|
|
87
|
+
> "No OpenSpec specs found for this project. `search_specs` will return empty results
|
|
88
|
+
> and `check_spec_drift` will flag all files as uncovered.
|
|
89
|
+
>
|
|
90
|
+
> Recommended: run `spec-gen generate $PROJECT_ROOT` after this phase to create a spec
|
|
91
|
+
> baseline. You only need to do this once — future phases will benefit from spec alignment.
|
|
92
|
+
>
|
|
93
|
+
> Continuing with structural analysis only (orient + impact)."
|
|
94
|
+
|
|
95
|
+
Skip the search_specs step below and go straight to impact_analysis.
|
|
96
|
+
|
|
97
|
+
**If specs exist**: proceed to search_specs.
|
|
98
|
+
</step>
|
|
99
|
+
|
|
100
|
+
<step name="search_specs">
|
|
101
|
+
Surface existing requirements that apply to this change:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
spec-gen search_specs
|
|
105
|
+
directory: $PROJECT_ROOT
|
|
106
|
+
query: $TASK_DESCRIPTION
|
|
107
|
+
limit: 5
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
List any relevant requirements found. Note constraints that apply to the planned implementation.
|
|
111
|
+
If search returns no results despite specs existing, note it in RISK-CONTEXT.md under
|
|
112
|
+
"Relevant Spec Requirements: none matched — area may not be spec'd yet".
|
|
113
|
+
</step>
|
|
114
|
+
|
|
115
|
+
<step name="impact_analysis">
|
|
116
|
+
For the top 2 functions returned by orient, run impact analysis:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
spec-gen analyze_impact
|
|
120
|
+
directory: $PROJECT_ROOT
|
|
121
|
+
symbol: $FUNCTION_NAME
|
|
122
|
+
depth: 2
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Build a risk table:
|
|
126
|
+
|
|
127
|
+
| Function | File | Risk Score | Level | Callers |
|
|
128
|
+
|----------|------|-----------|-------|---------|
|
|
129
|
+
</step>
|
|
130
|
+
|
|
131
|
+
<step name="gate">
|
|
132
|
+
Apply the risk gate:
|
|
133
|
+
|
|
134
|
+
| Max risk score | Decision |
|
|
135
|
+
|---|---|
|
|
136
|
+
| < 40 | 🟢 Proceed — show insertion points, write RISK-CONTEXT.md |
|
|
137
|
+
| 40–69 | 🟡 Proceed with caution — list callers to protect in RISK-CONTEXT.md |
|
|
138
|
+
| ≥ 70 | 🔴 **Stop.** Do not execute phase until the blocking function is refactored. |
|
|
139
|
+
|
|
140
|
+
**If riskScore ≥ 70 on any function:**
|
|
141
|
+
|
|
142
|
+
> ⚠️ High structural risk on `$FUNCTION_NAME` (score: $SCORE, $CALLER_COUNT callers).
|
|
143
|
+
>
|
|
144
|
+
> Recommended: add a refactor plan to the current phase or insert a new phase before this one.
|
|
145
|
+
> Use `/gsd:insert-phase` to add a refactor phase, then re-run `/gsd:spec-gen-orient`.
|
|
146
|
+
|
|
147
|
+
Stop and wait for user decision. Do not proceed to execute-phase.
|
|
148
|
+
</step>
|
|
149
|
+
|
|
150
|
+
<step name="write_output">
|
|
151
|
+
Write `.planning/codebase/RISK-CONTEXT.md`:
|
|
152
|
+
|
|
153
|
+
```markdown
|
|
154
|
+
# Risk Context — Phase {N}
|
|
155
|
+
|
|
156
|
+
> Generated by spec-gen on {date}. Re-run `/gsd:spec-gen-orient` after structural changes.
|
|
157
|
+
|
|
158
|
+
## Summary
|
|
159
|
+
|
|
160
|
+
- **Phase intent**: {task_description}
|
|
161
|
+
- **Domains**: {domains}
|
|
162
|
+
- **Max risk score**: {score} {badge}
|
|
163
|
+
- **Decision**: {🟢 proceed | 🟡 proceed with caution | 🔴 blocked}
|
|
164
|
+
|
|
165
|
+
## Functions in Scope
|
|
166
|
+
|
|
167
|
+
| Function | File | Risk | Hub |
|
|
168
|
+
|----------|------|------|-----|
|
|
169
|
+
{rows}
|
|
170
|
+
|
|
171
|
+
## Callers to Protect
|
|
172
|
+
|
|
173
|
+
{list of callers from impact analysis, or "none"}
|
|
174
|
+
|
|
175
|
+
## Blocking Refactors
|
|
176
|
+
|
|
177
|
+
{list of functions with risk ≥ 70, or "none"}
|
|
178
|
+
|
|
179
|
+
## Relevant Spec Requirements
|
|
180
|
+
|
|
181
|
+
{list from search_specs, or "none found — run spec-gen generate to create specs"}
|
|
182
|
+
|
|
183
|
+
## Insertion Points
|
|
184
|
+
|
|
185
|
+
{top insertion point from orient}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Confirm: "Risk context written to `.planning/codebase/RISK-CONTEXT.md`. Safe to run `/gsd:execute-phase`."
|
|
189
|
+
</step>
|
|
190
|
+
|
|
191
|
+
</process>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Mistral Vibe assets for spec-gen
|
|
2
|
+
|
|
3
|
+
Mistral Vibe implementation of the [spec-gen agentic workflow pattern](../../docs/agentic-workflows/README.md).
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
| Path | Purpose |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `skills/spec-gen-analyze-codebase/` | Full static analysis — architecture, call graph, refactor issues, duplicates |
|
|
10
|
+
| `skills/spec-gen-generate/` | Generate OpenSpec specs from analysis results |
|
|
11
|
+
| `skills/spec-gen-brainstorm/` | Design a feature: greenfield (Domain Sketch) or brownfield (Constrained Option Tree) → annotated story |
|
|
12
|
+
| `skills/spec-gen-plan-refactor/` | Identify highest-priority refactor target and write a plan |
|
|
13
|
+
| `skills/spec-gen-execute-refactor/` | Apply a refactor plan produced by spec-gen-plan-refactor |
|
|
14
|
+
| `skills/spec-gen-implement-story/` | Implement a story with structural pre-flight check, test gate, and drift verification |
|
|
15
|
+
| `skills/spec-gen-debug/` | Debug a bug: hypothesis-first, RED/GREEN test verification, spec invariant feedback loop |
|
|
16
|
+
| `antipatterns-template.md` | Starter template for `.claude/antipatterns.md` — copy to your project root |
|
|
17
|
+
|
|
18
|
+
## Workflow
|
|
19
|
+
|
|
20
|
+
```mermaid
|
|
21
|
+
flowchart TD
|
|
22
|
+
subgraph ANALYSIS ["📊 Analysis (one-time)"]
|
|
23
|
+
A["/spec-gen-analyze-codebase"] --> B["/spec-gen-generate"]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
subgraph REFACTOR ["🔧 Refactor cycle (optional)"]
|
|
27
|
+
C["/spec-gen-plan-refactor\n→ .spec-gen/refactor-plan.md"] --> D["/spec-gen-execute-refactor\nchange by change, test gate"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
subgraph DESIGN ["💡 Design"]
|
|
31
|
+
K["/spec-gen-brainstorm\ngreenfield or brownfield"] --> L["Won't Do + testable ACs\nadversarial challenge"]
|
|
32
|
+
L --> M["annotate_story\n→ story.md with risk_context"]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
subgraph FEATURE ["⚙️ Feature / Story"]
|
|
36
|
+
E["/spec-gen-implement-story"] --> F["orient + analyze_impact\nrisk gate ≥ 70 → blocks"]
|
|
37
|
+
F --> F2["adversarial self-check\n+ antipatterns"]
|
|
38
|
+
F2 --> G["search_specs\nread requirements"]
|
|
39
|
+
G --> H["implement"]
|
|
40
|
+
H --> I["tests green ✅"]
|
|
41
|
+
I --> J["check_spec_drift"]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
subgraph DEBUG ["🐛 Debug"]
|
|
45
|
+
N["/spec-gen-debug\nhypothesis-first"] --> O["RED/GREEN\ntest verification"]
|
|
46
|
+
O --> P["spec invariant\nfeedback loop"]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
B --> C
|
|
50
|
+
B --> K
|
|
51
|
+
M --> E
|
|
52
|
+
D --> E
|
|
53
|
+
|
|
54
|
+
style F fill:#fff3cd,stroke:#ffc107
|
|
55
|
+
style I fill:#d4edda,stroke:#28a745
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
Copy the skills into your Mistral Vibe project skills directory and invoke them with their slash commands:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
/spec-gen-analyze-codebase
|
|
64
|
+
/spec-gen-generate
|
|
65
|
+
/spec-gen-brainstorm
|
|
66
|
+
/spec-gen-plan-refactor
|
|
67
|
+
/spec-gen-execute-refactor
|
|
68
|
+
/spec-gen-implement-story
|
|
69
|
+
/spec-gen-debug
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Each skill follows the generic pre-flight pattern:
|
|
73
|
+
- `orient` + `analyze_impact` before any code change
|
|
74
|
+
- adversarial self-check + antipatterns read before first edit
|
|
75
|
+
- test gate before `check_spec_drift`
|
|
76
|
+
- `check_spec_drift` after tests are green
|
|
77
|
+
|
|
78
|
+
## Antipatterns
|
|
79
|
+
|
|
80
|
+
Copy `antipatterns-template.md` to `.claude/antipatterns.md` in your project:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cp examples/mistral-vibe/antipatterns-template.md .claude/antipatterns.md
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The antipatterns list is read by `spec-gen-brainstorm` (Step 1) and `spec-gen-implement-story` (Step 4b),
|
|
87
|
+
and written by `spec-gen-debug` (Step 9d) when a bug reveals a cross-cutting failure pattern.
|
|
88
|
+
|
|
89
|
+
## OpenSpec spec baseline
|
|
90
|
+
|
|
91
|
+
`search_specs` and `check_spec_drift` require specs to exist. Run `/spec-gen-generate`
|
|
92
|
+
once before using `/spec-gen-implement-story` for the first time — this creates the
|
|
93
|
+
baseline that makes spec alignment meaningful.
|
|
94
|
+
|
|
95
|
+
| State | What to do |
|
|
96
|
+
|---|---|
|
|
97
|
+
| No specs yet | `/spec-gen-analyze-codebase` then `/spec-gen-generate` |
|
|
98
|
+
| Specs exist | All skills work as expected |
|
|
99
|
+
| Post-sprint spec refresh | `/spec-gen-generate` again to update specs after new code |
|
|
100
|
+
|
|
101
|
+
`/spec-gen-implement-story` detects missing specs automatically and tells you what to do.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Project Antipatterns
|
|
2
|
+
|
|
3
|
+
Failure patterns discovered post-merge. Automatically checked by agents during
|
|
4
|
+
brainstorm and implementation via `spec-gen-brainstorm` and `spec-gen-implement-story`.
|
|
5
|
+
|
|
6
|
+
To add an entry: run `/spec-gen-debug` — Step 9 evaluates whether the bug
|
|
7
|
+
qualifies as a cross-cutting antipattern and appends here if so.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!-- Add entries below. Use AP-NNN numbering. -->
|
|
12
|
+
|
|
13
|
+
## AP-001 — {pattern name}
|
|
14
|
+
|
|
15
|
+
- **Class**: {state | concurrency | boundary | assumption | resource | ordering}
|
|
16
|
+
- **Symptom**: {what broke in production — one sentence}
|
|
17
|
+
- **Rule**: {detection rule agents should check — "When X, always verify Y"}
|
|
18
|
+
- **Discovered**: {YYYY-MM-DD} via {one-line bug summary}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec-gen-analyze-codebase
|
|
3
|
+
description: Run a full static analysis of a project using spec-gen and summarise the results — architecture, call graph, top refactoring issues, and duplicate code. No LLM required.
|
|
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
|
+
- spec-gen-plan-refactor
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# spec-gen: Analyze Codebase
|
|
14
|
+
|
|
15
|
+
## When to use this skill
|
|
16
|
+
|
|
17
|
+
Trigger this skill whenever the user asks to **analyze a codebase** with spec-gen, with phrasings like:
|
|
18
|
+
- "analyze my project / my code"
|
|
19
|
+
- "give me a code quality report"
|
|
20
|
+
- "what are the structural issues in my codebase"
|
|
21
|
+
- "find duplicates in my code"
|
|
22
|
+
- explicit command `/spec-gen-analyze-codebase`
|
|
23
|
+
|
|
24
|
+
This skill is **read-only** — it modifies no files. It produces a report and suggests next steps.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Step 1 — Confirm the project directory
|
|
29
|
+
|
|
30
|
+
Ask the user which project to analyze, or confirm the current workspace root.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Which project directory should I analyze?
|
|
34
|
+
Options: current workspace root | enter a different path
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Step 2 — Run static analysis
|
|
40
|
+
|
|
41
|
+
```xml
|
|
42
|
+
<use_mcp_tool>
|
|
43
|
+
<server_name>spec-gen</server_name>
|
|
44
|
+
<tool_name>analyze_codebase</tool_name>
|
|
45
|
+
<arguments>{"directory": "$DIRECTORY"}</arguments>
|
|
46
|
+
</use_mcp_tool>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Step 3 — Summarize the results
|
|
52
|
+
|
|
53
|
+
Present a concise summary:
|
|
54
|
+
- Project type and detected frameworks
|
|
55
|
+
- File count, function count, internal call count
|
|
56
|
+
- Top 5 refactoring issues (function name, file, issue type, priority score)
|
|
57
|
+
- Detected domains
|
|
58
|
+
|
|
59
|
+
Also report stack inventory (read directly from `.spec-gen/analysis/` — no extra MCP call needed):
|
|
60
|
+
- **HTTP routes**: N routes across M files — if `route-inventory.json` exists
|
|
61
|
+
- **ORM tables**: N tables — if `schema-inventory.json` exists
|
|
62
|
+
- **Env vars**: N total, X required without default — if `env-inventory.json` exists
|
|
63
|
+
- **UI components**: N components — if `ui-inventory.json` exists
|
|
64
|
+
|
|
65
|
+
If none of these files exist, skip this section and suggest running `spec-gen analyze --force`.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Step 4 — Show the call graph
|
|
70
|
+
|
|
71
|
+
```xml
|
|
72
|
+
<use_mcp_tool>
|
|
73
|
+
<server_name>spec-gen</server_name>
|
|
74
|
+
<tool_name>get_call_graph</tool_name>
|
|
75
|
+
<arguments>{"directory": "$DIRECTORY"}</arguments>
|
|
76
|
+
</use_mcp_tool>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Highlight:
|
|
80
|
+
- **Hub functions** (fanIn ≥ 8) — over-solicited functions, high coupling risk
|
|
81
|
+
- **Layer violations** detected (e.g. a UI layer calling the database directly)
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Step 5 — Show duplicate code report
|
|
86
|
+
|
|
87
|
+
```xml
|
|
88
|
+
<use_mcp_tool>
|
|
89
|
+
<server_name>spec-gen</server_name>
|
|
90
|
+
<tool_name>get_duplicate_report</tool_name>
|
|
91
|
+
<arguments>{"directory": "$DIRECTORY"}</arguments>
|
|
92
|
+
</use_mcp_tool>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Present a concise summary:
|
|
96
|
+
- Overall duplication ratio (e.g. "12% of functions are duplicated")
|
|
97
|
+
- Top 3 clone groups sorted by impact (instances × line count):
|
|
98
|
+
- Clone type (exact / structural / near) and similarity score
|
|
99
|
+
- List of instances (file + function name + line range)
|
|
100
|
+
- If no duplicates found, note this as a positive signal
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Step 6 — Suggest next steps
|
|
105
|
+
|
|
106
|
+
Based on the analysis, guide the user through the natural next actions in order:
|
|
107
|
+
|
|
108
|
+
1. Call `get_signatures` on the modules containing the top issues to understand their public API
|
|
109
|
+
2. Call `get_subgraph` on the highest-priority function to map its callers and callees
|
|
110
|
+
3. If significant duplication was found, suggest consolidating clone groups **before** refactoring
|
|
111
|
+
4. Suggest running `/spec-gen-plan-refactor` once the user has enough context to act, then `/spec-gen-execute-refactor` to apply the plan
|
|
112
|
+
5. If the project has OpenSpec specs, call `list_spec_domains` then `search_specs` to enable
|
|
113
|
+
spec-first reasoning (question → requirements → linked source files). To activate `search_specs`,
|
|
114
|
+
run `spec-gen analyze --embed` or `spec-gen analyze --reindex-specs`.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Absolute constraints
|
|
119
|
+
|
|
120
|
+
- **No code modifications** in this workflow
|
|
121
|
+
- Never skip the duplication step — it determines the order of subsequent actions
|
|
122
|
+
- Always present call graph and duplicate report results even if numbers are low
|
|
123
|
+
- Next steps (Step 6) are suggestions, not automatic actions
|