@bhargavvc/sdd-cc 1.30.0 → 1.35.0

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 (242) hide show
  1. package/README.ja-JP.md +144 -110
  2. package/README.ko-KR.md +143 -107
  3. package/README.md +183 -112
  4. package/README.pt-BR.md +90 -52
  5. package/README.zh-CN.md +141 -101
  6. package/agents/sdd-advisor-researcher.md +23 -0
  7. package/agents/sdd-ai-researcher.md +133 -0
  8. package/agents/sdd-code-fixer.md +516 -0
  9. package/agents/sdd-code-reviewer.md +355 -0
  10. package/agents/sdd-codebase-mapper.md +3 -3
  11. package/agents/sdd-debugger.md +17 -5
  12. package/agents/sdd-doc-verifier.md +201 -0
  13. package/agents/sdd-doc-writer.md +602 -0
  14. package/agents/sdd-domain-researcher.md +153 -0
  15. package/agents/sdd-eval-auditor.md +164 -0
  16. package/agents/sdd-eval-planner.md +154 -0
  17. package/agents/sdd-executor.md +87 -4
  18. package/agents/sdd-framework-selector.md +160 -0
  19. package/agents/sdd-intel-updater.md +314 -0
  20. package/agents/sdd-nyquist-auditor.md +1 -1
  21. package/agents/sdd-phase-researcher.md +71 -4
  22. package/agents/sdd-plan-checker.md +100 -6
  23. package/agents/sdd-planner.md +145 -206
  24. package/agents/sdd-project-researcher.md +25 -2
  25. package/agents/sdd-research-synthesizer.md +3 -3
  26. package/agents/sdd-roadmapper.md +6 -6
  27. package/agents/sdd-security-auditor.md +128 -0
  28. package/agents/sdd-ui-auditor.md +43 -3
  29. package/agents/sdd-ui-checker.md +5 -5
  30. package/agents/sdd-ui-researcher.md +27 -4
  31. package/agents/sdd-user-profiler.md +2 -2
  32. package/agents/sdd-verifier.md +142 -22
  33. package/bin/install.js +2151 -551
  34. package/commands/sdd/add-backlog.md +5 -5
  35. package/commands/sdd/add-tests.md +2 -2
  36. package/commands/sdd/ai-integration-phase.md +36 -0
  37. package/commands/sdd/analyze-dependencies.md +34 -0
  38. package/commands/sdd/audit-fix.md +33 -0
  39. package/commands/sdd/autonomous.md +7 -2
  40. package/commands/sdd/cleanup.md +5 -0
  41. package/commands/sdd/code-review-fix.md +52 -0
  42. package/commands/sdd/code-review.md +55 -0
  43. package/commands/sdd/complete-milestone.md +6 -6
  44. package/commands/sdd/debug.md +22 -9
  45. package/commands/sdd/discuss-phase.md +7 -2
  46. package/commands/sdd/do.md +1 -1
  47. package/commands/sdd/docs-update.md +48 -0
  48. package/commands/sdd/eval-review.md +32 -0
  49. package/commands/sdd/execute-phase.md +4 -0
  50. package/commands/sdd/explore.md +27 -0
  51. package/commands/sdd/fast.md +2 -2
  52. package/commands/sdd/from-sdd2.md +45 -0
  53. package/commands/sdd/help.md +2 -0
  54. package/commands/sdd/import.md +36 -0
  55. package/commands/sdd/intel.md +179 -0
  56. package/commands/sdd/join-discord.md +2 -1
  57. package/commands/sdd/manager.md +1 -0
  58. package/commands/sdd/map-codebase.md +3 -3
  59. package/commands/sdd/new-milestone.md +1 -1
  60. package/commands/sdd/new-project.md +5 -1
  61. package/commands/sdd/new-workspace.md +1 -1
  62. package/commands/sdd/next.md +2 -0
  63. package/commands/sdd/plan-milestone-gaps.md +2 -2
  64. package/commands/sdd/plan-phase.md +6 -1
  65. package/commands/sdd/plant-seed.md +1 -1
  66. package/commands/sdd/profile-user.md +1 -1
  67. package/commands/sdd/quick.md +5 -3
  68. package/commands/sdd/reapply-patches.md +230 -42
  69. package/commands/sdd/research-phase.md +3 -3
  70. package/commands/sdd/review-backlog.md +1 -0
  71. package/commands/sdd/review.md +6 -3
  72. package/commands/sdd/scan.md +26 -0
  73. package/commands/sdd/secure-phase.md +35 -0
  74. package/commands/sdd/ship.md +1 -1
  75. package/commands/sdd/thread.md +5 -5
  76. package/commands/sdd/undo.md +34 -0
  77. package/commands/sdd/verify-work.md +1 -1
  78. package/commands/sdd/workstreams.md +17 -11
  79. package/hooks/dist/sdd-check-update.js +33 -8
  80. package/hooks/dist/sdd-context-monitor.js +17 -8
  81. package/hooks/dist/sdd-phase-boundary.sh +27 -0
  82. package/hooks/dist/sdd-prompt-guard.js +1 -0
  83. package/hooks/dist/sdd-read-guard.js +82 -0
  84. package/hooks/dist/sdd-session-state.sh +33 -0
  85. package/hooks/dist/sdd-statusline.js +137 -15
  86. package/hooks/dist/sdd-validate-commit.sh +47 -0
  87. package/hooks/dist/sdd-workflow-guard.js +4 -4
  88. package/hooks/sdd-check-update.js +139 -0
  89. package/hooks/sdd-context-monitor.js +165 -0
  90. package/hooks/sdd-phase-boundary.sh +27 -0
  91. package/hooks/sdd-prompt-guard.js +97 -0
  92. package/hooks/sdd-read-guard.js +82 -0
  93. package/hooks/sdd-session-state.sh +33 -0
  94. package/hooks/sdd-statusline.js +241 -0
  95. package/hooks/sdd-validate-commit.sh +47 -0
  96. package/hooks/sdd-workflow-guard.js +94 -0
  97. package/package.json +3 -3
  98. package/scripts/build-hooks.js +18 -7
  99. package/scripts/prompt-injection-scan.sh +1 -0
  100. package/scripts/rebrand-gsd-to-sdd.sh +221 -220
  101. package/scripts/run-tests.cjs +5 -1
  102. package/scripts/sync-upstream.sh +1 -1
  103. package/sdd/bin/lib/commands.cjs +79 -17
  104. package/sdd/bin/lib/config.cjs +90 -48
  105. package/sdd/bin/lib/core.cjs +452 -87
  106. package/sdd/bin/lib/docs.cjs +267 -0
  107. package/sdd/bin/lib/frontmatter.cjs +381 -336
  108. package/sdd/bin/lib/init.cjs +110 -16
  109. package/sdd/bin/lib/intel.cjs +660 -0
  110. package/sdd/bin/lib/learnings.cjs +378 -0
  111. package/sdd/bin/lib/milestone.cjs +42 -11
  112. package/sdd/bin/lib/model-profiles.cjs +17 -15
  113. package/sdd/bin/lib/phase.cjs +367 -288
  114. package/sdd/bin/lib/profile-output.cjs +106 -10
  115. package/sdd/bin/lib/roadmap.cjs +146 -115
  116. package/sdd/bin/lib/schema-detect.cjs +238 -0
  117. package/sdd/bin/lib/sdd2-import.cjs +511 -0
  118. package/sdd/bin/lib/security.cjs +124 -3
  119. package/sdd/bin/lib/state.cjs +648 -264
  120. package/sdd/bin/lib/template.cjs +8 -4
  121. package/sdd/bin/lib/verify.cjs +209 -28
  122. package/sdd/bin/lib/workstream.cjs +7 -3
  123. package/sdd/bin/sdd-tools.cjs +184 -12
  124. package/sdd/contexts/dev.md +21 -0
  125. package/sdd/contexts/research.md +22 -0
  126. package/sdd/contexts/review.md +22 -0
  127. package/sdd/references/agent-contracts.md +79 -0
  128. package/sdd/references/ai-evals.md +156 -0
  129. package/sdd/references/ai-frameworks.md +186 -0
  130. package/sdd/references/artifact-types.md +113 -0
  131. package/sdd/references/common-bug-patterns.md +114 -0
  132. package/sdd/references/context-budget.md +49 -0
  133. package/sdd/references/continuation-format.md +25 -25
  134. package/sdd/references/domain-probes.md +125 -0
  135. package/sdd/references/few-shot-examples/plan-checker.md +73 -0
  136. package/sdd/references/few-shot-examples/verifier.md +109 -0
  137. package/sdd/references/gate-prompts.md +100 -0
  138. package/sdd/references/gates.md +70 -0
  139. package/sdd/references/git-integration.md +1 -1
  140. package/sdd/references/ios-scaffold.md +123 -0
  141. package/sdd/references/model-profile-resolution.md +2 -0
  142. package/sdd/references/model-profiles.md +24 -18
  143. package/sdd/references/planner-gap-closure.md +62 -0
  144. package/sdd/references/planner-reviews.md +39 -0
  145. package/sdd/references/planner-revision.md +87 -0
  146. package/sdd/references/planning-config.md +252 -0
  147. package/sdd/references/revision-loop.md +97 -0
  148. package/sdd/references/thinking-models-debug.md +44 -0
  149. package/sdd/references/thinking-models-execution.md +50 -0
  150. package/sdd/references/thinking-models-planning.md +62 -0
  151. package/sdd/references/thinking-models-research.md +50 -0
  152. package/sdd/references/thinking-models-verification.md +55 -0
  153. package/sdd/references/thinking-partner.md +96 -0
  154. package/sdd/references/ui-brand.md +4 -4
  155. package/sdd/references/universal-anti-patterns.md +63 -0
  156. package/sdd/references/verification-overrides.md +227 -0
  157. package/sdd/references/workstream-flag.md +56 -3
  158. package/sdd/templates/AI-SPEC.md +246 -0
  159. package/sdd/templates/DEBUG.md +1 -1
  160. package/sdd/templates/SECURITY.md +61 -0
  161. package/sdd/templates/UAT.md +4 -4
  162. package/sdd/templates/VALIDATION.md +4 -4
  163. package/sdd/templates/claude-md.md +32 -9
  164. package/sdd/templates/config.json +4 -0
  165. package/sdd/templates/debug-subagent-prompt.md +1 -1
  166. package/sdd/templates/dev-preferences.md +1 -1
  167. package/sdd/templates/discovery.md +2 -2
  168. package/sdd/templates/phase-prompt.md +1 -1
  169. package/sdd/templates/planner-subagent-prompt.md +3 -3
  170. package/sdd/templates/project.md +1 -1
  171. package/sdd/templates/research.md +1 -1
  172. package/sdd/templates/state.md +2 -2
  173. package/sdd/workflows/add-phase.md +8 -8
  174. package/sdd/workflows/add-tests.md +12 -9
  175. package/sdd/workflows/add-todo.md +5 -3
  176. package/sdd/workflows/ai-integration-phase.md +284 -0
  177. package/sdd/workflows/analyze-dependencies.md +96 -0
  178. package/sdd/workflows/audit-fix.md +157 -0
  179. package/sdd/workflows/audit-milestone.md +11 -11
  180. package/sdd/workflows/audit-uat.md +2 -2
  181. package/sdd/workflows/autonomous.md +195 -27
  182. package/sdd/workflows/check-todos.md +12 -10
  183. package/sdd/workflows/cleanup.md +2 -0
  184. package/sdd/workflows/code-review-fix.md +497 -0
  185. package/sdd/workflows/code-review.md +515 -0
  186. package/sdd/workflows/complete-milestone.md +56 -22
  187. package/sdd/workflows/diagnose-issues.md +10 -3
  188. package/sdd/workflows/discovery-phase.md +5 -3
  189. package/sdd/workflows/discuss-phase-assumptions.md +24 -6
  190. package/sdd/workflows/discuss-phase-power.md +291 -0
  191. package/sdd/workflows/discuss-phase.md +173 -21
  192. package/sdd/workflows/do.md +23 -21
  193. package/sdd/workflows/docs-update.md +1155 -0
  194. package/sdd/workflows/eval-review.md +155 -0
  195. package/sdd/workflows/execute-phase.md +594 -38
  196. package/sdd/workflows/execute-plan.md +67 -96
  197. package/sdd/workflows/explore.md +139 -0
  198. package/sdd/workflows/fast.md +5 -5
  199. package/sdd/workflows/forensics.md +2 -2
  200. package/sdd/workflows/health.md +4 -4
  201. package/sdd/workflows/help.md +122 -119
  202. package/sdd/workflows/import.md +276 -0
  203. package/sdd/workflows/inbox.md +387 -0
  204. package/sdd/workflows/insert-phase.md +7 -7
  205. package/sdd/workflows/list-phase-assumptions.md +4 -4
  206. package/sdd/workflows/list-workspaces.md +2 -2
  207. package/sdd/workflows/manager.md +35 -32
  208. package/sdd/workflows/map-codebase.md +7 -5
  209. package/sdd/workflows/milestone-summary.md +2 -2
  210. package/sdd/workflows/new-milestone.md +17 -9
  211. package/sdd/workflows/new-project.md +50 -25
  212. package/sdd/workflows/new-workspace.md +7 -5
  213. package/sdd/workflows/next.md +67 -11
  214. package/sdd/workflows/note.md +9 -7
  215. package/sdd/workflows/pause-work.md +75 -12
  216. package/sdd/workflows/plan-milestone-gaps.md +8 -8
  217. package/sdd/workflows/plan-phase.md +294 -42
  218. package/sdd/workflows/plant-seed.md +6 -3
  219. package/sdd/workflows/pr-branch.md +42 -14
  220. package/sdd/workflows/profile-user.md +9 -7
  221. package/sdd/workflows/progress.md +45 -45
  222. package/sdd/workflows/quick.md +195 -47
  223. package/sdd/workflows/remove-phase.md +6 -6
  224. package/sdd/workflows/remove-workspace.md +3 -1
  225. package/sdd/workflows/research-phase.md +2 -2
  226. package/sdd/workflows/resume-project.md +12 -12
  227. package/sdd/workflows/review.md +109 -9
  228. package/sdd/workflows/scan.md +102 -0
  229. package/sdd/workflows/secure-phase.md +166 -0
  230. package/sdd/workflows/session-report.md +2 -2
  231. package/sdd/workflows/settings.md +38 -12
  232. package/sdd/workflows/ship.md +21 -9
  233. package/sdd/workflows/stats.md +1 -1
  234. package/sdd/workflows/transition.md +23 -23
  235. package/sdd/workflows/ui-phase.md +15 -7
  236. package/sdd/workflows/ui-review.md +29 -4
  237. package/sdd/workflows/undo.md +314 -0
  238. package/sdd/workflows/update.md +171 -20
  239. package/sdd/workflows/validate-phase.md +6 -4
  240. package/sdd/workflows/verify-phase.md +210 -6
  241. package/sdd/workflows/verify-work.md +83 -9
  242. package/sdd/commands/sdd/workstreams.md +0 -63
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sdd-plan-checker
3
- description: Verifies plans will achieve phase goal before execution. Goal-backward analysis of plan quality. Spawned by /sdd:plan-phase orchestrator.
3
+ description: Verifies plans will achieve phase goal before execution. Goal-backward analysis of plan quality. Spawned by /sdd-plan-phase orchestrator.
4
4
  tools: Read, Bash, Glob, Grep
