@smartmemory/compose 0.1.1-beta → 0.1.3-beta

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.
Files changed (124) hide show
  1. package/.claude/skills/bug-fix/SKILL.md +143 -0
  2. package/.claude/skills/compose/SKILL.md +604 -0
  3. package/.compose-deps.json +89 -0
  4. package/README.md +47 -983
  5. package/bin/compose.js +473 -0
  6. package/contracts/comp-obs-contract.schema.json +362 -0
  7. package/contracts/cross-model-review-result.json +78 -0
  8. package/contracts/review-result.json +126 -0
  9. package/dist/assets/{_baseUniq-CQwX6VLz.js → _baseUniq-D-avYfn5.js} +1 -1
  10. package/dist/assets/{arc-SxJ2J1sh.js → arc-BC4dfQ-X.js} +1 -1
  11. package/dist/assets/{architectureDiagram-Q4EWVU46-BykunY1F.js → architectureDiagram-Q4EWVU46-BZmFXnGI.js} +1 -1
  12. package/dist/assets/{blockDiagram-DXYQGD6D-ohAKBOUw.js → blockDiagram-DXYQGD6D-DlfWSuux.js} +1 -1
  13. package/dist/assets/{c4Diagram-AHTNJAMY-DBDC3ENB.js → c4Diagram-AHTNJAMY-Y__uJrRx.js} +1 -1
  14. package/dist/assets/channel-LRG9kHqJ.js +1 -0
  15. package/dist/assets/{chunk-4BX2VUAB-Cv93Z7uM.js → chunk-4BX2VUAB-BfMePfTp.js} +1 -1
  16. package/dist/assets/{chunk-4TB4RGXK-DE0WBDkj.js → chunk-4TB4RGXK-BdlMSdEA.js} +1 -1
  17. package/dist/assets/{chunk-55IACEB6-CE1EXenG.js → chunk-55IACEB6-vrQHZTdv.js} +1 -1
  18. package/dist/assets/{chunk-EDXVE4YY-DA7Ana6H.js → chunk-EDXVE4YY-B8wioVlW.js} +1 -1
  19. package/dist/assets/{chunk-FMBD7UC4-CTDIPA3p.js → chunk-FMBD7UC4-Cd6Hrux2.js} +1 -1
  20. package/dist/assets/{chunk-OYMX7WX6-uGBaPaTX.js → chunk-OYMX7WX6-CfrhdQXY.js} +1 -1
  21. package/dist/assets/{chunk-QZHKN3VN-CYlnXuUO.js → chunk-QZHKN3VN-B9JQerOU.js} +1 -1
  22. package/dist/assets/{chunk-YZCP3GAM-ojGkzcZK.js → chunk-YZCP3GAM-DFN9X99H.js} +1 -1
  23. package/dist/assets/classDiagram-6PBFFD2Q-BC9a6pDE.js +1 -0
  24. package/dist/assets/classDiagram-v2-HSJHXN6E-BC9a6pDE.js +1 -0
  25. package/dist/assets/clone-dRxgFrBv.js +1 -0
  26. package/dist/assets/{cose-bilkent-S5V4N54A-Bktn9hL-.js → cose-bilkent-S5V4N54A-BAn0ap_E.js} +1 -1
  27. package/dist/assets/{dagre-KV5264BT-DFaSzuRF.js → dagre-KV5264BT-DyxnVq1g.js} +1 -1
  28. package/dist/assets/{diagram-5BDNPKRD-DnfmDzEm.js → diagram-5BDNPKRD-XCrzqski.js} +1 -1
  29. package/dist/assets/{diagram-G4DWMVQ6-Bm8W9YnG.js → diagram-G4DWMVQ6-MBCAXft_.js} +1 -1
  30. package/dist/assets/{diagram-MMDJMWI5-B5-TSKvp.js → diagram-MMDJMWI5-DbtB2yS6.js} +1 -1
  31. package/dist/assets/{diagram-TYMM5635-ls4rqlky.js → diagram-TYMM5635-Bb5NzX61.js} +1 -1
  32. package/dist/assets/{erDiagram-SMLLAGMA-giG6WO-r.js → erDiagram-SMLLAGMA-CpIeCOh2.js} +1 -1
  33. package/dist/assets/{flowDiagram-DWJPFMVM-XvlUuz-7.js → flowDiagram-DWJPFMVM-CHyoKnhW.js} +1 -1
  34. package/dist/assets/{ganttDiagram-T4ZO3ILL-hLBV57oV.js → ganttDiagram-T4ZO3ILL-DErKteO_.js} +1 -1
  35. package/dist/assets/{gitGraphDiagram-UUTBAWPF-BHu3s_Gn.js → gitGraphDiagram-UUTBAWPF-KFVAtj2F.js} +1 -1
  36. package/dist/assets/{graph-D0Cfv00Y.js → graph-CRnO_ifT.js} +1 -1
  37. package/dist/assets/index-DKBsEUJ-.css +1 -0
  38. package/dist/assets/index-DkRKLuNr.js +1144 -0
  39. package/dist/assets/{infoDiagram-42DDH7IO-DbqRsOo3.js → infoDiagram-42DDH7IO-BZFnuSp5.js} +1 -1
  40. package/dist/assets/{ishikawaDiagram-UXIWVN3A-DnCdx7zb.js → ishikawaDiagram-UXIWVN3A-4Xe2Szde.js} +1 -1
  41. package/dist/assets/{journeyDiagram-VCZTEJTY-CfD7eNcP.js → journeyDiagram-VCZTEJTY-CZRByfS-.js} +1 -1
  42. package/dist/assets/{kanban-definition-6JOO6SKY-BYaO9-mK.js → kanban-definition-6JOO6SKY-B95sk6Fk.js} +1 -1
  43. package/dist/assets/{layout-Bj72wOEB.js → layout-BqNQzxWT.js} +1 -1
  44. package/dist/assets/{linear-BRFo114D.js → linear-CUh7qb64.js} +1 -1
  45. package/dist/assets/{min-GCHnKlJS.js → min-wXgOS3ig.js} +1 -1
  46. package/dist/assets/{mindmap-definition-QFDTVHPH-n0PMebY4.js → mindmap-definition-QFDTVHPH-DB6iaAbO.js} +1 -1
  47. package/dist/assets/{pieDiagram-DEJITSTG-pN4CljHF.js → pieDiagram-DEJITSTG-CHkZHrTW.js} +1 -1
  48. package/dist/assets/{quadrantDiagram-34T5L4WZ-DNoAy8-D.js → quadrantDiagram-34T5L4WZ-DoTEO8e3.js} +1 -1
  49. package/dist/assets/{requirementDiagram-MS252O5E-BhtY05PT.js → requirementDiagram-MS252O5E-Dn8peXYp.js} +1 -1
  50. package/dist/assets/{sankeyDiagram-XADWPNL6-B6AD-16A.js → sankeyDiagram-XADWPNL6-DRXs6Ipb.js} +1 -1
  51. package/dist/assets/{sequenceDiagram-FGHM5R23-DShHM-uk.js → sequenceDiagram-FGHM5R23-wBBYZ0aq.js} +1 -1
  52. package/dist/assets/{stateDiagram-FHFEXIEX-DMxn7HTo.js → stateDiagram-FHFEXIEX-DPlBNGmf.js} +1 -1
  53. package/dist/assets/stateDiagram-v2-QKLJ7IA2-BW0ezXb4.js +1 -0
  54. package/dist/assets/{timeline-definition-GMOUNBTQ-Cdu6uq52.js → timeline-definition-GMOUNBTQ-CbbyTlHk.js} +1 -1
  55. package/dist/assets/{vennDiagram-DHZGUBPP-CpK29iRe.js → vennDiagram-DHZGUBPP-Bj4GaFfj.js} +1 -1
  56. package/dist/assets/{wardley-RL74JXVD-BQgSkdcO.js → wardley-RL74JXVD-RtNzq8KU.js} +55 -55
  57. package/dist/assets/{wardleyDiagram-NUSXRM2D-DJHYev6O.js → wardleyDiagram-NUSXRM2D-CDfE3zSj.js} +1 -1
  58. package/dist/assets/{xychartDiagram-5P7HB3ND-1d75pbaO.js → xychartDiagram-5P7HB3ND-CZXHHYD5.js} +1 -1
  59. package/dist/index.html +2 -2
  60. package/lib/budget-ledger.js +45 -0
  61. package/lib/bug-bisect.js +292 -0
  62. package/lib/bug-checkpoint.js +191 -0
  63. package/lib/bug-escalation.js +306 -0
  64. package/lib/bug-index-gen.js +136 -0
  65. package/lib/bug-ledger.js +126 -0
  66. package/lib/build-stream-schema.js +176 -0
  67. package/lib/build-stream-writer.js +3 -1
  68. package/lib/build.js +854 -284
  69. package/lib/connector-factory-shim.js +167 -0
  70. package/lib/constants.js +18 -0
  71. package/lib/debug-discipline.js +176 -27
  72. package/lib/deps.js +205 -0
  73. package/lib/health-score.js +4 -4
  74. package/lib/import.js +26 -13
  75. package/lib/inject-schema.js +21 -0
  76. package/lib/new.js +27 -53
  77. package/lib/result-normalizer.js +160 -144
  78. package/lib/review-lenses.js +5 -5
  79. package/lib/review-normalize.js +413 -0
  80. package/lib/review-prompt.js +163 -0
  81. package/lib/sections.js +325 -0
  82. package/lib/step-prompt.js +21 -1
  83. package/lib/step-validator.js +5 -3
  84. package/lib/stratum-mcp-client.js +172 -7
  85. package/package.json +14 -3
  86. package/pipelines/bug-fix.stratum.yaml +39 -1
  87. package/pipelines/build.stratum.yaml +28 -45
  88. package/pipelines/review-fix.stratum.yaml +1 -1
  89. package/presets/team-review.stratum.yaml +21 -14
  90. package/server/build-stream-bridge.js +28 -0
  91. package/server/cc-session-feature-resolver.js +111 -0
  92. package/server/cc-session-reader.js +327 -0
  93. package/server/cc-session-watcher.js +318 -0
  94. package/server/compose-mcp-tools.js +0 -125
  95. package/server/compose-mcp.js +2 -4
  96. package/server/contract-diff.js +192 -0
  97. package/server/decision-event-emit.js +175 -0
  98. package/server/decision-event-id.js +64 -0
  99. package/server/decision-events-snapshot.js +166 -0
  100. package/server/design-routes.js +92 -49
  101. package/server/drift-axes.js +365 -0
  102. package/server/drift-emit.js +121 -0
  103. package/server/gate-log-store.js +102 -0
  104. package/server/lifecycle-phase-history.js +44 -0
  105. package/server/open-loops-store.js +102 -0
  106. package/server/schema-validator.js +49 -0
  107. package/server/status-emit.js +27 -0
  108. package/server/status-snapshot.js +218 -0
  109. package/server/vision-routes.js +332 -4
  110. package/server/vision-server.js +104 -12
  111. package/server/vision-store.js +21 -0
  112. package/dist/assets/channel-DGElom1e.js +0 -1
  113. package/dist/assets/classDiagram-6PBFFD2Q-KqWP9wWZ.js +0 -1
  114. package/dist/assets/classDiagram-v2-HSJHXN6E-KqWP9wWZ.js +0 -1
  115. package/dist/assets/clone-DUJKJXd7.js +0 -1
  116. package/dist/assets/index-CUd6pFGF.css +0 -1
  117. package/dist/assets/index-DReRlzZI.js +0 -1144
  118. package/dist/assets/stateDiagram-v2-QKLJ7IA2-o6PnCs4e.js +0 -1
  119. package/server/connectors/agent-connector.js +0 -78
  120. package/server/connectors/claude-sdk-connector.js +0 -198
  121. package/server/connectors/codex-connector.js +0 -240
  122. package/server/connectors/connector-discovery.js +0 -18
  123. package/server/connectors/connector-runtime.js +0 -13
  124. package/server/connectors/opencode-connector.js +0 -200