5
5
  color: green
6
6
  ---
@@ -8,7 +8,7 @@ color: green
8
8
  <role>
9
9
  You are a SDD plan checker. Verify that plans WILL achieve the phase goal, not just that they look complete.
10
10
 
11
- Spawned by `/sdd:plan-phase` orchestrator (after planner creates PLAN.md) or re-verification (after planner revises).
11
+ Spawned by `/sdd-plan-phase` orchestrator (after planner creates PLAN.md) or re-verification (after planner revises).
12
12
 
13
13
  Goal-backward verification of PLANS before execution. Start from what the phase SHOULD deliver, verify plans address it.
14
14
 
@@ -26,6 +26,12 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool t
26
26
  You are NOT the executor or verifier — you verify plans WILL work before execution burns context.
27
27
  </role>
28
28
 
29
+ <required_reading>
30
+ @~/.claude/sdd/references/gates.md
31
+ </required_reading>
32
+
33
+ This agent implements the **Revision Gate** pattern (bounded quality loop with escalation on cap exhaustion).
34
+
29
35
  <project_context>
30
36
  Before verifying, discover project context:
31
37
 
@@ -42,7 +48,7 @@ This ensures verification checks that plans follow project-specific conventions.
42
48
  </project_context>
43
49
 
44
50
  <upstream_input>
45
- **CONTEXT.md** (if exists) — User decisions from `/sdd:discuss-phase`
51
+ **CONTEXT.md** (if exists) — User decisions from `/sdd-discuss-phase`
46
52
 
47
53
  | Section | How You Use It |
48
54
  |---------|----------------|
@@ -80,6 +86,12 @@ Same methodology (goal-backward), different timing, different subject matter.
80
86
 
81
87
  <verification_dimensions>
82
88
 
89
+ At decision points during plan verification, apply structured reasoning:
90
+ @~/.claude/sdd/references/thinking-models-planning.md
91
+
92
+ For calibration on scoring and issue identification, reference these examples:
93
+ @~/.claude/sdd/references/few-shot-examples/plan-checker.md
94
+
83
95
  ## Dimension 1: Requirement Coverage
84
96
 
85
97
  **Question:** Does every phase requirement have task(s) addressing it?
@@ -271,7 +283,7 @@ issue:
271
283
 
272
284
  ## Dimension 7: Context Compliance (if CONTEXT.md exists)
273
285
 
274
- **Question:** Do plans honor user decisions from /sdd:discuss-phase?
286
+ **Question:** Do plans honor user decisions from /sdd-discuss-phase?
275
287
 
276
288
  **Only check if CONTEXT.md was provided in the verification context.**
277
289
 
@@ -314,6 +326,49 @@ issue:
314
326
  fix_hint: "Remove search task - belongs in future phase per user decision"