@@ -0,0 +1,604 @@
1
+ ---
2
+ name: compose
3
+ description: Use when starting a non-trivial feature OR fixing a non-trivial bug — orchestrates the full lifecycle (build mode: idea → design → blueprint → implement; fix mode: triage → reproduce → root-cause → fix → verify) using existing skills and agents at each stage.
4
+ ---
5
+
6
+ # Compose Lifecycle
7
+
8
+ ## Overview
9
+
10
+ Orchestrates two lifecycles under one skill:
11
+
12
+ - **`/compose build <feature-ref>`** — feature lifecycle (idea → design → blueprint → implement → ship)
13
+ - **`/compose fix <bug-ref>`** — bug-fix lifecycle (triage → reproduce → root-cause → fix → verify → ship)
14
+
15
+ Both modes share Phase 6 (plan), Phase 7 (TDD execute + E2E + review loop + coverage sweep), Phase 9 (docs), and Phase 10 (ship). They diverge in the upstream phases. Claude Code's native tools (plan mode, tasks, sessions) handle within-session execution; this skill handles the cross-session lifecycle.
16
+
17
+ Before any phase begins, read project state via the `compose` MCP server (get_vision_items, get_phase_summary, get_blocked_items). Every feature OR bug maps to a vision item — check it exists, create it if not.
18
+
19
+ ## Mode Selection
20
+
21
+ `/compose` with no verb defaults to `build` for back-compat. Explicit verbs:
22
+
23
+ | Verb | Use | Folder |
24
+ |---|---|---|
25
+ | `/compose build <feature-ref>` | New feature, 3+ files, 2+ phases, needs design | `docs/features/<feature-code>/` |
26
+ | `/compose fix <bug-ref>` | Non-trivial bug, test failure, regression, hotfix | `docs/bugs/<bug-code>/` |
27
+
28
+ **Skip Compose entirely for:** typos, one-line obvious fixes, cosmetic changes — just fix those directly.
29
+
30
+ ## Partial Execution: `--through <phase>`
31
+
32
+ By default, `/compose` runs the full lifecycle. Use `--through` to stop after a specific phase's gate is approved:
33
+
34
+ ```
35
+ /compose FEAT-1 --through design
36
+ /compose FEAT-1 --through prd
37
+ /compose FEAT-1 --through architecture
38
+ /compose FEAT-1 --through blueprint
39
+ /compose FEAT-1 --through plan
40
+ /compose FEAT-1 --through execute
41
+ /compose FEAT-1 --through report
42
+ /compose FEAT-1 --through docs
43
+ ```
44
+
45
+ When `--through` is active:
46
+ 1. Run phases normally up to and including the target phase
47
+ 2. After the target phase's gate is approved, write `status.md` to the feature folder
48
+ 3. Commit all artifacts and exit — do NOT propose the next phase
49
+ 4. On next `/compose` invocation, `status.md` is read during entry scan and informs the resume point
50
+
51
+ ## Feature Folder
52
+
53
+ Every feature gets a folder at `docs/features/<feature-code>/`. The folder name matches the vision item's semantic ID or tracker code (e.g. `FEAT-1`, `AUTH-3`). 1:1 mapping between vision items and feature folders.
54
+
55
+ ```
56
+ docs/features/<feature-code>/
57
+ design.md # Feature-level design
58
+ prd.md # PRD (skip for internal/technical work)
59
+ architecture.md # Architecture (skip for single-component)
60
+ killed.md # Present only if feature was abandoned
61
+ sessions/ # Session transcripts
62
+ phase-1-<slug>/ # Implementation phase subfolders
63
+ phase-2-<slug>/
64
+ ```
65
+
66
+ For small features, artifacts stay flat at root (no phase subfolders).
67
+
68
+ ## Gate Protocol
69
+
70
+ Every phase transition is a gate. Three outcomes:
71
+
72
+ - **Approve** — artifact accepted, proceed
73
+ - **Revise** — loop back, improve, re-gate
74
+ - **Kill** — write `killed.md` with reason and phase; update vision item status to `killed`
75
+
76
+ At every gate, always propose whether to proceed, skip, or revise. The difference between dial modes:
77
+ - **Gate:** Agent proposes, human decides
78
+ - **Flag:** Agent decides, human gets notified
79
+ - **Skip:** Agent decides silently
80
+
81
+ ### Codex Review
82
+
83
+ Any gate can include a Codex review pass. This is not limited to implementation — use it for design docs, PRDs, blueprints, plans, or code.
84
+
85
+ ```
86
+ Call mcp__stratum__stratum_agent_run with:
87
+ type: "codex"
88
+ prompt: "Review <artifact>. Output REVIEW CLEAN if no actionable findings remain."
89
+ ```
90
+
91
+ Fix all issues Codex flags. Re-run until REVIEW CLEAN. Max 5 iterations — if max hit, the problem is in the spec, surface to human.
92
+
93
+ If `mcp__stratum__stratum_agent_run` is unavailable (or returns a stream-chunk-size error — tracked as `STRAT-MCP-CHUNK-SIZE`), fall back options:
94
+
95
+ - **Programmatic / pipeline path:** dispatch a `general-purpose` Agent with an explicit reviewer prompt — the canonical `ReviewResult` schema (severity `must-fix`/`should-fix`/`nit`, confidence 1–10, gate `>= 7`) defined at `compose/contracts/review-result.json` is the contract for both paths.
96
+ - **Human-driven path:** invoke the OpenAI codex plugin's `/codex:review` (review-only) or `/codex:adversarial-review` (challenges design assumptions). These return Codex stdout verbatim and are not a drop-in for the canonical-JSON pipeline path, but they are the right tool when a human is in the loop.
97
+
98
+ ## Lifecycle (build mode)
99
+
100
+ ```
101
+ Phase 1: Explore & Design ──── gate ──→
102
+ Phase 2: PRD (skippable) ───── gate ──→
103
+ Phase 3: Architecture (skip) ─ gate ──→
104
+ Phase 4: Blueprint ─────────── gate ──→
105
+ Phase 5: Blueprint Verification gate ──→
106
+ Phase 6: Plan ──────────────── gate ──→
107
+ Phase 7: Execute + E2E + Review + Sweep ──→
108
+ ├─ Step 1: TDD execution
109
+ ├─ Step 2: E2E smoke test
110
+ ├─ Step 3: Review loop (till clean)
111
+ └─ Step 4: Coverage sweep (till clean)
112
+ Phase 8: Report (skippable) ── gate ──→
113
+ Phase 9: Update Docs ──────── gate ──→
114
+ Phase 10: Ship ─────────────────────────→ Done
115
+ ```
116
+
117
+ ## Lifecycle (fix mode)
118
+
119
+ ```
120
+ Phase F1: Triage ──────────────── gate ──→ (severity, scope, path: Quick/Standard/Hotfix)
121
+ Phase F2: Reproduce ───────────── gate ──→ (failing test or reliable repro)
122
+ Phase F3: Root Cause Investigate gate ──→ (superpowers:systematic-debugging)
123
+ Phase 6: Plan (often trivial) ── gate ──→
124
+ Phase 7: Execute + E2E + Review + Sweep ──→ (same four steps as build)
125
+ Phase 9: Update Docs ────────── gate ──→
126
+ Phase 10: Ship ────────────────────────────→ Done
127
+ ```
128
+
129
+ Phase 7 includes all four steps as exit criteria — you cannot exit without all completing. Quick path (trivial bug, known root cause, single file) collapses F1–F3 into a single triage step and skips Phase 9 docs unless the bug had user-visible behavior.
130
+
131
+ ## Phases
132
+
133
+ ### Phase 1: Explore & Design
134
+
135
+ **Agent:** `compose-explorer` (2-3 instances in parallel)
136
+
137
+ - Check compose MCP for existing vision item; create one if absent
138
+ - Create `docs/features/<feature-code>/` folder
139
+ - Launch 2-3 `compose-explorer` agents in parallel:
140
+ - "Find features similar to [feature] and trace their implementation"
141
+ - "Map the architecture and abstractions for [area]"
142
+ - "Analyze the current implementation of [related feature]"
143
+ - Understand the idea through one-question-at-a-time dialogue
144
+ - Explore 2-3 approaches with trade-offs
145
+ - Write to `docs/features/<feature-code>/design.md`
146
+ - Update vision item status to `in_progress`
147
+
148
+ **Gate checkpoint:** Does this design depend on unproven technical assumptions? If yes, list them. Spikes happen as roadmap tasks.
149
+
150
+ **Gate:** User approves design. Commit.
151
+
152
+ **Skip when:** Spec already exists.
153
+
154
+ ### Phase 2: Write PRD
155
+
156
+ Formalize into a PRD at `docs/features/<feature-code>/prd.md`. Sections: Problem Statement, Goals & Non-Goals, Requirements (MUST/SHOULD/MAY), Success Criteria, User Stories, Constraints & Assumptions, Open Questions.
157
+
158
+ **Gate:** All open questions resolved or deferred with rationale.
159
+
160
+ **Skip when:** PRD exists, or feature is purely internal with no user-facing requirements.
161
+
162
+ ### Phase 3: Architecture Doc
163
+
164
+ **Agent:** `compose-architect` (2-3 instances with competing mandates)
165
+
166
+ - **Minimal changes** — smallest possible change, maximum reuse
167
+ - **Clean architecture** — maintainability first, elegant abstractions
168
+ - **Pragmatic balance** — 80/20, good boundaries without over-engineering
169
+
170
+ Present all proposals, trade-offs, your recommendation. User picks. Write to `docs/features/<feature-code>/architecture.md`.
171
+
172
+ **Gate:** Component boundaries and interfaces clear enough for blueprint.
173
+
174
+ **Skip when:** Feature is small enough that design covers architecture.
175
+
176
+ ### Phase 4: Implementation Blueprint
177
+
178
+ **Agent:** `compose-explorer` (targeted research)
179
+
180
+ - Check for overlapping in-flight features: scan other `docs/features/*/blueprint.md` for shared file references
181
+ - Launch `compose-explorer` targeting the specific area
182
+ - Read every critical file, note patterns with line references
183
+ - Build corrections table (spec assumption vs reality)
184
+ - Write to `docs/features/<feature-code>/blueprint.md`
185
+
186
+ **Gate:** Corrections table empty or all corrections documented.
187
+
188
+ ### Phase 5: Blueprint Verification
189
+
190
+ For every file:line reference in the blueprint:
191
+ 1. Read the actual file at that line — does it match?
192
+ 2. Check function signatures
193
+ 3. Verify pattern claims
194
+ 4. Confirm imports/exports
195
+ 5. Flag stale references
196
+
197
+ Produce a verification table, append to `blueprint.md`. If any stale/wrong, loop back to Phase 4.
198
+
199
+ **Gate:** All file:line references verified. Zero stale entries.
200
+
201
+ **Skip when:** Blueprint written in the same session immediately after reading all referenced files.
202
+
203
+ ## Fix Mode Phases (F1–F3)
204
+
205
+ These replace Phases 1–5 when the entry verb is `/compose fix`. Phases 6, 7, 9, 10 are reused unchanged.
206
+
207
+ ### Phase F1: Triage
208
+
209
+ Gather enough information to select a path. Determine from context or ask:
210
+
211
+ 1. **What broke?** — observed vs expected behavior
212
+ 2. **Reproduction** — steps or failing test
213
+ 3. **Severity** — Trivial (cosmetic) / Normal (broken w/ workaround) / Critical (prod down, data loss, security)
214
+ 4. **Scope** — single file / multi-file / unknown
215
+ 5. **Root cause hypothesis** — already known?
216
+
217
+ **Path selection:**
218
+
219
+ | Path | When | Phases |
220
+ |---|---|---|
221
+ | **Quick** | Known root cause + single file | F1 → Phase 7 step 1 (TDD fix) → ship |
222
+ | **Standard** | Unknown root cause OR multi-file | F1 → F2 → F3 → 6 → 7 → 9 → 10 |
223
+ | **Hotfix** | Severity = Critical | F1 → F2 → F3 (time-boxed) → 7 → 10 (+cleanup follow-up) |
224
+
225
+ For Standard/Hotfix: create `docs/bugs/<bug-code>/` folder. Bug code matches vision item ID. Quick path skips the folder.
226
+
227
+ **Gate:** Agent proposes path with rationale. Human approves or redirects.
228
+
229
+ ### Phase F2: Reproduce
230
+
231
+ **Skill:** `superpowers:test-driven-development` (write the failing test first — it IS the spec for "fixed")
232
+
233
+ 1. Write a test that reproduces the bug deterministically
234
+ 2. Run it — confirm it fails for the right reason (not a setup error)
235
+ 3. Save artifacts to `docs/bugs/<bug-code>/repro.md` (steps, environment, test path)
236
+
237
+ **Gate:** Failing test exists and fails as expected. Stratum `ensure: failing_test_exists`.
238
+
239
+ **Skip when:** Quick path with obvious one-liner — but prefer not to skip; the test guards against regression.
240
+
241
+ ### Phase F3: Root Cause Investigate
242
+
243
+ **Skill:** `superpowers:systematic-debugging`
244
+
245
+ Follow the methodology: Reproduce → Hypothesize → Verify → Repeat. Apply `~/.claude/rules/correct-over-quick.md` (contract → spec → code → test, in that order) and `~/.claude/rules/test-architecture-first.md` (understand test intent before changing).
246
+
247
+ Write findings to `docs/bugs/<bug-code>/diagnosis.md`: root cause, evidence, fix approach, files affected, risk level.
248
+
249
+ **For Hotfix:** time-box. If root cause not found, fix the symptom with a `// HOTFIX:` comment and file a follow-up task for proper RCA. Note this in `diagnosis.md`.
250
+
251
+ **Gate:** Root cause documented. Fix approach approved by human. Risk level called out.
252
+
253
+ **Skip when:** Quick path — root cause was clear at triage.
254
+
255
+
256
+
257
+ Uses `EnterPlanMode`. Plan writes to `docs/features/<feature-code>/plan.md`.
258
+
259
+ - Break blueprint into ordered tasks with dependencies
260
+ - Each task: file path, what to do, pattern to follow, test to write
261
+ - Identify parallelizable tasks
262
+
263
+ **Gate:** User approves plan via `ExitPlanMode`.
264
+
265
+ ### Phase 7: Execute
266
+
267
+ **Execution skill selection:**
268
+
269
+ | Condition | Use |
270
+ |---|---|
271
+ | Independent tasks, parallelizable | `superpowers:dispatching-parallel-agents` |
272
+ | Sequential tasks with dependencies | `superpowers:executing-plans` |
273
+
274
+ - **REQUIRED:** TDD per task — write test first, watch fail, implement, watch pass
275
+ - **REQUIRED:** `superpowers:verification-before-completion` before marking any task done
276
+ - Use `superpowers:systematic-debugging` on any unexpected failure
277
+
278
+ **Blocker protocol:** If external blocker hit — record in feature folder, set vision item to `blocked`, surface to human.
279
+
280
+ **Gate:** All four steps complete:
281
+
282
+ 1. **All tasks executed** — tests pass
283
+ 2. **E2E smoke test** — start dev server (`npm run dev` from compose root — Vite on :5173, API on :3001, agent on :3002), run Playwright tests for affected flows
284
+ 3. **Review loop clean** — Codex reviews via `codex_run`, confidence >= 80, loop until `REVIEW CLEAN`
285
+ 4. **Coverage sweep clean** — loop until `TESTS PASSING`
286
+
287
+ **Step 3: Review Loop**
288
+
289
+ Run the Codex Review protocol (see Gate Protocol above) against the implementation.
290
+
291
+ **Step 4: Coverage Sweep**
292
+
293
+ ```
294
+ Write and run tests for the implementation in docs/features/<feature-code>/plan.md.
295
+ Focus on edge cases, error paths, cross-component integration.
296
+ Fix failing tests. Output TESTS PASSING when all pass.
297
+ ```
298
+
299
+ Max 15 iterations.
300
+
301
+ ### Phase 8: Implementation Report
302
+
303
+ Write to `docs/features/<feature-code>/report.md`:
304
+
305
+ 1. Summary
306
+ 2. Delivered vs Planned
307
+ 3. Architecture Deviations
308
+ 4. Key Implementation Decisions
309
+ 5. Test Coverage
310
+ 6. Files Changed
311
+ 7. Known Issues & Tech Debt
312
+ 8. Lessons Learned
313
+
314
+ **Gate:** Report complete and honest.
315
+
316
+ **Skip when:** Feature had no PRD or architecture doc (too small to warrant a report).
317
+
318
+ ### Phase 9: Update All Docs
319
+
320
+ - `CHANGELOG.md` — entry for this feature
321
+ - `README.md` — if setup, usage, or capabilities changed
322
+ - `CLAUDE.md` — if new commands, conventions, or architecture changed
323
+ - `ROADMAP.md` — update item status to `COMPLETE`
324
+ - Update vision item status to `complete`
325
+ - Bind the stratum flow to the vision item: `POST /api/stratum/bind` with the flow_id and vision item id
326
+
327
+ **Do NOT update** pre-implementation intent documents (PRD, architecture).
328
+
329
+ **Gate:** All doc surfaces reviewed and updated.
330
+
331
+ ### Phase 10: Review & Ship
332
+
333
+ - Final `superpowers:verification-before-completion`
334
+ - Verify all Phase 9 docs committed
335
+ - Call `stratum_audit` with `flow_id`, include trace in commit description
336
+ - Present options: merge, PR, or cleanup
337
+
338
+ ## Stratum Integration
339
+
340
+ Compose uses Stratum as the execution tracker. The `.stratum.yaml` spec is generated at invocation — never shown to the user. Claude Code is the executor; Stratum enforces that each phase produced a verifiable artifact before advancing.
341
+
342
+ ### When to Call Each Tool
343
+
344
+ - **`stratum_plan`** — once, after entry scan, before Phase 1. Flow: `compose_feature`.
345
+ - **`stratum_step_done`** — after each step's gate is approved.
346
+ - **`stratum_audit`** — in Phase 10 before committing. Bind result to vision item via `POST /api/stratum/bind`.
347
+
348
+ If Stratum unavailable, continue with flat prompt chain.
349
+
350
+ ### Step → Phase Mapping
351
+
352
+ **Build mode** uses flow `compose_feature`:
353
+
354
+ | Step | Phases |
355
+ |---|---|
356
+ | `research` | Phase 1 exploration. No human gate. |
357
+ | `write_design` | Phase 1 design + optional Phase 2 PRD + optional Phase 3 Architecture. Gate after Phase 1. |
358
+ | `write_blueprint` | Phase 4 + Phase 5 verification. Gate after Phase 5. |
359
+ | `implement` | Phase 7 — TDD, E2E, review loop, coverage sweep. Gate after all four steps. |
360
+
361
+ **Fix mode** uses flow `bug_fix` from `compose/pipelines/bug-fix.stratum.yaml` (8 steps, all already implemented):
362
+
363
+ | Step | Phase | Retries | Ensure | Iteration role |
364
+ |---|---|---|---|---|
365
+ | `reproduce` | F2 | 2 | — | failing test or repro confirmed |
366
+ | `diagnose` | F3 | 2 | `trace_evidence ≥ 2`, `root_cause != null`, `scope_hint in {single,cross-layer,unknown}` | forces real command output, not assumptions |
367
+ | `scope_check` | F3 | 1 | — | greps all configured project repos for cross-layer references |
368
+ | `fix` | 7 step 1 | 2 | — | minimal correct fix across all affected layers |
369
+ | `test` | 7 step 4 | **5** | `result.passing == true` | **inner fix-and-retest loop** — Stratum re-runs until all tests pass or cap hit |
370
+ | `verify` | 7 | 1 | — | original repro now passes |
371
+ | `retro_check` | — | 1 | — | scans git history for fix chains; **hard stop at attempt 2 for visual/CSS bugs**, triggers cross-agent escalation |
372
+ | `ship` | 10 | 1 | — | commit + CHANGELOG |
373
+
374
+ Triage is implicit on entry (severity, scope, path) — it gates which steps to run, not a Stratum step itself. Phases 6 (plan), 9 (docs) are folded into `fix` and `ship` respectively.
375
+
376
+ ### Spec Template
377
+
378
+ ```yaml
379
+ version: "0.1"
380
+ contracts:
381
+ ResearchResult:
382
+ findings: {type: array}
383
+ relevant_files: {type: array}
384
+ DesignResult:
385
+ path: {type: string}
386
+ word_count: {type: integer}
387
+ BlueprintResult:
388
+ path: {type: string}
389
+ ImplementResult:
390
+ files_changed: {type: array}
391
+ tests_pass: {type: boolean}
392
+
393
+ functions:
394
+ research:
395
+ mode: compute
396
+ intent: "Explore the codebase with compose-explorer agents and surface patterns relevant to the feature."
397
+ input: {description: {type: string}}
398
+ output: ResearchResult
399
+ ensure:
400
+ - "len(result.findings) > 0"
401
+ retries: 2
402
+
403
+ write_design:
404
+ mode: compute
405
+ intent: "Run Phase 1 (and optional Phases 2-3) — explore, gate, write design.md."
406
+ input: {description: {type: string}}
407
+ output: DesignResult
408
+ ensure:
409
+ - "file_exists(result.path)"
410
+ - "result.word_count > 200"
411
+ retries: 2
412
+
413
+ write_blueprint:
414
+ mode: compute
415
+ intent: "Run Phases 4-5 — blueprint, verification. Gate before returning."
416
+ input: {description: {type: string}}
417
+ output: BlueprintResult
418
+ ensure:
419
+ - "file_exists(result.path)"
420
+ retries: 2
421
+
422
+ implement:
423
+ mode: compute
424
+ intent: "Run Phase 7 — TDD, E2E, review loop, coverage sweep."
425
+ input: {description: {type: string}}
426
+ output: ImplementResult
427
+ ensure:
428
+ - "result.tests_pass == True"
429
+ - "len(result.files_changed) > 0"
430
+ retries: 2
431
+
432
+ flows:
433
+ compose_feature:
434
+ input: {description: {type: string}}
435
+ output: ImplementResult
436
+ steps:
437
+ - id: research
438
+ function: research
439
+ inputs: {description: "$.input.description"}
440
+ output_schema:
441
+ type: object
442
+ required: [findings]
443
+ properties:
444
+ findings: {type: array, items: {type: string}}
445
+ relevant_files: {type: array, items: {type: string}}
446
+
447
+ - id: write_design
448
+ function: write_design
449
+ inputs: {description: "$.input.description"}
450
+ depends_on: [research]
451
+ output_schema:
452
+ type: object
453
+ required: [path, word_count]
454
+ properties:
455
+ path: {type: string}
456
+ word_count: {type: integer}
457
+
458
+ - id: write_blueprint
459
+ function: write_blueprint
460
+ inputs: {description: "$.input.description"}
461
+ depends_on: [write_design]
462
+ output_schema:
463
+ type: object
464
+ required: [path]
465
+ properties:
466
+ path: {type: string}
467
+
468
+ - id: implement
469
+ function: implement
470
+ inputs: {description: "$.input.description"}
471
+ depends_on: [write_blueprint]
472
+ output_schema:
473
+ type: object
474
+ required: [files_changed, tests_pass]
475
+ properties:
476
+ files_changed: {type: array, items: {type: string}}
477
+ tests_pass: {type: boolean}
478
+
479
+ ```
480
+
481
+ The bugfix flow lives in `compose/pipelines/bug-fix.stratum.yaml` (8 steps + bisect, ships with compose). The CLI entry `compose fix <bug-code>` (in `bin/compose.js`) reads `docs/bugs/<code>/description.md` (scaffolds and exits if missing) and dispatches `runBuild(code, { mode: 'bug', template: 'bug-fix', description })`.
482
+
483
+ ### Hard-bug machinery (COMP-FIX-HARD, 2026-05-01)
484
+
485
+ For genuinely hard bugs the pipeline gains persistent state across attempts and sessions, structured second opinions, and a fresh-context retry path:
486
+
487
+ - **Hypothesis ledger** at `docs/bugs/<code>/hypotheses.jsonl` (JSONL, idempotent on `(attempt, ts)`). `diagnose` retries see a "Previously Rejected" block prepended via `buildRetryPrompt` so they don't re-propose disproven theories. Every successful diagnose plus every Tier 1 escalation appends an entry.
488
+ - **Compose-side retry-cap enforcement.** Stratum's `retries:` field is declared-but-not-enforced in `executor.py` (tracked as `STRAT-RETRIES-ENFORCE`). Compose parses the YAML at flow start, builds a per-step cap map, and force-terminates when `iterN > maxIter`. In bug mode for `{test, fix, diagnose}`, terminal-failure also emits `docs/bugs/<code>/checkpoint.md` (current diff, last failure, ledger pointer, `compose fix <code> --resume` command).
489
+ - **`docs/bugs/INDEX.md`** rendered atomically from per-bug checkpoints (same pattern as `roadmap-gen.js`).
490
+ - **`bisect` step** sits between `diagnose` and `scope_check`. `classifyRegression` heuristic (test in main + affected files touched in last 10 commits) decides whether to gate the human; cost estimator samples one test run with a 5-min timeout; `runBisect` always calls `git bisect reset` in finally.
491
+ - **`compose fix --resume`** re-enters the failed step with full ledger context. Active-build state carries `mode` and `pid`; resume refuses if another live process owns the build or if the active mode mismatches.
492
+ - **Two-tier escalation**, both gated, neither auto-commits:
493
+ - Tier 1: `stratum.runAgentText('codex', ...)` second opinion, parsed to canonical `ReviewResult`, appended to ledger as `verdict: 'escalation_tier_1'`.
494
+ - Tier 2: only fires when Codex's hypothesis is materially new (Jaccard token-overlap < 0.7 vs prior rejected entries). `git worktree add <path> --detach HEAD`, fresh `claude` agent dispatched with explicit DO-NOT-COMMIT prompt, produces `docs/bugs/<code>/escalation-patch-N.md`. `git worktree remove --force` in finally; `rm -rf` fallback. Detached HEAD is the defense-in-depth: even if the agent ignores the prompt, commits orphan and never reach a branch.
495
+ - **`debug-discipline.js`** is per-bug-keyed. `AttemptCounter`/`FixChainDetector` use a `byBug` Map; legacy global API preserved via synthetic `__feature_mode__` key. Existing thresholds preserved verbatim: visual@2, all@5.
496
+
497
+ The CLI scaffold for `description.md` is the bug-mode equivalent of feature-mode's `description.md`/`feature.json`. Fields the agent should fill in: symptom, repro steps, expected vs actual, environment.
498
+
499
+ ### Result Dict Shapes
500
+
501
+ ```python
502
+ # research
503
+ {"findings": ["pattern A", "pattern B"], "relevant_files": ["server/index.js"]}
504
+
505
+ # write_design
506
+ {"path": "docs/features/FEAT-1/design.md", "word_count": 450}
507
+
508
+ # write_blueprint
509
+ {"path": "docs/features/FEAT-1/blueprint.md"}
510
+
511
+ # implement
512
+ {"files_changed": ["server/index.js", "src/components/Foo.jsx"], "tests_pass": True}
513
+ ```
514
+
515
+ ### Narration Pattern
516
+
517
+ Never mention `.stratum.yaml`, `stratum_plan`, or step IDs to the user:
518
+
519
+ ```
520
+ Checking project state and exploring codebase...
521
+ Writing design doc...
522
+ Writing implementation blueprint...
523
+ Implementing...
524
+ ```
525
+
526
+ ## Entry: Scan First
527
+
528
+ When `/compose` is invoked, always scan first:
529
+
530
+ 1. Read compose MCP: `get_vision_items` for the feature code, `get_current_session` for context
531
+ 2. Check `docs/features/<feature-code>/`. If absent, start at Phase 1.
532
+ 3. If folder exists, read every file. Summarize what's covered and what's missing.
533
+ 4. If `status.md` exists, read it for resume point, then delete it.
534
+ 5. Propose starting phase with rationale. Human approves.
535
+
536
+ ## Phase Selection
537
+
538
+ | Folder State | Action |
539
+ |---|---|
540
+ | No folder | Start Phase 1 |
541
+ | `status.md` | Read for resume point, delete, start indicated phase |
542
+ | `design.md` | Review, fill gaps, gate |
543
+ | `prd.md` / `architecture.md` | Review completeness. If solid, proceed to Phase 4. |
544
+ | `blueprint.md` | Verify (Phase 5). Never skip verification. |
545
+ | `plan.md` | Review against current code. If accurate, execute (Phase 7). |
546
+ | Code + tests done | E2E, review, sweep (Phase 7 steps 2-4), then docs (Phase 9). |
547
+
548
+ **Phase 7's E2E and loops are never skipped.** They self-terminate on clean input.
549
+
550
+ ## Cross-Cutting Agents & Skills
551
+
552
+ | Agent/Skill | When |
553
+ |---|---|
554
+ | `compose-explorer` | Phase 1 (2-3 parallel), Phase 4 (targeted) |
555
+ | `compose-architect` | Phase 3 (2-3 competing mandates) |
556
+ | `mcp__stratum__stratum_agent_run(type="codex")` | Any gate — Codex review pass (see Gate Protocol) |
557
+ | `general-purpose` Agent | Reviewer fallback when `stratum_agent_run` unavailable; prompt with canonical `ReviewResult` schema |
558
+ | `superpowers:systematic-debugging` | Phase F3 (fix mode) and any unexpected failure (build mode) |
559
+ | `superpowers:test-driven-development` | Phase F2 (fix mode), Phase 7 step 1 (both modes) |
560
+ | `superpowers:verification-before-completion` | Before any task/phase done |
561
+ | `superpowers:requesting-code-review` | Phase 7 review step (fallback when Codex unavailable) |
562
+ | `interface-design:init` | Phase 7 — new UI components |
563
+ | `interface-design:critique` | Phase 7 — after building UI |
564
+ | `interface-design:audit` | Phase 7 — check UI against design system |
565
+ | `refactor` | Phase 7 — when review finds large files |
566
+ | `update-docs` | Phase 9 |
567
+
568
+ **Note on dependencies:** these skills are referenced by name and must be installed on the user's machine. See `## Dependencies` below for the install contract — `compose setup` only ships compose-owned skills today; external deps are documented but not auto-installed.
569
+
570
+ ## Memory
571
+
572
+ After completing a feature OR bug-fix lifecycle, update project memory:
573
+ - Architecture decisions made
574
+ - Patterns discovered during blueprint or diagnosis
575
+ - Corrections that apply broadly
576
+ - For bugfix: root-cause class (off-by-one, race, contract drift, etc.) — helps spot repeats
577
+
578
+ ## Dependencies
579
+
580
+ `compose setup` (see `bin/compose.js` `syncSkills()`) installs compose-owned skills from `PACKAGE_ROOT/.claude/skills/` and `PACKAGE_ROOT/skills/` to `~/.claude/skills/` and tracks them in `~/.claude/skills/.compose-skills.json`.
581
+
582
+ ### Vendored (ship with compose)
583
+
584
+ | Skill | Source | Why vendored |
585
+ |---|---|---|
586
+ | `compose` | `compose/.claude/skills/compose/` | Core lifecycle |
587
+ | `stratum` | `compose/skills/stratum/` (if present) | Execution substrate |
588
+ | `compose-explorer`, `compose-architect` | agents under `compose/.claude/agents/` | Required by Phases 1, 3, 4 |
589
+
590
+ ### External dependencies (NOT auto-installed)
591
+
592
+ Authoritative list lives in `compose/.compose-deps.json`. Run `compose doctor` to see what's installed locally and `compose doctor --json` for machine-readable output. The manifest is the single source of truth for external dep IDs and per-dep `fallback` behavior — this SKILL.md never duplicates per-dep fallback strings.
593
+
594
+ The manifest declares 12 external skills/commands across `superpowers:*`, `interface-design:*`, `codex:review`, `refactor`, and `update-docs`. Each entry carries `id`, `required_for`, `install`, `fallback` (or null), and `optional`.
595
+
596
+ ### Degrade pattern
597
+
598
+ At lifecycle entry (Phase 1), run `compose doctor --json`. For each missing dep:
599
+
600
+ - If `optional: false` and `fallback` is non-null → use the `fallback` value, surface a warning to the user, continue.
601
+ - If `optional: false` and `fallback` is null → block the lifecycle and surface the `install` command to the user.
602
+ - If `optional: true` → skip the affected step and log a warning in the phase report.
603
+
604
+ If the CLI is unavailable (PATH issue, sandbox), fall back to reading `~/.claude/skills/compose/.compose-deps.json` (copied alongside this SKILL.md by `compose setup`).