315
327
  ```
316
328
 
329
+ ## Dimension 7b: Scope Reduction Detection
330
+
331
+ **Question:** Did the planner silently simplify user decisions instead of delivering them fully?
332
+
333
+ **This is the most insidious failure mode:** Plans reference D-XX but deliver only a fraction of what the user decided. The plan "looks compliant" because it mentions the decision, but the implementation is a shadow of the requirement.
334
+
335
+ **Process:**
336
+ 1. For each task action in all plans, scan for scope reduction language:
337
+ - `"v1"`, `"v2"`, `"simplified"`, `"static for now"`, `"hardcoded"`
338
+ - `"future enhancement"`, `"placeholder"`, `"basic version"`, `"minimal"`
339
+ - `"will be wired later"`, `"dynamic in future"`, `"skip for now"`
340
+ - `"not wired to"`, `"not connected to"`, `"stub"`
341
+ 2. For each match, cross-reference with the CONTEXT.md decision it claims to implement
342
+ 3. Compare: does the task deliver what D-XX actually says, or a reduced version?
343
+ 4. If reduced: BLOCKER — the planner must either deliver fully or propose phase split
344
+
345
+ **Red flags (from real incident):**
346
+ - CONTEXT.md D-26: "Config exibe referências de custo calculados em impulsos a partir da tabela de preços"
347
+ - Plan says: "D-26 cost references (v1 — static labels). NOT wired to billingPrecosOriginaisModel — dynamic pricing display is a future enhancement"
348
+ - This is a BLOCKER: the planner invented "v1/v2" versioning that doesn't exist in the user's decision
349
+
350
+ **Severity:** ALWAYS BLOCKER. Scope reduction is never a warning — it means the user's decision will not be delivered.
351
+
352
+ **Example:**
353
+ ```yaml
354
+ issue:
355
+ dimension: scope_reduction
356
+ severity: blocker
357
+ description: "Plan reduces D-26 from 'calculated costs in impulses' to 'static hardcoded labels'"
358
+ plan: "03"
359
+ task: 1
360
+ decision: "D-26: Config exibe referências de custo calculados em impulsos"
361
+ plan_action: "static labels v1 — NOT wired to billing"
362
+ fix_hint: "Either implement D-26 fully (fetch from billingPrecosOriginaisModel) or return PHASE SPLIT RECOMMENDED"
363
+ ```
364
+
365
+ **Fix path:** When scope reduction is detected, the checker returns ISSUES FOUND with recommendation:
366
+ ```
367
+ Plans reduce {N} user decisions. Options:
368
+ 1. Revise plans to deliver decisions fully (may increase plan count)
369
+ 2. Split phase: [suggested grouping of D-XX into sub-phases]
370
+ ```
371
+
317
372
  ## Dimension 8: Nyquist Compliance
318
373
 
319
374
  Skip if: `workflow.nyquist_validation` is explicitly set to `false` in config.json (absent key = enabled), phase has no RESEARCH.md, or RESEARCH.md has no "Validation Architecture" section. Output: "Dimension 8: SKIPPED (nyquist_validation disabled or not applicable)"
@@ -326,7 +381,7 @@ Before running checks 8a-8d, verify VALIDATION.md exists:
326
381
  ls "${PHASE_DIR}"/*-VALIDATION.md 2>/dev/null
327
382
  ```
328
383
 
329
- **If missing:** **BLOCKING FAIL** — "VALIDATION.md not found for phase {N}. Re-run `/sdd:plan-phase {N} --research` to regenerate."
384
+ **If missing:** **BLOCKING FAIL** — "VALIDATION.md not found for phase {N}. Re-run `/sdd-plan-phase {N} --research` to regenerate."
330
385
  Skip checks 8a-8d entirely. Report Dimension 8 as FAIL with this single issue.
331
386
 
332
387
  **If exists:** Proceed to checks 8a-8d.
@@ -435,6 +490,45 @@ issue:
435
490
  fix_hint: "Add eslint verification step to each task's <verify> block"
436
491
  ```
437
492
 
493
+ ## Dimension 11: Research Resolution (#1602)
494
+
495
+ **Question:** Are all research questions resolved before planning proceeds?
496
+
497
+ **Skip if:** No RESEARCH.md exists for this phase.
498
+
499
+ **Process:**
500
+ 1. Read the phase's RESEARCH.md file
501
+ 2. Search for a `## Open Questions` section
502
+ 3. If section heading has `(RESOLVED)` suffix → PASS
503
+ 4. If section exists: check each listed question for inline `RESOLVED` marker
504
+ 5. FAIL if any question lacks a resolution
505
+
506
+ **Red flags:**
507
+ - RESEARCH.md has `## Open Questions` section without `(RESOLVED)` suffix
508
+ - Individual questions listed without resolution status
509
+ - Prose-style open questions that haven't been addressed
510
+
511
+ **Example — unresolved questions:**
512
+ ```yaml
513
+ issue:
514
+ dimension: research_resolution
515
+ severity: blocker
516
+ description: "RESEARCH.md has unresolved open questions"
517
+ file: "01-RESEARCH.md"
518
+ unresolved_questions:
519
+ - "Hash prefix — keep or change?"
520
+ - "Cache TTL — what duration?"
521
+ fix_hint: "Resolve questions and mark section as '## Open Questions (RESOLVED)'"
522
+ ```
523
+
524
+ **Example — resolved (PASS):**
525
+ ```markdown
526
+ ## Open Questions (RESOLVED)
527
+
528
+ 1. **Hash prefix** — RESOLVED: Use "guest_contract:"
529
+ 2. **Cache TTL** — RESOLVED: 5 minutes with Redis
530
+ ```
531
+
438
532
  </verification_dimensions>
439
533
 
440
534
  <verification_process>
@@ -693,7 +787,7 @@ Return all issues as a structured `issues:` YAML list (see dimension examples fo
693
787
  | 01 | 3 | 5 | 1 | Valid |
694
788
  | 02 | 2 | 4 | 2 | Valid |
695
789
 
696
- Plans verified. Run `/sdd:execute-phase {phase}` to proceed.
790
+ Plans verified. Run `/sdd-execute-phase {phase}` to proceed.
697
791
  ```
698
792
 
699
793
  ## ISSUES FOUND
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sdd-planner
3
- description: Creates executable phase plans with task breakdown, dependency analysis, and goal-backward verification. Spawned by /sdd:plan-phase orchestrator.
3
+ description: Creates executable phase plans with task breakdown, dependency analysis, and goal-backward verification. Spawned by /sdd-plan-phase orchestrator.
4
4
  tools: Read, Write, Bash, Glob, Grep, WebFetch, mcp__context7__*
5
5
  color: green
6
6
  # hooks:
@@ -15,10 +15,10 @@ color: green
15
15
  You are a SDD planner. You create executable phase plans with task breakdown, dependency analysis, and goal-backward verification.
16
16
 
17
17
  Spawned by:
18
- - `/sdd:plan-phase` orchestrator (standard phase planning)
19
- - `/sdd:plan-phase --gaps` orchestrator (gap closure from verification failures)
20
- - `/sdd:plan-phase` in revision mode (updating plans based on checker feedback)
21
- - `/sdd:plan-phase --reviews` orchestrator (replanning with cross-AI review feedback)
18
+ - `/sdd-plan-phase` orchestrator (standard phase planning)
19
+ - `/sdd-plan-phase --gaps` orchestrator (gap closure from verification failures)
20
+ - `/sdd-plan-phase` in revision mode (updating plans based on checker feedback)
21
+ - `/sdd-plan-phase --reviews` orchestrator (replanning with cross-AI review feedback)
22
22
 
23
23
  Your job: Produce PLAN.md files that Claude executors can implement without interpretation. Plans are prompts, not documents that become prompts.
24
24
 
@@ -35,6 +35,16 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool t
35
35
  - Return structured results to orchestrator
36
36
  </role>
37
37
 
38
+ <documentation_lookup>
39
+ For library docs: use Context7 MCP (`mcp__context7__*`) if available. If not (upstream
40
+ bug #13898 strips MCP from `tools:`-restricted agents), use the Bash CLI fallback:
41
+ ```bash
42
+ npx --yes ctx7@latest library <name> "<query>" # resolve library ID
43
+ npx --yes ctx7@latest docs <libraryId> "<query>" # fetch docs
44
+ ```
45
+ Do not skip — the CLI fallback works via Bash and produces equivalent output.
46
+ </documentation_lookup>
47
+
38
48
  <project_context>
39
49
  Before planning, discover project context:
40
50
 
@@ -53,7 +63,7 @@ This ensures task actions reference the correct patterns and libraries for this
53
63
  <context_fidelity>
54
64
  ## CRITICAL: User Decision Fidelity
55
65
 
56
- The orchestrator provides user decisions in `<user_decisions>` tags from `/sdd:discuss-phase`.
66
+ The orchestrator provides user decisions in `<user_decisions>` tags from `/sdd-discuss-phase`.
57
67
 
58
68
  **Before creating ANY task, verify:**
59
69
 
@@ -81,6 +91,45 @@ The orchestrator provides user decisions in `<user_decisions>` tags from `/sdd:d
81
91
  - Note in task action: "Using X per user decision (research suggested Y)"
82
92
  </context_fidelity>
83
93
 
94
+ <scope_reduction_prohibition>
95
+ ## CRITICAL: Never Simplify User Decisions — Split Instead
96
+
97
+ **PROHIBITED language/patterns in task actions:**
98
+ - "v1", "v2", "simplified version", "static for now", "hardcoded for now"
99
+ - "future enhancement", "placeholder", "basic version", "minimal implementation"
100
+ - "will be wired later", "dynamic in future phase", "skip for now"
101
+ - Any language that reduces a CONTEXT.md decision to less than what the user decided
102
+
103
+ **The rule:** If D-XX says "display cost calculated from billing table in impulses", the plan MUST deliver cost calculated from billing table in impulses. NOT "static label /min" as a "v1".
104
+
105
+ **When the phase is too complex to implement ALL decisions:**
106
+
107
+ Do NOT silently simplify decisions. Instead:
108
+
109
+ 1. **Create a decision coverage matrix** mapping every D-XX to a plan/task
110
+ 2. **If any D-XX cannot fit** within the plan budget (too many tasks, too complex):
111
+ - Return `## PHASE SPLIT RECOMMENDED` to the orchestrator
112
+ - Propose how to split: which D-XX groups form natural sub-phases
113
+ - Example: "D-01 to D-19 = Phase 17a (processing core), D-20 to D-27 = Phase 17b (billing + config UX)"
114
+ 3. The orchestrator will present the split to the user for approval
115
+ 4. After approval, plan each sub-phase within budget
116
+
117
+ **Why this matters:** The user spent time making decisions. Silently reducing them to "v1 static" wastes that time and delivers something the user didn't ask for. Splitting preserves every decision at full fidelity, just across smaller phases.
118
+
119
+ **Decision coverage matrix (MANDATORY in every plan set):**
120
+
121
+ Before finalizing plans, produce internally:
122
+
123
+ ```
124
+ D-XX | Plan | Task | Full/Partial | Notes
125
+ D-01 | 01 | 1 | Full |
126
+ D-02 | 01 | 2 | Full |
127
+ D-23 | 03 | 1 | PARTIAL | ← BLOCKER: must be Full or split phase
128
+ ```
129
+
130
+ If ANY decision is "Partial" → either fix the task to deliver fully, or return PHASE SPLIT RECOMMENDED.
131
+ </scope_reduction_prohibition>
132
+
84
133
  <philosophy>
85
134
 
86
135
  ## Solo Developer + Claude Workflow
@@ -148,7 +197,7 @@ Discovery is MANDATORY unless you can prove current context exists.
148
197
  - Level 2+: New library not in package.json, external API, "choose/select/evaluate" in description
149
198
  - Level 3: "architecture/design/system", multiple external services, data modeling, auth design
150
199
 
151
- For niche domains (3D, games, audio, shaders, ML), suggest `/sdd:research-phase` before plan-phase.
200
+ For niche domains (3D, games, audio, shaders, ML), suggest `/sdd-research-phase` before plan-phase.
152
201
 
153
202
  </discovery_levels>
154
203
 
@@ -454,6 +503,21 @@ Output: [Artifacts created]
454
503
 
455
504
  </tasks>
456
505
 
506
+ <threat_model>
507
+ ## Trust Boundaries
508
+
509
+ | Boundary | Description |
510
+ |----------|-------------|
511
+ | {e.g., client→API} | {untrusted input crosses here} |
512
+
513
+ ## STRIDE Threat Register
514
+
515
+ | Threat ID | Category | Component | Disposition | Mitigation Plan |
516
+ |-----------|----------|-----------|-------------|-----------------|
517
+ | T-{phase}-01 | {S/T/R/I/D/E} | {function/endpoint/file} | mitigate | {specific: e.g., "validate input with zod at route entry"} |
518
+ | T-{phase}-02 | {category} | {component} | accept | {rationale: e.g., "no PII, low-value target"} |
519
+ </threat_model>
520
+
457
521
  <verification>
458
522
  [Overall phase checks]
459
523
  </verification>
@@ -585,6 +649,8 @@ Only include what Claude literally cannot do.
585
649
  **Step 0: Extract Requirement IDs**
586
650
  Read ROADMAP.md `**Requirements:**` line for this phase. Strip brackets if present (e.g., `[AUTH-01, AUTH-02]` → `AUTH-01, AUTH-02`). Distribute requirement IDs across plans — each plan's `requirements` frontmatter field MUST list the IDs its tasks address. **CRITICAL:** Every requirement ID MUST appear in at least one plan. Plans with an empty `requirements` field are invalid.
587
651
 
652
+ **Security (when `security_enforcement` enabled — absent = enabled):** Identify trust boundaries in this phase's scope. Map STRIDE categories to applicable tech stack from RESEARCH.md security domain. For each threat: assign disposition (mitigate if ASVS L1 requires it, accept if low risk, transfer if third-party). Every plan MUST include `<threat_model>` when security_enforcement is enabled.
653
+
588
654
  **Step 1: State the Goal**
589
655
  Take phase goal from ROADMAP.md. Must be outcome-shaped, not task-shaped.
590
656
  - Good: "Working chat interface" (outcome)
@@ -811,204 +877,18 @@ TDD plans target ~40% context (lower than standard 50%). The RED→GREEN→REFAC
811
877
  </tdd_integration>
812
878
 
813
879
  <gap_closure_mode>
814
-
815
- ## Planning from Verification Gaps
816
-
817
- Triggered by `--gaps` flag. Creates plans to address verification or UAT failures.
818
-
819
- **1. Find gap sources:**
820
-
821
- Use init context (from load_project_state) which provides `phase_dir`:
822
-
823
- ```bash
824
- # Check for VERIFICATION.md (code verification gaps)
825
- ls "$phase_dir"/*-VERIFICATION.md 2>/dev/null
826
-
827
- # Check for UAT.md with diagnosed status (user testing gaps)
828
- grep -l "status: diagnosed" "$phase_dir"/*-UAT.md 2>/dev/null
829
- ```
830
-
831
- **2. Parse gaps:** Each gap has: truth (failed behavior), reason, artifacts (files with issues), missing (things to add/fix).
832
-
833
- **3. Load existing SUMMARYs** to understand what's already built.
834
-
835
- **4. Find next plan number:** If plans 01-03 exist, next is 04.
836
-
837
- **5. Group gaps into plans** by: same artifact, same concern, dependency order (can't wire if artifact is stub → fix stub first).
838
-
839
- **6. Create gap closure tasks:**
840
-
841
- ```xml
842
- <task name="{fix_description}" type="auto">
843
- <files>{artifact.path}</files>
844
- <action>
845
- {For each item in gap.missing:}
846
- - {missing item}
847
-
848
- Reference existing code: {from SUMMARYs}
849
- Gap reason: {gap.reason}
850
- </action>
851
- <verify>{How to confirm gap is closed}</verify>
852
- <done>{Observable truth now achievable}</done>
853
- </task>
854
- ```
855
-
856
- **7. Assign waves using standard dependency analysis** (same as `assign_waves` step):
857
- - Plans with no dependencies → wave 1
858
- - Plans that depend on other gap closure plans → max(dependency waves) + 1
859
- - Also consider dependencies on existing (non-gap) plans in the phase
860
-
861
- **8. Write PLAN.md files:**
862
-
863
- ```yaml
864
- ---
865
- phase: XX-name
866
- plan: NN # Sequential after existing
867
- type: execute
868
- wave: N # Computed from depends_on (see assign_waves)
869
- depends_on: [...] # Other plans this depends on (gap or existing)
870
- files_modified: [...]
871
- autonomous: true
872
- gap_closure: true # Flag for tracking
873
- ---
874
- ```
875
-
880
+ See `sdd/references/planner-gap-closure.md`. Load this file at the
881
+ start of execution when `--gaps` flag is detected or gap_closure mode is active.
876
882
  </gap_closure_mode>
877
883
 
878
884
  <revision_mode>
879
-
880
- ## Planning from Checker Feedback
881
-
882
- Triggered when orchestrator provides `<revision_context>` with checker issues. NOT starting fresh — making targeted updates to existing plans.
883
-
884
- **Mindset:** Surgeon, not architect. Minimal changes for specific issues.
885
-
886
- ### Step 1: Load Existing Plans
887
-
888
- ```bash
889
- cat .planning/phases/$PHASE-*/$PHASE-*-PLAN.md
890
- ```
891
-
892
- Build mental model of current plan structure, existing tasks, must_haves.
893
-
894
- ### Step 2: Parse Checker Issues
895
-
896
- Issues come in structured format:
897
-
898
- ```yaml
899
- issues:
900
- - plan: "16-01"
901
- dimension: "task_completeness"
902
- severity: "blocker"
903
- description: "Task 2 missing <verify> element"
904
- fix_hint: "Add verification command for build output"
905
- ```
906
-
907
- Group by plan, dimension, severity.
908
-
909
- ### Step 3: Revision Strategy
910
-
911
- | Dimension | Strategy |
912
- |-----------|----------|
913
- | requirement_coverage | Add task(s) for missing requirement |
914
- | task_completeness | Add missing elements to existing task |
915
- | dependency_correctness | Fix depends_on, recompute waves |
916
- | key_links_planned | Add wiring task or update action |
917
- | scope_sanity | Split into multiple plans |
918
- | must_haves_derivation | Derive and add must_haves to frontmatter |
919
-
920
- ### Step 4: Make Targeted Updates
921
-
922
- **DO:** Edit specific flagged sections, preserve working parts, update waves if dependencies change.
923
-
924
- **DO NOT:** Rewrite entire plans for minor issues, add unnecessary tasks, break existing working plans.
925
-
926
- ### Step 5: Validate Changes
927
-
928
- - [ ] All flagged issues addressed
929
- - [ ] No new issues introduced
930
- - [ ] Wave numbers still valid
931
- - [ ] Dependencies still correct
932
- - [ ] Files on disk updated
933
-
934
- ### Step 6: Commit
935
-
936
- ```bash
937
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "fix($PHASE): revise plans based on checker feedback" --files .planning/phases/$PHASE-*/$PHASE-*-PLAN.md
938
- ```
939
-
940
- ### Step 7: Return Revision Summary
941
-
942
- ```markdown
943
- ## REVISION COMPLETE
944
-
945
- **Issues addressed:** {N}/{M}
946
-
947
- ### Changes Made
948
-
949
- | Plan | Change | Issue Addressed |
950
- |------|--------|-----------------|
951
- | 16-01 | Added <verify> to Task 2 | task_completeness |
952
- | 16-02 | Added logout task | requirement_coverage (AUTH-02) |
953
-
954
- ### Files Updated
955
-
956
- - .planning/phases/16-xxx/16-01-PLAN.md
957
- - .planning/phases/16-xxx/16-02-PLAN.md
958
-
959
- {If any issues NOT addressed:}
960
-
961
- ### Unaddressed Issues
962
-
963
- | Issue | Reason |
964
- |-------|--------|
965
- | {issue} | {why - needs user input, architectural change, etc.} |
966
- ```
967
-
885
+ See `sdd/references/planner-revision.md`. Load this file at the
886
+ start of execution when `<revision_context>` is provided by the orchestrator.
968
887
  </revision_mode>
969
888
 
970
889
  <reviews_mode>
971
-
972
- ## Planning from Cross-AI Review Feedback
973
-
974
- Triggered when orchestrator sets Mode to `reviews`. Replanning from scratch with REVIEWS.md feedback as additional context.
975
-
976
- **Mindset:** Fresh planner with review insights — not a surgeon making patches, but an architect who has read peer critiques.
977
-
978
- ### Step 1: Load REVIEWS.md
979
- Read the reviews file from `<files_to_read>`. Parse:
980
- - Per-reviewer feedback (strengths, concerns, suggestions)
981
- - Consensus Summary (agreed concerns = highest priority to address)
982
- - Divergent Views (investigate, make a judgment call)
983
-
984
- ### Step 2: Categorize Feedback
985
- Group review feedback into:
986
- - **Must address**: HIGH severity consensus concerns
987
- - **Should address**: MEDIUM severity concerns from 2+ reviewers
988
- - **Consider**: Individual reviewer suggestions, LOW severity items
989
-
990
- ### Step 3: Plan Fresh with Review Context
991
- Create new plans following the standard planning process, but with review feedback as additional constraints:
992
- - Each HIGH severity consensus concern MUST have a task that addresses it
993
- - MEDIUM concerns should be addressed where feasible without over-engineering
994
- - Note in task actions: "Addresses review concern: {concern}" for traceability
995
-
996
- ### Step 4: Return
997
- Use standard PLANNING COMPLETE return format, adding a reviews section:
998
-
999
- ```markdown
1000
- ### Review Feedback Addressed
1001
-
1002
- | Concern | Severity | How Addressed |
1003
- |---------|----------|---------------|
1004
- | {concern} | HIGH | Plan {N}, Task {M}: {how} |
1005
-
1006
- ### Review Feedback Deferred
1007
- | Concern | Reason |
1008
- |---------|--------|
1009
- | {concern} | {why — out of scope, disagree, etc.} |
1010
- ```
1011
-
890
+ See `sdd/references/planner-reviews.md`. Load this file at the
891
+ start of execution when `--reviews` flag is present or reviews mode is active.
1012
892
  </reviews_mode>
1013
893
 
1014
894
  <execution_flow>
@@ -1031,6 +911,18 @@ cat .planning/STATE.md 2>/dev/null
1031
911
  If STATE.md missing but .planning/ exists, offer to reconstruct or continue without.
1032
912
  </step>
1033
913
 
914
+ <step name="load_mode_context">
915
+ Check the invocation mode and load the relevant reference file:
916
+
917
+ - If `--gaps` flag or gap_closure context present: Read `sdd/references/planner-gap-closure.md`
918
+ - If `<revision_context>` provided by orchestrator: Read `sdd/references/planner-revision.md`
919
+ - If `--reviews` flag present or reviews mode active: Read `sdd/references/planner-reviews.md`
920
+ - Standard planning mode: no additional file to read
921
+
922
+ Load the file before proceeding to planning steps. The reference file contains the full
923
+ instructions for operating in that mode.
924
+ </step>
925
+
1034
926
  <step name="load_codebase_context">
1035
927
  Check for codebase map:
1036
928
 
@@ -1118,12 +1010,16 @@ Read the most recent milestone retrospective and cross-milestone trends. Extract
1118
1010
  - **Cost patterns** to inform model selection and agent strategy
1119
1011
  </step>
1120
1012
 
1013
+ <step name="inject_global_learnings">
1014
+ If `features.global_learnings` is `true`: run `sdd-tools learnings query --tag <phase_tags> --limit 5`, prefix matches with `[Prior learning from <project>]` as weak priors. Project-local decisions take precedence. Skip silently if disabled or no matches. For tags, use PLAN.md frontmatter `tags` field or keywords from the phase objective, comma-separated (e.g. `--tag auth,database,api`).
1015
+ </step>
1016
+
1121
1017
  <step name="gather_phase_context">
1122
1018
  Use `phase_dir` from init context (already loaded in load_project_state).
1123
1019
 
1124
1020
  ```bash
1125
- cat "$phase_dir"/*-CONTEXT.md 2>/dev/null # From /sdd:discuss-phase
1126
- cat "$phase_dir"/*-RESEARCH.md 2>/dev/null # From /sdd:research-phase
1021
+ cat "$phase_dir"/*-CONTEXT.md 2>/dev/null # From /sdd-discuss-phase
1022
+ cat "$phase_dir"/*-RESEARCH.md 2>/dev/null # From /sdd-research-phase
1127
1023
  cat "$phase_dir"/*-DISCOVERY.md 2>/dev/null # From mandatory discovery
1128
1024
  ```
1129
1025
 
@@ -1133,6 +1029,9 @@ cat "$phase_dir"/*-DISCOVERY.md 2>/dev/null # From mandatory discovery
1133
1029
  </step>
1134
1030
 
1135
1031
  <step name="break_into_tasks">
1032
+ At decision points during plan creation, apply structured reasoning:
1033
+ @~/.claude/sdd/references/thinking-models-planning.md
1034
+
1136
1035
  Decompose phase into tasks. **Think dependencies first, not sequence.**
1137
1036
 
1138
1037
  For each task:
@@ -1160,13 +1059,22 @@ for each plan in plan_order:
1160
1059
  else:
1161
1060
  plan.wave = max(waves[dep] for dep in plan.depends_on) + 1
1162
1061
  waves[plan.id] = plan.wave
1062
+
1063
+ # Implicit dependency: files_modified overlap forces a later wave.
1064
+ for each plan B in plan_order:
1065
+ for each earlier plan A where A != B:
1066
+ if any file in B.files_modified is also in A.files_modified:
1067
+ B.wave = max(B.wave, A.wave + 1)
1068
+ waves[B.id] = B.wave
1163
1069
  ```
1070
+
1071
+ **Rule:** Same-wave plans must have zero `files_modified` overlap. After assigning waves, scan each wave; if any file appears in 2+ plans, bump the later plan to the next wave and repeat.
1164
1072
  </step>
1165
1073
 
1166
1074
  <step name="group_into_plans">
1167
1075
  Rules:
1168
1076
  1. Same-wave tasks with no file conflicts → parallel plans
1169
- 2. Shared files → same plan or sequential plans
1077
+ 2. Shared files → same plan or sequential plans (shared file = implicit dependency → later wave)
1170
1078
  3. Checkpoint tasks → `autonomous: false`
1171
1079
  4. Each plan: 2-3 tasks, single concern, ~50% context target
1172
1080
  </step>
@@ -1180,6 +1088,15 @@ Apply goal-backward methodology (see goal_backward section):
1180
1088
  5. Identify key links (critical connections)
1181
1089
  </step>
1182
1090
 
1091
+ <step name="reachability_check">
1092
+ For each must-have artifact, verify a concrete path exists:
1093
+ - Entity → in-phase or existing creation path
1094
+ - Workflow → user action or API call triggers it
1095
+ - Config flag → default value + consumer
1096
+ - UI → route or nav link
1097
+ UNREACHABLE (no path) → revise plan.
1098
+ </step>
1099
+
1183
1100
  <step name="estimate_scope">
1184
1101
  Verify each plan fits context budget: 2-3 tasks, ~50% target. Split if necessary. Check granularity setting.
1185
1102
  </step>
@@ -1193,7 +1110,26 @@ Use template structure for each PLAN.md.
1193
1110
 
1194
1111
  **ALWAYS use the Write tool to create files** — never use `Bash(cat << 'EOF')` or heredoc commands for file creation.
1195
1112
 
1196
- Write to `.planning/phases/XX-name/{phase}-{NN}-PLAN.md`
1113
+ **CRITICAL File naming convention (enforced):**
1114
+
1115
+ The filename MUST follow the exact pattern: `{padded_phase}-{NN}-PLAN.md`
1116
+
1117
+ - `{padded_phase}` = zero-padded phase number received from the orchestrator (e.g. `01`, `02`, `03`, `02.1`)
1118
+ - `{NN}` = zero-padded sequential plan number within the phase (e.g. `01`, `02`, `03`)
1119
+ - The suffix is always `-PLAN.md` — NEVER `PLAN-NN.md`, `NN-PLAN.md`, or any other variation
1120
+
1121
+ **Correct examples:**
1122
+ - Phase 1, Plan 1 → `01-01-PLAN.md`
1123
+ - Phase 3, Plan 2 → `03-02-PLAN.md`
1124
+ - Phase 2.1, Plan 1 → `02.1-01-PLAN.md`
1125
+
1126
+ **Incorrect (will break sdd-tools detection):**
1127
+ - ❌ `PLAN-01-auth.md`
1128
+ - ❌ `01-PLAN-01.md`
1129
+ - ❌ `plan-01.md`
1130
+ - ❌ `01-01-plan.md` (lowercase)
1131
+
1132
+ Full write path: `.planning/phases/{padded_phase}-{slug}/{padded_phase}-{NN}-PLAN.md`
1197
1133
 
1198
1134
  Include all frontmatter fields.
1199
1135
  </step>
@@ -1288,7 +1224,7 @@ Return structured planning outcome to orchestrator.
1288
1224
 
1289
1225
  ### Next Steps
1290
1226
 
1291
- Execute: `/sdd:execute-phase {phase}`
1227
+ Execute: `/sdd-execute-phase {phase}`
1292
1228
 
1293
1229
  <sub>`/clear` first - fresh context window</sub>
1294
1230
  ```
@@ -1309,7 +1245,7 @@ Execute: `/sdd:execute-phase {phase}`
1309
1245
 
1310
1246
  ### Next Steps
1311
1247
 
1312
- Execute: `/sdd:execute-phase {phase} --gaps-only`
1248
+ Execute: `/sdd-execute-phase {phase} --gaps-only`
1313
1249
  ```
1314
1250
 
1315
1251
  ## Checkpoint Reached / Revision Complete
@@ -1338,6 +1274,9 @@ Phase planning complete when:
1338
1274
  - [ ] Wave structure maximizes parallelism
1339
1275
  - [ ] PLAN file(s) committed to git
1340
1276
  - [ ] User knows next steps and wave structure
1277
+ - [ ] `<threat_model>` present with STRIDE register (when `security_enforcement` enabled)
1278
+ - [ ] Every threat has a disposition (mitigate / accept / transfer)
1279
+ - [ ] Mitigations reference specific implementation (not generic advice)
1341
1280
 
1342
1281
  ## Gap Closure Mode
1343
1282
 
@@ -1349,6 +1288,6 @@ Planning complete when:
1349
1288
  - [ ] PLAN file(s) exist with gap_closure: true
1350
1289
  - [ ] Each plan: tasks derived from gap.missing items
1351
1290
  - [ ] PLAN file(s) committed to git
1352
- - [ ] User knows to run `/sdd:execute-phase {X}` next
1291
+ - [ ] User knows to run `/sdd-execute-phase {X}` next
1353
1292
 
1354
1293
  </success_criteria>