claude-code-workflow 7.2.23 → 7.2.25

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 (212) hide show
  1. package/.ccw/workflows/cli-tools-usage.md +123 -521
  2. package/.claude/skills/brainstorm/SKILL.md +408 -408
  3. package/.claude/skills/review-cycle/SKILL.md +132 -132
  4. package/.claude/skills/spec-generator/SKILL.md +1 -1
  5. package/.claude/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  6. package/.claude/skills/team-lifecycle-v4/SKILL.md +1 -1
  7. package/.claude/skills/team-review/SKILL.md +1 -1
  8. package/.claude/skills/team-ultra-analyze/SKILL.md +1 -1
  9. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +1 -1
  10. package/.claude/skills/workflow-plan/SKILL.md +1 -1
  11. package/.claude/skills/workflow-test-fix/SKILL.md +1 -1
  12. package/.codex/skills/analyze-with-file/SKILL.md +966 -966
  13. package/.codex/skills/issue-discover/SKILL.md +361 -361
  14. package/.codex/skills/review-cycle/SKILL.md +1 -1
  15. package/.codex/skills/roadmap-with-file/SKILL.md +901 -901
  16. package/.codex/skills/spec-generator/SKILL.md +425 -425
  17. package/.codex/skills/spec-setup/SKILL.md +669 -669
  18. package/.codex/skills/team-arch-opt/SKILL.md +242 -175
  19. package/.codex/skills/team-arch-opt/roles/analyzer/role.md +78 -78
  20. package/.codex/skills/team-arch-opt/roles/coordinator/commands/analyze.md +57 -57
  21. package/.codex/skills/team-arch-opt/roles/coordinator/commands/monitor.md +246 -204
  22. package/.codex/skills/team-arch-opt/roles/coordinator/role.md +196 -184
  23. package/.codex/skills/team-arch-opt/roles/designer/role.md +115 -115
  24. package/.codex/skills/team-arch-opt/roles/refactorer/role.md +102 -102
  25. package/.codex/skills/team-arch-opt/roles/reviewer/role.md +111 -111
  26. package/.codex/skills/team-arch-opt/roles/validator/role.md +115 -115
  27. package/.codex/skills/team-arch-opt/specs/pipelines.md +102 -102
  28. package/.codex/skills/team-brainstorm/SKILL.md +72 -4
  29. package/.codex/skills/team-brainstorm/roles/challenger/role.md +61 -61
  30. package/.codex/skills/team-brainstorm/roles/coordinator/commands/analyze.md +58 -58
  31. package/.codex/skills/team-brainstorm/roles/coordinator/commands/monitor.md +212 -171
  32. package/.codex/skills/team-brainstorm/roles/coordinator/role.md +172 -160
  33. package/.codex/skills/team-brainstorm/roles/evaluator/role.md +56 -56
  34. package/.codex/skills/team-brainstorm/roles/ideator/role.md +69 -69
  35. package/.codex/skills/team-brainstorm/roles/synthesizer/role.md +57 -57
  36. package/.codex/skills/team-brainstorm/specs/pipelines.md +72 -72
  37. package/.codex/skills/team-coordinate/SKILL.md +71 -3
  38. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +45 -5
  39. package/.codex/skills/team-coordinate/roles/coordinator/role.md +402 -389
  40. package/.codex/skills/team-coordinate/specs/knowledge-transfer.md +111 -111
  41. package/.codex/skills/team-coordinate/specs/pipelines.md +97 -97
  42. package/.codex/skills/team-coordinate/specs/quality-gates.md +112 -112
  43. package/.codex/skills/team-designer/SKILL.md +153 -153
  44. package/.codex/skills/team-designer/phases/01-requirements-analysis.md +250 -250
  45. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +228 -228
  46. package/.codex/skills/team-designer/phases/03-content-generation.md +330 -330
  47. package/.codex/skills/team-designer/phases/04-validation.md +320 -320
  48. package/.codex/skills/team-executor/SKILL.md +29 -2
  49. package/.codex/skills/team-executor/roles/executor/commands/monitor.md +23 -15
  50. package/.codex/skills/team-frontend/SKILL.md +77 -3
  51. package/.codex/skills/team-frontend/roles/analyst/role.md +92 -92
  52. package/.codex/skills/team-frontend/roles/architect/role.md +86 -86
  53. package/.codex/skills/team-frontend/roles/coordinator/commands/analyze.md +52 -52
  54. package/.codex/skills/team-frontend/roles/coordinator/commands/monitor.md +222 -188
  55. package/.codex/skills/team-frontend/roles/coordinator/role.md +189 -177
  56. package/.codex/skills/team-frontend/roles/developer/role.md +93 -93
  57. package/.codex/skills/team-frontend/roles/qa/role.md +79 -79
  58. package/.codex/skills/team-frontend/specs/pipelines.md +76 -76
  59. package/.codex/skills/team-frontend-debug/SKILL.md +66 -3
  60. package/.codex/skills/team-frontend-debug/roles/analyzer/role.md +208 -208
  61. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/analyze.md +174 -174
  62. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/dispatch.md +198 -198
  63. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/monitor.md +177 -143
  64. package/.codex/skills/team-frontend-debug/roles/coordinator/role.md +164 -152
  65. package/.codex/skills/team-frontend-debug/roles/fixer/role.md +147 -147
  66. package/.codex/skills/team-frontend-debug/roles/reproducer/role.md +147 -147
  67. package/.codex/skills/team-frontend-debug/roles/tester/role.md +231 -231
  68. package/.codex/skills/team-frontend-debug/roles/verifier/role.md +172 -172
  69. package/.codex/skills/team-frontend-debug/specs/debug-tools.md +215 -215
  70. package/.codex/skills/team-frontend-debug/specs/pipelines.md +94 -94
  71. package/.codex/skills/team-issue/SKILL.md +83 -4
  72. package/.codex/skills/team-issue/roles/coordinator/commands/analyze.md +64 -64
  73. package/.codex/skills/team-issue/roles/coordinator/commands/dispatch.md +273 -273
  74. package/.codex/skills/team-issue/roles/coordinator/commands/monitor.md +235 -194
  75. package/.codex/skills/team-issue/roles/coordinator/role.md +206 -194
  76. package/.codex/skills/team-issue/roles/explorer/role.md +94 -94
  77. package/.codex/skills/team-issue/roles/implementer/role.md +87 -87
  78. package/.codex/skills/team-issue/roles/integrator/role.md +84 -84
  79. package/.codex/skills/team-issue/roles/planner/role.md +81 -81
  80. package/.codex/skills/team-issue/roles/reviewer/role.md +86 -86
  81. package/.codex/skills/team-issue/specs/pipelines.md +124 -124
  82. package/.codex/skills/team-lifecycle-v4/MIGRATION-PLAN.md +6 -6
  83. package/.codex/skills/team-lifecycle-v4/SKILL.md +305 -242
  84. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/dispatch.md +1 -1
  85. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/monitor.md +66 -24
  86. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +13 -1
  87. package/.codex/skills/team-lifecycle-v4/roles/supervisor/role.md +1 -1
  88. package/.codex/skills/team-lifecycle-v4/templates/architecture.md +254 -254
  89. package/.codex/skills/team-lifecycle-v4/templates/epics.md +196 -196
  90. package/.codex/skills/team-lifecycle-v4/templates/product-brief.md +133 -133
  91. package/.codex/skills/team-lifecycle-v4/templates/requirements.md +224 -224
  92. package/.codex/skills/team-perf-opt/SKILL.md +68 -3
  93. package/.codex/skills/team-perf-opt/roles/benchmarker/role.md +89 -89
  94. package/.codex/skills/team-perf-opt/roles/coordinator/commands/analyze.md +61 -61
  95. package/.codex/skills/team-perf-opt/roles/coordinator/commands/monitor.md +35 -1
  96. package/.codex/skills/team-perf-opt/roles/coordinator/role.md +179 -167
  97. package/.codex/skills/team-perf-opt/roles/optimizer/role.md +97 -97
  98. package/.codex/skills/team-perf-opt/roles/profiler/role.md +73 -73
  99. package/.codex/skills/team-perf-opt/roles/reviewer/role.md +75 -75
  100. package/.codex/skills/team-perf-opt/roles/strategist/role.md +94 -94
  101. package/.codex/skills/team-perf-opt/specs/pipelines.md +65 -65
  102. package/.codex/skills/team-planex/SKILL.md +65 -3
  103. package/.codex/skills/team-planex/roles/coordinator/commands/analyze.md +52 -52
  104. package/.codex/skills/team-planex/roles/coordinator/commands/monitor.md +210 -164
  105. package/.codex/skills/team-planex/roles/coordinator/role.md +171 -159
  106. package/.codex/skills/team-planex/roles/executor/role.md +91 -91
  107. package/.codex/skills/team-planex/roles/planner/role.md +112 -112
  108. package/.codex/skills/team-planex/specs/pipelines.md +93 -93
  109. package/.codex/skills/team-quality-assurance/SKILL.md +60 -3
  110. package/.codex/skills/team-quality-assurance/roles/analyst/role.md +80 -80
  111. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/analyze.md +72 -72
  112. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/dispatch.md +108 -108
  113. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +243 -209
  114. package/.codex/skills/team-quality-assurance/roles/coordinator/role.md +176 -164
  115. package/.codex/skills/team-quality-assurance/roles/executor/role.md +66 -66
  116. package/.codex/skills/team-quality-assurance/roles/generator/role.md +68 -68
  117. package/.codex/skills/team-quality-assurance/roles/scout/role.md +67 -67
  118. package/.codex/skills/team-quality-assurance/roles/strategist/role.md +71 -71
  119. package/.codex/skills/team-quality-assurance/specs/pipelines.md +115 -115
  120. package/.codex/skills/team-review/SKILL.md +58 -3
  121. package/.codex/skills/team-review/roles/coordinator/commands/analyze.md +71 -71
  122. package/.codex/skills/team-review/roles/coordinator/commands/dispatch.md +90 -90
  123. package/.codex/skills/team-review/roles/coordinator/commands/monitor.md +225 -185
  124. package/.codex/skills/team-review/roles/coordinator/role.md +175 -163
  125. package/.codex/skills/team-review/roles/fixer/role.md +76 -76
  126. package/.codex/skills/team-review/roles/reviewer/role.md +68 -68
  127. package/.codex/skills/team-review/roles/scanner/role.md +71 -71
  128. package/.codex/skills/team-review/specs/pipelines.md +102 -102
  129. package/.codex/skills/team-roadmap-dev/SKILL.md +55 -3
  130. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/analyze.md +61 -61
  131. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/monitor.md +502 -468
  132. package/.codex/skills/team-roadmap-dev/roles/coordinator/role.md +335 -322
  133. package/.codex/skills/team-roadmap-dev/roles/executor/role.md +71 -71
  134. package/.codex/skills/team-roadmap-dev/roles/planner/role.md +76 -76
  135. package/.codex/skills/team-roadmap-dev/roles/verifier/role.md +74 -74
  136. package/.codex/skills/team-roadmap-dev/specs/pipelines.md +93 -93
  137. package/.codex/skills/team-tech-debt/SKILL.md +56 -3
  138. package/.codex/skills/team-tech-debt/roles/assessor/role.md +69 -69
  139. package/.codex/skills/team-tech-debt/roles/coordinator/commands/analyze.md +47 -47
  140. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +272 -231
  141. package/.codex/skills/team-tech-debt/roles/coordinator/role.md +172 -160
  142. package/.codex/skills/team-tech-debt/roles/executor/role.md +76 -76
  143. package/.codex/skills/team-tech-debt/roles/planner/role.md +69 -69
  144. package/.codex/skills/team-tech-debt/roles/scanner/role.md +82 -82
  145. package/.codex/skills/team-tech-debt/roles/validator/role.md +75 -75
  146. package/.codex/skills/team-tech-debt/specs/pipelines.md +47 -47
  147. package/.codex/skills/team-testing/SKILL.md +72 -3
  148. package/.codex/skills/team-testing/roles/analyst/role.md +95 -95
  149. package/.codex/skills/team-testing/roles/coordinator/commands/analyze.md +70 -70
  150. package/.codex/skills/team-testing/roles/coordinator/commands/dispatch.md +106 -106
  151. package/.codex/skills/team-testing/roles/coordinator/commands/monitor.md +283 -242
  152. package/.codex/skills/team-testing/roles/coordinator/role.md +184 -172
  153. package/.codex/skills/team-testing/roles/executor/role.md +96 -96
  154. package/.codex/skills/team-testing/roles/generator/role.md +95 -95
  155. package/.codex/skills/team-testing/roles/strategist/role.md +83 -83
  156. package/.codex/skills/team-testing/specs/pipelines.md +101 -101
  157. package/.codex/skills/team-uidesign/SKILL.md +65 -3
  158. package/.codex/skills/team-uidesign/roles/coordinator/commands/analyze.md +59 -59
  159. package/.codex/skills/team-uidesign/roles/coordinator/commands/dispatch.md +156 -156
  160. package/.codex/skills/team-uidesign/roles/coordinator/commands/monitor.md +234 -194
  161. package/.codex/skills/team-uidesign/roles/coordinator/role.md +211 -199
  162. package/.codex/skills/team-uidesign/roles/designer/role.md +69 -69
  163. package/.codex/skills/team-uidesign/roles/implementer/role.md +72 -72
  164. package/.codex/skills/team-uidesign/roles/researcher/role.md +82 -82
  165. package/.codex/skills/team-uidesign/roles/reviewer/role.md +67 -67
  166. package/.codex/skills/team-uidesign/specs/pipelines.md +76 -76
  167. package/.codex/skills/team-ultra-analyze/SKILL.md +73 -3
  168. package/.codex/skills/team-ultra-analyze/roles/analyst/role.md +90 -90
  169. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/analyze.md +73 -73
  170. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +50 -9
  171. package/.codex/skills/team-ultra-analyze/roles/coordinator/role.md +255 -243
  172. package/.codex/skills/team-ultra-analyze/roles/discussant/role.md +104 -104
  173. package/.codex/skills/team-ultra-analyze/roles/explorer/role.md +74 -74
  174. package/.codex/skills/team-ultra-analyze/roles/synthesizer/role.md +78 -78
  175. package/.codex/skills/team-ultra-analyze/specs/pipelines.md +64 -64
  176. package/.codex/skills/team-ux-improve/SKILL.md +64 -3
  177. package/.codex/skills/team-ux-improve/roles/coordinator/commands/analyze.md +62 -62
  178. package/.codex/skills/team-ux-improve/roles/coordinator/commands/dispatch.md +233 -233
  179. package/.codex/skills/team-ux-improve/roles/coordinator/commands/monitor.md +195 -160
  180. package/.codex/skills/team-ux-improve/roles/coordinator/role.md +170 -158
  181. package/.codex/skills/team-ux-improve/roles/designer/role.md +122 -122
  182. package/.codex/skills/team-ux-improve/roles/diagnoser/role.md +93 -93
  183. package/.codex/skills/team-ux-improve/roles/explorer/role.md +77 -77
  184. package/.codex/skills/team-ux-improve/roles/implementer/role.md +102 -102
  185. package/.codex/skills/team-ux-improve/roles/scanner/role.md +93 -93
  186. package/.codex/skills/team-ux-improve/roles/tester/role.md +84 -84
  187. package/.codex/skills/team-ux-improve/specs/pipelines.md +54 -54
  188. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +402 -402
  189. package/README.md +1 -0
  190. package/package.json +1 -1
  191. package/.claude/skills/team-iterdev/SKILL.md +0 -127
  192. package/.claude/skills/team-iterdev/roles/architect/role.md +0 -65
  193. package/.claude/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
  194. package/.claude/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -234
  195. package/.claude/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -182
  196. package/.claude/skills/team-iterdev/roles/coordinator/role.md +0 -153
  197. package/.claude/skills/team-iterdev/roles/developer/role.md +0 -74
  198. package/.claude/skills/team-iterdev/roles/reviewer/role.md +0 -66
  199. package/.claude/skills/team-iterdev/roles/tester/role.md +0 -88
  200. package/.claude/skills/team-iterdev/specs/pipelines.md +0 -94
  201. package/.claude/skills/team-iterdev/specs/team-config.json +0 -172
  202. package/.codex/skills/team-iterdev/SKILL.md +0 -158
  203. package/.codex/skills/team-iterdev/roles/architect/role.md +0 -65
  204. package/.codex/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
  205. package/.codex/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -187
  206. package/.codex/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -186
  207. package/.codex/skills/team-iterdev/roles/coordinator/role.md +0 -181
  208. package/.codex/skills/team-iterdev/roles/developer/role.md +0 -74
  209. package/.codex/skills/team-iterdev/roles/reviewer/role.md +0 -66
  210. package/.codex/skills/team-iterdev/roles/tester/role.md +0 -88
  211. package/.codex/skills/team-iterdev/specs/pipelines.md +0 -94
  212. package/.codex/skills/team-iterdev/specs/team-config.json +0 -172
@@ -1,425 +1,425 @@
1
- ---
2
- name: spec-generator
3
- description: Specification generator - 7 phase document chain producing product brief, PRD, architecture, epics, and issues. Agent-delegated heavy phases (2-5, 6.5) with Codex review gates. Triggers on "generate spec", "create specification", "spec generator", "workflow:spec".
4
- allowed-tools: Agent, request_user_input, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep, Skill
5
- ---
6
-
7
- # Spec Generator
8
-
9
- Structured specification document generator producing a complete specification package (Product Brief, PRD, Architecture, Epics, Issues) through 7 sequential phases with multi-CLI analysis, Codex review gates, and interactive refinement. Heavy document phases are delegated to `doc-generator` agents to minimize main context usage. **Document generation only** - execution handoff via issue export to team-planex or existing workflows.
10
-
11
- ## Architecture Overview
12
-
13
- ```
14
- Phase 0: Specification Study (Read specs/ + templates/ - mandatory prerequisite) [Inline]
15
- |
16
- Phase 1: Discovery -> spec-config.json + discovery-context.json [Inline]
17
- | (includes spec_type selection)
18
- Phase 1.5: Req Expansion -> refined-requirements.json [Inline]
19
- | (interactive discussion + CLI gap analysis)
20
- Phase 2: Product Brief -> product-brief.md + glossary.json [Agent]
21
- | (3-CLI parallel + synthesis)
22
- Phase 3: Requirements (PRD) -> requirements/ (_index.md + REQ-*.md + NFR-*.md) [Agent]
23
- | (Gemini + Codex review)
24
- Phase 4: Architecture -> architecture/ (_index.md + ADR-*.md) [Agent]
25
- | (Gemini + Codex review)
26
- Phase 5: Epics & Stories -> epics/ (_index.md + EPIC-*.md) [Agent]
27
- | (Gemini + Codex review)
28
- Phase 6: Readiness Check -> readiness-report.md + spec-summary.md [Inline]
29
- | (Gemini + Codex dual validation + per-req verification)
30
- ├── Pass (>=80%): Handoff or Phase 7
31
- ├── Review (60-79%): Handoff with caveats or Phase 7
32
- └── Fail (<60%): Phase 6.5 Auto-Fix (max 2 iterations)
33
- |
34
- Phase 6.5: Auto-Fix -> Updated Phase 2-5 documents [Agent]
35
- |
36
- └── Re-run Phase 6 validation
37
- |
38
- Phase 7: Issue Export -> issue-export-report.md [Inline]
39
- (Epic→Issue mapping, ccw issue create, wave assignment)
40
- ```
41
-
42
- ## Key Design Principles
43
-
44
- 1. **Document Chain**: Each phase builds on previous outputs, creating a traceable specification chain from idea to executable issues
45
- 2. **Agent-Delegated**: Heavy document phases (2-5, 6.5) run in `doc-generator` agents, keeping main context lean (summaries only)
46
- 3. **Multi-Perspective Analysis**: CLI tools (Gemini/Codex/Claude) provide product, technical, and user perspectives in parallel
47
- 4. **Codex Review Gates**: Phases 3, 5, 6 include Codex CLI review for quality validation before output
48
- 5. **Interactive by Default**: Each phase offers user confirmation points; `-y` flag enables full auto mode
49
- 6. **Resumable Sessions**: `spec-config.json` tracks completed phases; `-c` flag resumes from last checkpoint
50
- 7. **Template-Driven**: All documents generated from standardized templates with YAML frontmatter
51
- 8. **Pure Documentation**: No code generation or execution - clean handoff via issue export to execution workflows
52
- 9. **Spec Type Specialization**: Templates adapt to spec type (service/api/library/platform) via profiles for domain-specific depth
53
- 10. **Iterative Quality**: Phase 6.5 auto-fix loop repairs issues found in readiness check (max 2 iterations)
54
- 11. **Terminology Consistency**: glossary.json generated in Phase 2, injected into all subsequent phases
55
-
56
- ---
57
-
58
- ## Mandatory Prerequisites
59
-
60
- > **Do NOT skip**: Before performing any operations, you **must** completely read the following documents. Proceeding without reading the specifications will result in outputs that do not meet quality standards.
61
-
62
- ### Specification Documents (Required Reading)
63
-
64
- | Document | Purpose | Priority |
65
- |----------|---------|----------|
66
- | [specs/document-standards.md](specs/document-standards.md) | Document format, frontmatter, naming conventions | **P0 - Must read before execution** |
67
- | [specs/quality-gates.md](specs/quality-gates.md) | Per-phase quality gate criteria and scoring | **P0 - Must read before execution** |
68
-
69
- ### Template Files (Must read before generation)
70
-
71
- | Document | Purpose |
72
- |----------|---------|
73
- | [templates/product-brief.md](templates/product-brief.md) | Product brief document template |
74
- | [templates/requirements-prd.md](templates/requirements-prd.md) | PRD document template |
75
- | [templates/architecture-doc.md](templates/architecture-doc.md) | Architecture document template |
76
- | [templates/epics-template.md](templates/epics-template.md) | Epic/Story document template |
77
-
78
- ---
79
-
80
- ## Execution Flow
81
-
82
- ```
83
- Input Parsing:
84
- |- Parse $ARGUMENTS: extract idea/topic, flags (-y, -c, -m)
85
- |- Detect mode: new | continue
86
- |- If continue: read spec-config.json, resume from first incomplete phase
87
- |- If new: proceed to Phase 1
88
-
89
- Phase 1: Discovery & Seed Analysis
90
- |- Ref: phases/01-discovery.md
91
- |- Generate session ID: SPEC-{slug}-{YYYY-MM-DD}
92
- |- Parse input (text or file reference)
93
- |- Gemini CLI seed analysis (problem, users, domain, dimensions)
94
- |- Codebase exploration (conditional, if project detected)
95
- |- Spec type selection: service|api|library|platform (interactive, -y defaults to service)
96
- |- User confirmation (interactive, -y skips)
97
- |- Output: spec-config.json, discovery-context.json (optional)
98
-
99
- Phase 1.5: Requirement Expansion & Clarification
100
- |- Ref: phases/01-5-requirement-clarification.md
101
- |- CLI gap analysis: completeness scoring, missing dimensions detection
102
- |- Multi-round interactive discussion (max 5 rounds)
103
- | |- Round 1: present gap analysis + expansion suggestions
104
- | |- Round N: follow-up refinement based on user responses
105
- |- User final confirmation of requirements
106
- |- Auto mode (-y): CLI auto-expansion without interaction
107
- |- Output: refined-requirements.json
108
-
109
- Phase 2: Product Brief [AGENT: doc-generator]
110
- |- Delegate to Task(subagent_type="doc-generator")
111
- |- Agent reads: phases/02-product-brief.md
112
- |- Agent executes: 3 parallel CLI analyses + synthesis + glossary generation
113
- |- Agent writes: product-brief.md, glossary.json
114
- |- Agent returns: JSON summary {files_created, quality_notes, key_decisions}
115
- |- Orchestrator validates: files exist, spec-config.json updated
116
-
117
- Phase 3: Requirements / PRD [AGENT: doc-generator]
118
- |- Delegate to Task(subagent_type="doc-generator")
119
- |- Agent reads: phases/03-requirements.md
120
- |- Agent executes: Gemini expansion + Codex review (Step 2.5) + priority sorting
121
- |- Agent writes: requirements/ directory (_index.md + REQ-*.md + NFR-*.md)
122
- |- Agent returns: JSON summary {files_created, codex_review_integrated, key_decisions}
123
- |- Orchestrator validates: directory exists, file count matches
124
-
125
- Phase 4: Architecture [AGENT: doc-generator]
126
- |- Delegate to Task(subagent_type="doc-generator")
127
- |- Agent reads: phases/04-architecture.md
128
- |- Agent executes: Gemini analysis + Codex review + codebase mapping
129
- |- Agent writes: architecture/ directory (_index.md + ADR-*.md)
130
- |- Agent returns: JSON summary {files_created, codex_review_rating, key_decisions}
131
- |- Orchestrator validates: directory exists, ADR files present
132
-
133
- Phase 5: Epics & Stories [AGENT: doc-generator]
134
- |- Delegate to Task(subagent_type="doc-generator")
135
- |- Agent reads: phases/05-epics-stories.md
136
- |- Agent executes: Gemini decomposition + Codex review (Step 2.5) + validation
137
- |- Agent writes: epics/ directory (_index.md + EPIC-*.md)
138
- |- Agent returns: JSON summary {files_created, codex_review_integrated, mvp_epic_count}
139
- |- Orchestrator validates: directory exists, MVP epics present
140
-
141
- Phase 6: Readiness Check [INLINE + ENHANCED]
142
- |- Ref: phases/06-readiness-check.md
143
- |- Gemini CLI: cross-document validation (completeness, consistency, traceability)
144
- |- Codex CLI: technical depth review (ADR quality, data model, security, observability)
145
- |- Per-requirement verification: iterate all REQ-*.md / NFR-*.md
146
- | |- Check: AC exists + testable, Brief trace, Story coverage, Arch coverage
147
- | |- Generate: Per-Requirement Verification table
148
- |- Merge dual CLI scores into quality report
149
- |- Output: readiness-report.md, spec-summary.md
150
- |- Handoff options: Phase 7 (issue export), lite-plan, req-plan, plan, iterate
151
-
152
- Phase 6.5: Auto-Fix (conditional) [AGENT: doc-generator]
153
- |- Delegate to Task(subagent_type="doc-generator")
154
- |- Agent reads: phases/06-5-auto-fix.md + readiness-report.md
155
- |- Agent executes: fix affected Phase 2-5 documents
156
- |- Agent returns: JSON summary {files_modified, issues_fixed, phases_touched}
157
- |- Re-run Phase 6 validation
158
- |- Max 2 iterations, then force handoff
159
-
160
- Phase 7: Issue Export [INLINE]
161
- |- Ref: phases/07-issue-export.md
162
- |- Read EPIC-*.md files, assign waves (MVP→wave-1, others→wave-2)
163
- |- Create issues via ccw issue create (one per Epic)
164
- |- Map Epic dependencies to issue dependencies
165
- |- Generate issue-export-report.md
166
- |- Update spec-config.json with issue_ids
167
- |- Handoff: team-planex, wave-1 only, view issues, done
168
-
169
- Complete: Full specification package with issues ready for execution
170
-
171
- Phase 6/7 → Handoff Bridge (conditional, based on user selection):
172
- ├─ team-planex: Execute issues via coordinated team workflow
173
- ├─ lite-plan: Extract first MVP Epic description → direct text input
174
- ├─ plan / req-plan: Create WFS session + .brainstorming/ bridge files
175
- │ ├─ guidance-specification.md (synthesized from spec outputs)
176
- │ ├─ feature-specs/feature-index.json (Epic → Feature mapping)
177
- │ └─ feature-specs/F-{num}-{slug}.md (one per Epic)
178
- └─ context-search-agent auto-discovers .brainstorming/
179
- → context-package.json.brainstorm_artifacts populated
180
- → action-planning-agent consumes: guidance_spec (P1) → feature_index (P2)
181
- ```
182
-
183
- ## Directory Setup
184
-
185
- ```javascript
186
- // Session ID generation
187
- const slug = topic.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-').slice(0, 40);
188
- const date = new Date().toISOString().slice(0, 10);
189
- const sessionId = `SPEC-${slug}-${date}`;
190
- const workDir = `.workflow/.spec/${sessionId}`;
191
-
192
- Bash(`mkdir -p "${workDir}"`);
193
- ```
194
-
195
- ## Output Structure
196
-
197
- ```
198
- .workflow/.spec/SPEC-{slug}-{YYYY-MM-DD}/
199
- ├── spec-config.json # Session configuration + phase state
200
- ├── discovery-context.json # Codebase exploration results (optional)
201
- ├── refined-requirements.json # Phase 1.5: Confirmed requirements after discussion
202
- ├── glossary.json # Phase 2: Terminology glossary for cross-doc consistency
203
- ├── product-brief.md # Phase 2: Product brief
204
- ├── requirements/ # Phase 3: Detailed PRD (directory)
205
- │ ├── _index.md # Summary, MoSCoW table, traceability, links
206
- │ ├── REQ-NNN-{slug}.md # Individual functional requirement
207
- │ └── NFR-{type}-NNN-{slug}.md # Individual non-functional requirement
208
- ├── architecture/ # Phase 4: Architecture decisions (directory)
209
- │ ├── _index.md # Overview, components, tech stack, links
210
- │ └── ADR-NNN-{slug}.md # Individual Architecture Decision Record
211
- ├── epics/ # Phase 5: Epic/Story breakdown (directory)
212
- │ ├── _index.md # Epic table, dependency map, MVP scope
213
- │ └── EPIC-NNN-{slug}.md # Individual Epic with Stories
214
- ├── readiness-report.md # Phase 6: Quality report (+ per-req verification table)
215
- ├── spec-summary.md # Phase 6: One-page executive summary
216
- └── issue-export-report.md # Phase 7: Issue mapping table + spec links
217
- ```
218
-
219
- ## State Management
220
-
221
- **spec-config.json** serves as core state file:
222
- ```json
223
- {
224
- "session_id": "SPEC-xxx-2026-02-11",
225
- "seed_input": "User input text",
226
- "input_type": "text",
227
- "timestamp": "ISO8601",
228
- "mode": "interactive",
229
- "complexity": "moderate",
230
- "depth": "standard",
231
- "focus_areas": [],
232
- "spec_type": "service",
233
- "iteration_count": 0,
234
- "iteration_history": [],
235
- "seed_analysis": {
236
- "problem_statement": "...",
237
- "target_users": [],
238
- "domain": "...",
239
- "constraints": [],
240
- "dimensions": []
241
- },
242
- "has_codebase": false,
243
- "refined_requirements_file": "refined-requirements.json",
244
- "issue_ids": [],
245
- "issues_created": 0,
246
- "phasesCompleted": [
247
- { "phase": 1, "name": "discovery", "output_file": "spec-config.json", "completed_at": "ISO8601" },
248
- { "phase": 1.5, "name": "requirement-clarification", "output_file": "refined-requirements.json", "discussion_rounds": 2, "completed_at": "ISO8601" },
249
- { "phase": 3, "name": "requirements", "output_dir": "requirements/", "output_index": "requirements/_index.md", "file_count": 8, "completed_at": "ISO8601" }
250
- ]
251
- }
252
- ```
253
-
254
- **Resume mechanism**: `-c|--continue` flag reads `spec-config.json.phasesCompleted`, resumes from first incomplete phase.
255
-
256
- ## Core Rules
257
-
258
- 1. **Start Immediately**: First action is TaskCreate initialization, then Phase 0 (spec study), then Phase 1
259
- 2. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
260
- 3. **Auto-Continue**: All phases run autonomously; check TaskList to execute next pending phase
261
- 4. **Parse Every Output**: Extract required data from each phase for next phase context
262
- 5. **DO NOT STOP**: Continuous 7-phase pipeline until all phases complete or user exits
263
- 6. **Respect -y Flag**: When auto mode, skip all request_user_input calls, use recommended defaults
264
- 7. **Respect -c Flag**: When continue mode, load spec-config.json and resume from checkpoint
265
- 8. **Inject Glossary**: From Phase 3 onward, inject glossary.json terms into every CLI prompt
266
- 9. **Load Profile**: Read templates/profiles/{spec_type}-profile.md and inject requirements into Phase 2-5 prompts
267
- 10. **Iterate on Failure**: When Phase 6 score < 60%, auto-trigger Phase 6.5 (max 2 iterations)
268
- 11. **Agent Delegation**: Phase 2-5 and 6.5 MUST be delegated to `doc-generator` agents via Task tool — never execute inline
269
- 12. **Lean Context**: Orchestrator only sees agent return summaries (JSON), never the full document content
270
- 13. **Validate Agent Output**: After each agent returns, verify files exist on disk and spec-config.json was updated
271
-
272
- ## Agent Delegation Protocol
273
-
274
- For Phase 2-5 and 6.5, the orchestrator delegates to a `doc-generator` agent via the Task tool. The orchestrator builds a lean context envelope — passing only paths, never file content.
275
-
276
- ### Context Envelope Template
277
-
278
- ```javascript
279
- Task({
280
- subagent_type: "doc-generator",
281
- run_in_background: false,
282
- description: `Spec Phase ${N}: ${phaseName}`,
283
- prompt: `
284
- ## Spec Generator - Phase ${N}: ${phaseName}
285
-
286
- ### Session
287
- - ID: ${sessionId}
288
- - Work Dir: ${workDir}
289
- - Auto Mode: ${autoMode}
290
- - Spec Type: ${specType}
291
-
292
- ### Input (read from disk)
293
- ${inputFilesList} // Only file paths — agent reads content itself
294
-
295
- ### Instructions
296
- Read: ${skillDir}/phases/${phaseFile} // Agent reads the phase doc for full instructions
297
- Apply template: ${skillDir}/templates/${templateFile}
298
-
299
- ### Glossary (Phase 3+ only)
300
- Read: ${workDir}/glossary.json
301
-
302
- ### Output
303
- Write files to: ${workDir}/${outputPath}
304
- Update: ${workDir}/spec-config.json (phasesCompleted)
305
- Return: JSON summary { files_created, quality_notes, key_decisions }
306
- `
307
- });
308
- ```
309
-
310
- ### Orchestrator Post-Agent Validation
311
-
312
- After each agent returns:
313
-
314
- ```javascript
315
- // 1. Parse agent return summary
316
- const summary = JSON.parse(agentResult);
317
-
318
- // 2. Validate files exist
319
- summary.files_created.forEach(file => {
320
- const exists = Glob(`${workDir}/${file}`);
321
- if (!exists.length) throw new Error(`Agent claimed to create ${file} but file not found`);
322
- });
323
-
324
- // 3. Verify spec-config.json updated
325
- const config = JSON.parse(Read(`${workDir}/spec-config.json`));
326
- const phaseComplete = config.phasesCompleted.some(p => p.phase === N);
327
- if (!phaseComplete) throw new Error(`Agent did not update phasesCompleted for Phase ${N}`);
328
-
329
- // 4. Store summary for downstream context (do NOT read full documents)
330
- phasesSummaries[N] = summary;
331
- ```
332
-
333
- ---
334
-
335
- ## Reference Documents by Phase
336
-
337
- ### Phase 1: Discovery
338
- | Document | Purpose | When to Use |
339
- |----------|---------|-------------|
340
- | [phases/01-discovery.md](phases/01-discovery.md) | Seed analysis and session setup | Phase start |
341
- | [templates/profiles/](templates/profiles/) | Spec type profiles | Spec type selection |
342
- | [specs/document-standards.md](specs/document-standards.md) | Frontmatter format for spec-config.json | Config generation |
343
-
344
- ### Phase 1.5: Requirement Expansion & Clarification
345
- | Document | Purpose | When to Use |
346
- |----------|---------|-------------|
347
- | [phases/01-5-requirement-clarification.md](phases/01-5-requirement-clarification.md) | Interactive requirement discussion workflow | Phase start |
348
- | [specs/quality-gates.md](specs/quality-gates.md) | Quality criteria for refined requirements | Validation |
349
-
350
- ### Phase 2: Product Brief
351
- | Document | Purpose | When to Use |
352
- |----------|---------|-------------|
353
- | [phases/02-product-brief.md](phases/02-product-brief.md) | Multi-CLI analysis orchestration | Phase start |
354
- | [templates/product-brief.md](templates/product-brief.md) | Document template | Document generation |
355
- | [specs/glossary-template.json](specs/glossary-template.json) | Glossary schema | Glossary generation |
356
-
357
- ### Phase 3: Requirements
358
- | Document | Purpose | When to Use |
359
- |----------|---------|-------------|
360
- | [phases/03-requirements.md](phases/03-requirements.md) | PRD generation workflow | Phase start |
361
- | [templates/requirements-prd.md](templates/requirements-prd.md) | Document template | Document generation |
362
-
363
- ### Phase 4: Architecture
364
- | Document | Purpose | When to Use |
365
- |----------|---------|-------------|
366
- | [phases/04-architecture.md](phases/04-architecture.md) | Architecture decision workflow | Phase start |
367
- | [templates/architecture-doc.md](templates/architecture-doc.md) | Document template | Document generation |
368
-
369
- ### Phase 5: Epics & Stories
370
- | Document | Purpose | When to Use |
371
- |----------|---------|-------------|
372
- | [phases/05-epics-stories.md](phases/05-epics-stories.md) | Epic/Story decomposition | Phase start |
373
- | [templates/epics-template.md](templates/epics-template.md) | Document template | Document generation |
374
-
375
- ### Phase 6: Readiness Check
376
- | Document | Purpose | When to Use |
377
- |----------|---------|-------------|
378
- | [phases/06-readiness-check.md](phases/06-readiness-check.md) | Cross-document validation | Phase start |
379
- | [specs/quality-gates.md](specs/quality-gates.md) | Quality scoring criteria | Validation |
380
-
381
- ### Phase 6.5: Auto-Fix
382
- | Document | Purpose | When to Use |
383
- |----------|---------|-------------|
384
- | [phases/06-5-auto-fix.md](phases/06-5-auto-fix.md) | Auto-fix workflow for readiness issues | When Phase 6 score < 60% |
385
- | [specs/quality-gates.md](specs/quality-gates.md) | Iteration exit criteria | Validation |
386
-
387
- ### Phase 7: Issue Export
388
- | Document | Purpose | When to Use |
389
- |----------|---------|-------------|
390
- | [phases/07-issue-export.md](phases/07-issue-export.md) | Epic→Issue mapping and export | Phase start |
391
- | [specs/quality-gates.md](specs/quality-gates.md) | Issue export quality criteria | Validation |
392
-
393
- ### Debugging & Troubleshooting
394
- | Issue | Solution Document |
395
- |-------|-------------------|
396
- | Phase execution failed | Refer to the relevant Phase documentation |
397
- | Output does not meet expectations | [specs/quality-gates.md](specs/quality-gates.md) |
398
- | Document format issues | [specs/document-standards.md](specs/document-standards.md) |
399
-
400
- ## Error Handling
401
-
402
- | Phase | Error | Blocking? | Action |
403
- |-------|-------|-----------|--------|
404
- | Phase 1 | Empty input | Yes | Error and exit |
405
- | Phase 1 | CLI seed analysis fails | No | Use basic parsing fallback |
406
- | Phase 1.5 | Gap analysis CLI fails | No | Skip to user questions with basic prompts |
407
- | Phase 1.5 | User skips discussion | No | Proceed with seed_analysis as-is |
408
- | Phase 1.5 | Max rounds reached (5) | No | Force confirmation with current state |
409
- | Phase 2 | Single CLI perspective fails | No | Continue with available perspectives |
410
- | Phase 2 | All CLI calls fail | No | Generate basic brief from seed analysis |
411
- | Phase 3 | Gemini CLI fails | No | Use codex fallback |
412
- | Phase 4 | Architecture review fails | No | Skip review, proceed with initial analysis |
413
- | Phase 5 | Story generation fails | No | Generate epics without detailed stories |
414
- | Phase 6 | Validation CLI fails | No | Generate partial report with available data |
415
- | Phase 6.5 | Auto-fix CLI fails | No | Log failure, proceed to handoff with Review status |
416
- | Phase 6.5 | Max iterations reached | No | Force handoff, report remaining issues |
417
- | Phase 7 | ccw issue create fails for one Epic | No | Log error, continue with remaining Epics |
418
- | Phase 7 | No EPIC files found | Yes | Error and return to Phase 5 |
419
- | Phase 7 | All issue creations fail | Yes | Error with CLI diagnostic, suggest manual creation |
420
- | Phase 2-5 | Agent fails to return | Yes | Retry once, then fall back to inline execution |
421
- | Phase 2-5 | Agent returns incomplete files | No | Log gaps, attempt inline completion for missing files |
422
-
423
- ### CLI Fallback Chain
424
-
425
- Gemini -> Codex -> Claude -> degraded mode (local analysis only)
1
+ ---
2
+ name: spec-generator
3
+ description: "Specification generator - 7 phase document chain producing product brief, PRD, architecture, epics, and issues. Agent-delegated heavy phases (2-5, 6.5) with Codex review gates. Triggers on \"generate spec\", \"create specification\", \"spec generator\", \"workflow:spec\"."
4
+ allowed-tools: Agent, request_user_input, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep, Skill
5
+ ---
6
+
7
+ # Spec Generator
8
+
9
+ Structured specification document generator producing a complete specification package (Product Brief, PRD, Architecture, Epics, Issues) through 7 sequential phases with multi-CLI analysis, Codex review gates, and interactive refinement. Heavy document phases are delegated to `doc-generator` agents to minimize main context usage. **Document generation only** - execution handoff via issue export to team-planex or existing workflows.
10
+
11
+ ## Architecture Overview
12
+
13
+ ```
14
+ Phase 0: Specification Study (Read specs/ + templates/ - mandatory prerequisite) [Inline]
15
+ |
16
+ Phase 1: Discovery -> spec-config.json + discovery-context.json [Inline]
17
+ | (includes spec_type selection)
18
+ Phase 1.5: Req Expansion -> refined-requirements.json [Inline]
19
+ | (interactive discussion + CLI gap analysis)
20
+ Phase 2: Product Brief -> product-brief.md + glossary.json [Agent]
21
+ | (3-CLI parallel + synthesis)
22
+ Phase 3: Requirements (PRD) -> requirements/ (_index.md + REQ-*.md + NFR-*.md) [Agent]
23
+ | (Gemini + Codex review)
24
+ Phase 4: Architecture -> architecture/ (_index.md + ADR-*.md) [Agent]
25
+ | (Gemini + Codex review)
26
+ Phase 5: Epics & Stories -> epics/ (_index.md + EPIC-*.md) [Agent]
27
+ | (Gemini + Codex review)
28
+ Phase 6: Readiness Check -> readiness-report.md + spec-summary.md [Inline]
29
+ | (Gemini + Codex dual validation + per-req verification)
30
+ ├── Pass (>=80%): Handoff or Phase 7
31
+ ├── Review (60-79%): Handoff with caveats or Phase 7
32
+ └── Fail (<60%): Phase 6.5 Auto-Fix (max 2 iterations)
33
+ |
34
+ Phase 6.5: Auto-Fix -> Updated Phase 2-5 documents [Agent]
35
+ |
36
+ └── Re-run Phase 6 validation
37
+ |
38
+ Phase 7: Issue Export -> issue-export-report.md [Inline]
39
+ (Epic→Issue mapping, ccw issue create, wave assignment)
40
+ ```
41
+
42
+ ## Key Design Principles
43
+
44
+ 1. **Document Chain**: Each phase builds on previous outputs, creating a traceable specification chain from idea to executable issues
45
+ 2. **Agent-Delegated**: Heavy document phases (2-5, 6.5) run in `doc-generator` agents, keeping main context lean (summaries only)
46
+ 3. **Multi-Perspective Analysis**: CLI tools (Gemini/Codex/Claude) provide product, technical, and user perspectives in parallel
47
+ 4. **Codex Review Gates**: Phases 3, 5, 6 include Codex CLI review for quality validation before output
48
+ 5. **Interactive by Default**: Each phase offers user confirmation points; `-y` flag enables full auto mode
49
+ 6. **Resumable Sessions**: `spec-config.json` tracks completed phases; `-c` flag resumes from last checkpoint
50
+ 7. **Template-Driven**: All documents generated from standardized templates with YAML frontmatter
51
+ 8. **Pure Documentation**: No code generation or execution - clean handoff via issue export to execution workflows
52
+ 9. **Spec Type Specialization**: Templates adapt to spec type (service/api/library/platform) via profiles for domain-specific depth
53
+ 10. **Iterative Quality**: Phase 6.5 auto-fix loop repairs issues found in readiness check (max 2 iterations)
54
+ 11. **Terminology Consistency**: glossary.json generated in Phase 2, injected into all subsequent phases
55
+
56
+ ---
57
+
58
+ ## Mandatory Prerequisites
59
+
60
+ > **Do NOT skip**: Before performing any operations, you **must** completely read the following documents. Proceeding without reading the specifications will result in outputs that do not meet quality standards.
61
+
62
+ ### Specification Documents (Required Reading)
63
+
64
+ | Document | Purpose | Priority |
65
+ |----------|---------|----------|
66
+ | [specs/document-standards.md](specs/document-standards.md) | Document format, frontmatter, naming conventions | **P0 - Must read before execution** |
67
+ | [specs/quality-gates.md](specs/quality-gates.md) | Per-phase quality gate criteria and scoring | **P0 - Must read before execution** |
68
+
69
+ ### Template Files (Must read before generation)
70
+
71
+ | Document | Purpose |
72
+ |----------|---------|
73
+ | [templates/product-brief.md](templates/product-brief.md) | Product brief document template |
74
+ | [templates/requirements-prd.md](templates/requirements-prd.md) | PRD document template |
75
+ | [templates/architecture-doc.md](templates/architecture-doc.md) | Architecture document template |
76
+ | [templates/epics-template.md](templates/epics-template.md) | Epic/Story document template |
77
+
78
+ ---
79
+
80
+ ## Execution Flow
81
+
82
+ ```
83
+ Input Parsing:
84
+ |- Parse $ARGUMENTS: extract idea/topic, flags (-y, -c, -m)
85
+ |- Detect mode: new | continue
86
+ |- If continue: read spec-config.json, resume from first incomplete phase
87
+ |- If new: proceed to Phase 1
88
+
89
+ Phase 1: Discovery & Seed Analysis
90
+ |- Ref: phases/01-discovery.md
91
+ |- Generate session ID: SPEC-{slug}-{YYYY-MM-DD}
92
+ |- Parse input (text or file reference)
93
+ |- Gemini CLI seed analysis (problem, users, domain, dimensions)
94
+ |- Codebase exploration (conditional, if project detected)
95
+ |- Spec type selection: service|api|library|platform (interactive, -y defaults to service)
96
+ |- User confirmation (interactive, -y skips)
97
+ |- Output: spec-config.json, discovery-context.json (optional)
98
+
99
+ Phase 1.5: Requirement Expansion & Clarification
100
+ |- Ref: phases/01-5-requirement-clarification.md
101
+ |- CLI gap analysis: completeness scoring, missing dimensions detection
102
+ |- Multi-round interactive discussion (max 5 rounds)
103
+ | |- Round 1: present gap analysis + expansion suggestions
104
+ | |- Round N: follow-up refinement based on user responses
105
+ |- User final confirmation of requirements
106
+ |- Auto mode (-y): CLI auto-expansion without interaction
107
+ |- Output: refined-requirements.json
108
+
109
+ Phase 2: Product Brief [AGENT: doc-generator]
110
+ |- Delegate to Task(subagent_type="doc-generator")
111
+ |- Agent reads: phases/02-product-brief.md
112
+ |- Agent executes: 3 parallel CLI analyses + synthesis + glossary generation
113
+ |- Agent writes: product-brief.md, glossary.json
114
+ |- Agent returns: JSON summary {files_created, quality_notes, key_decisions}
115
+ |- Orchestrator validates: files exist, spec-config.json updated
116
+
117
+ Phase 3: Requirements / PRD [AGENT: doc-generator]
118
+ |- Delegate to Task(subagent_type="doc-generator")
119
+ |- Agent reads: phases/03-requirements.md
120
+ |- Agent executes: Gemini expansion + Codex review (Step 2.5) + priority sorting
121
+ |- Agent writes: requirements/ directory (_index.md + REQ-*.md + NFR-*.md)
122
+ |- Agent returns: JSON summary {files_created, codex_review_integrated, key_decisions}
123
+ |- Orchestrator validates: directory exists, file count matches
124
+
125
+ Phase 4: Architecture [AGENT: doc-generator]
126
+ |- Delegate to Task(subagent_type="doc-generator")
127
+ |- Agent reads: phases/04-architecture.md
128
+ |- Agent executes: Gemini analysis + Codex review + codebase mapping
129
+ |- Agent writes: architecture/ directory (_index.md + ADR-*.md)
130
+ |- Agent returns: JSON summary {files_created, codex_review_rating, key_decisions}
131
+ |- Orchestrator validates: directory exists, ADR files present
132
+
133
+ Phase 5: Epics & Stories [AGENT: doc-generator]
134
+ |- Delegate to Task(subagent_type="doc-generator")
135
+ |- Agent reads: phases/05-epics-stories.md
136
+ |- Agent executes: Gemini decomposition + Codex review (Step 2.5) + validation
137
+ |- Agent writes: epics/ directory (_index.md + EPIC-*.md)
138
+ |- Agent returns: JSON summary {files_created, codex_review_integrated, mvp_epic_count}
139
+ |- Orchestrator validates: directory exists, MVP epics present
140
+
141
+ Phase 6: Readiness Check [INLINE + ENHANCED]
142
+ |- Ref: phases/06-readiness-check.md
143
+ |- Gemini CLI: cross-document validation (completeness, consistency, traceability)
144
+ |- Codex CLI: technical depth review (ADR quality, data model, security, observability)
145
+ |- Per-requirement verification: iterate all REQ-*.md / NFR-*.md
146
+ | |- Check: AC exists + testable, Brief trace, Story coverage, Arch coverage
147
+ | |- Generate: Per-Requirement Verification table
148
+ |- Merge dual CLI scores into quality report
149
+ |- Output: readiness-report.md, spec-summary.md
150
+ |- Handoff options: Phase 7 (issue export), lite-plan, req-plan, plan, iterate
151
+
152
+ Phase 6.5: Auto-Fix (conditional) [AGENT: doc-generator]
153
+ |- Delegate to Task(subagent_type="doc-generator")
154
+ |- Agent reads: phases/06-5-auto-fix.md + readiness-report.md
155
+ |- Agent executes: fix affected Phase 2-5 documents
156
+ |- Agent returns: JSON summary {files_modified, issues_fixed, phases_touched}
157
+ |- Re-run Phase 6 validation
158
+ |- Max 2 iterations, then force handoff
159
+
160
+ Phase 7: Issue Export [INLINE]
161
+ |- Ref: phases/07-issue-export.md
162
+ |- Read EPIC-*.md files, assign waves (MVP→wave-1, others→wave-2)
163
+ |- Create issues via ccw issue create (one per Epic)
164
+ |- Map Epic dependencies to issue dependencies
165
+ |- Generate issue-export-report.md
166
+ |- Update spec-config.json with issue_ids
167
+ |- Handoff: team-planex, wave-1 only, view issues, done
168
+
169
+ Complete: Full specification package with issues ready for execution
170
+
171
+ Phase 6/7 → Handoff Bridge (conditional, based on user selection):
172
+ ├─ team-planex: Execute issues via coordinated team workflow
173
+ ├─ lite-plan: Extract first MVP Epic description → direct text input
174
+ ├─ plan / req-plan: Create WFS session + .brainstorming/ bridge files
175
+ │ ├─ guidance-specification.md (synthesized from spec outputs)
176
+ │ ├─ feature-specs/feature-index.json (Epic → Feature mapping)
177
+ │ └─ feature-specs/F-{num}-{slug}.md (one per Epic)
178
+ └─ context-search-agent auto-discovers .brainstorming/
179
+ → context-package.json.brainstorm_artifacts populated
180
+ → action-planning-agent consumes: guidance_spec (P1) → feature_index (P2)
181
+ ```
182
+
183
+ ## Directory Setup
184
+
185
+ ```javascript
186
+ // Session ID generation
187
+ const slug = topic.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-').slice(0, 40);
188
+ const date = new Date().toISOString().slice(0, 10);
189
+ const sessionId = `SPEC-${slug}-${date}`;
190
+ const workDir = `.workflow/.spec/${sessionId}`;
191
+
192
+ Bash(`mkdir -p "${workDir}"`);
193
+ ```
194
+
195
+ ## Output Structure
196
+
197
+ ```
198
+ .workflow/.spec/SPEC-{slug}-{YYYY-MM-DD}/
199
+ ├── spec-config.json # Session configuration + phase state
200
+ ├── discovery-context.json # Codebase exploration results (optional)
201
+ ├── refined-requirements.json # Phase 1.5: Confirmed requirements after discussion
202
+ ├── glossary.json # Phase 2: Terminology glossary for cross-doc consistency
203
+ ├── product-brief.md # Phase 2: Product brief
204
+ ├── requirements/ # Phase 3: Detailed PRD (directory)
205
+ │ ├── _index.md # Summary, MoSCoW table, traceability, links
206
+ │ ├── REQ-NNN-{slug}.md # Individual functional requirement
207
+ │ └── NFR-{type}-NNN-{slug}.md # Individual non-functional requirement
208
+ ├── architecture/ # Phase 4: Architecture decisions (directory)
209
+ │ ├── _index.md # Overview, components, tech stack, links
210
+ │ └── ADR-NNN-{slug}.md # Individual Architecture Decision Record
211
+ ├── epics/ # Phase 5: Epic/Story breakdown (directory)
212
+ │ ├── _index.md # Epic table, dependency map, MVP scope
213
+ │ └── EPIC-NNN-{slug}.md # Individual Epic with Stories
214
+ ├── readiness-report.md # Phase 6: Quality report (+ per-req verification table)
215
+ ├── spec-summary.md # Phase 6: One-page executive summary
216
+ └── issue-export-report.md # Phase 7: Issue mapping table + spec links
217
+ ```
218
+
219
+ ## State Management
220
+
221
+ **spec-config.json** serves as core state file:
222
+ ```json
223
+ {
224
+ "session_id": "SPEC-xxx-2026-02-11",
225
+ "seed_input": "User input text",
226
+ "input_type": "text",
227
+ "timestamp": "ISO8601",
228
+ "mode": "interactive",
229
+ "complexity": "moderate",
230
+ "depth": "standard",
231
+ "focus_areas": [],
232
+ "spec_type": "service",
233
+ "iteration_count": 0,
234
+ "iteration_history": [],
235
+ "seed_analysis": {
236
+ "problem_statement": "...",
237
+ "target_users": [],
238
+ "domain": "...",
239
+ "constraints": [],
240
+ "dimensions": []
241
+ },
242
+ "has_codebase": false,
243
+ "refined_requirements_file": "refined-requirements.json",
244
+ "issue_ids": [],
245
+ "issues_created": 0,
246
+ "phasesCompleted": [
247
+ { "phase": 1, "name": "discovery", "output_file": "spec-config.json", "completed_at": "ISO8601" },
248
+ { "phase": 1.5, "name": "requirement-clarification", "output_file": "refined-requirements.json", "discussion_rounds": 2, "completed_at": "ISO8601" },
249
+ { "phase": 3, "name": "requirements", "output_dir": "requirements/", "output_index": "requirements/_index.md", "file_count": 8, "completed_at": "ISO8601" }
250
+ ]
251
+ }
252
+ ```
253
+
254
+ **Resume mechanism**: `-c|--continue` flag reads `spec-config.json.phasesCompleted`, resumes from first incomplete phase.
255
+
256
+ ## Core Rules
257
+
258
+ 1. **Start Immediately**: First action is TaskCreate initialization, then Phase 0 (spec study), then Phase 1
259
+ 2. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
260
+ 3. **Auto-Continue**: All phases run autonomously; check TaskList to execute next pending phase
261
+ 4. **Parse Every Output**: Extract required data from each phase for next phase context
262
+ 5. **DO NOT STOP**: Continuous 7-phase pipeline until all phases complete or user exits
263
+ 6. **Respect -y Flag**: When auto mode, skip all request_user_input calls, use recommended defaults
264
+ 7. **Respect -c Flag**: When continue mode, load spec-config.json and resume from checkpoint
265
+ 8. **Inject Glossary**: From Phase 3 onward, inject glossary.json terms into every CLI prompt
266
+ 9. **Load Profile**: Read templates/profiles/{spec_type}-profile.md and inject requirements into Phase 2-5 prompts
267
+ 10. **Iterate on Failure**: When Phase 6 score < 60%, auto-trigger Phase 6.5 (max 2 iterations)
268
+ 11. **Agent Delegation**: Phase 2-5 and 6.5 MUST be delegated to `doc-generator` agents via Task tool — never execute inline
269
+ 12. **Lean Context**: Orchestrator only sees agent return summaries (JSON), never the full document content
270
+ 13. **Validate Agent Output**: After each agent returns, verify files exist on disk and spec-config.json was updated
271
+
272
+ ## Agent Delegation Protocol
273
+
274
+ For Phase 2-5 and 6.5, the orchestrator delegates to a `doc-generator` agent via the Task tool. The orchestrator builds a lean context envelope — passing only paths, never file content.
275
+
276
+ ### Context Envelope Template
277
+
278
+ ```javascript
279
+ Task({
280
+ subagent_type: "doc-generator",
281
+ run_in_background: false,
282
+ description: `Spec Phase ${N}: ${phaseName}`,
283
+ prompt: `
284
+ ## Spec Generator - Phase ${N}: ${phaseName}
285
+
286
+ ### Session
287
+ - ID: ${sessionId}
288
+ - Work Dir: ${workDir}
289
+ - Auto Mode: ${autoMode}
290
+ - Spec Type: ${specType}
291
+
292
+ ### Input (read from disk)
293
+ ${inputFilesList} // Only file paths — agent reads content itself
294
+
295
+ ### Instructions
296
+ Read: ${skillDir}/phases/${phaseFile} // Agent reads the phase doc for full instructions
297
+ Apply template: ${skillDir}/templates/${templateFile}
298
+
299
+ ### Glossary (Phase 3+ only)
300
+ Read: ${workDir}/glossary.json
301
+
302
+ ### Output
303
+ Write files to: ${workDir}/${outputPath}
304
+ Update: ${workDir}/spec-config.json (phasesCompleted)
305
+ Return: JSON summary { files_created, quality_notes, key_decisions }
306
+ `
307
+ });
308
+ ```
309
+
310
+ ### Orchestrator Post-Agent Validation
311
+
312
+ After each agent returns:
313
+
314
+ ```javascript
315
+ // 1. Parse agent return summary
316
+ const summary = JSON.parse(agentResult);
317
+
318
+ // 2. Validate files exist
319
+ summary.files_created.forEach(file => {
320
+ const exists = Glob(`${workDir}/${file}`);
321
+ if (!exists.length) throw new Error(`Agent claimed to create ${file} but file not found`);
322
+ });
323
+
324
+ // 3. Verify spec-config.json updated
325
+ const config = JSON.parse(Read(`${workDir}/spec-config.json`));
326
+ const phaseComplete = config.phasesCompleted.some(p => p.phase === N);
327
+ if (!phaseComplete) throw new Error(`Agent did not update phasesCompleted for Phase ${N}`);
328
+
329
+ // 4. Store summary for downstream context (do NOT read full documents)
330
+ phasesSummaries[N] = summary;
331
+ ```
332
+
333
+ ---
334
+
335
+ ## Reference Documents by Phase
336
+
337
+ ### Phase 1: Discovery
338
+ | Document | Purpose | When to Use |
339
+ |----------|---------|-------------|
340
+ | [phases/01-discovery.md](phases/01-discovery.md) | Seed analysis and session setup | Phase start |
341
+ | [templates/profiles/](templates/profiles/) | Spec type profiles | Spec type selection |
342
+ | [specs/document-standards.md](specs/document-standards.md) | Frontmatter format for spec-config.json | Config generation |
343
+
344
+ ### Phase 1.5: Requirement Expansion & Clarification
345
+ | Document | Purpose | When to Use |
346
+ |----------|---------|-------------|
347
+ | [phases/01-5-requirement-clarification.md](phases/01-5-requirement-clarification.md) | Interactive requirement discussion workflow | Phase start |
348
+ | [specs/quality-gates.md](specs/quality-gates.md) | Quality criteria for refined requirements | Validation |
349
+
350
+ ### Phase 2: Product Brief
351
+ | Document | Purpose | When to Use |
352
+ |----------|---------|-------------|
353
+ | [phases/02-product-brief.md](phases/02-product-brief.md) | Multi-CLI analysis orchestration | Phase start |
354
+ | [templates/product-brief.md](templates/product-brief.md) | Document template | Document generation |
355
+ | [specs/glossary-template.json](specs/glossary-template.json) | Glossary schema | Glossary generation |
356
+
357
+ ### Phase 3: Requirements
358
+ | Document | Purpose | When to Use |
359
+ |----------|---------|-------------|
360
+ | [phases/03-requirements.md](phases/03-requirements.md) | PRD generation workflow | Phase start |
361
+ | [templates/requirements-prd.md](templates/requirements-prd.md) | Document template | Document generation |
362
+
363
+ ### Phase 4: Architecture
364
+ | Document | Purpose | When to Use |
365
+ |----------|---------|-------------|
366
+ | [phases/04-architecture.md](phases/04-architecture.md) | Architecture decision workflow | Phase start |
367
+ | [templates/architecture-doc.md](templates/architecture-doc.md) | Document template | Document generation |
368
+
369
+ ### Phase 5: Epics & Stories
370
+ | Document | Purpose | When to Use |
371
+ |----------|---------|-------------|
372
+ | [phases/05-epics-stories.md](phases/05-epics-stories.md) | Epic/Story decomposition | Phase start |
373
+ | [templates/epics-template.md](templates/epics-template.md) | Document template | Document generation |
374
+
375
+ ### Phase 6: Readiness Check
376
+ | Document | Purpose | When to Use |
377
+ |----------|---------|-------------|
378
+ | [phases/06-readiness-check.md](phases/06-readiness-check.md) | Cross-document validation | Phase start |
379
+ | [specs/quality-gates.md](specs/quality-gates.md) | Quality scoring criteria | Validation |
380
+
381
+ ### Phase 6.5: Auto-Fix
382
+ | Document | Purpose | When to Use |
383
+ |----------|---------|-------------|
384
+ | [phases/06-5-auto-fix.md](phases/06-5-auto-fix.md) | Auto-fix workflow for readiness issues | When Phase 6 score < 60% |
385
+ | [specs/quality-gates.md](specs/quality-gates.md) | Iteration exit criteria | Validation |
386
+
387
+ ### Phase 7: Issue Export
388
+ | Document | Purpose | When to Use |
389
+ |----------|---------|-------------|
390
+ | [phases/07-issue-export.md](phases/07-issue-export.md) | Epic→Issue mapping and export | Phase start |
391
+ | [specs/quality-gates.md](specs/quality-gates.md) | Issue export quality criteria | Validation |
392
+
393
+ ### Debugging & Troubleshooting
394
+ | Issue | Solution Document |
395
+ |-------|-------------------|
396
+ | Phase execution failed | Refer to the relevant Phase documentation |
397
+ | Output does not meet expectations | [specs/quality-gates.md](specs/quality-gates.md) |
398
+ | Document format issues | [specs/document-standards.md](specs/document-standards.md) |
399
+
400
+ ## Error Handling
401
+
402
+ | Phase | Error | Blocking? | Action |
403
+ |-------|-------|-----------|--------|
404
+ | Phase 1 | Empty input | Yes | Error and exit |
405
+ | Phase 1 | CLI seed analysis fails | No | Use basic parsing fallback |
406
+ | Phase 1.5 | Gap analysis CLI fails | No | Skip to user questions with basic prompts |
407
+ | Phase 1.5 | User skips discussion | No | Proceed with seed_analysis as-is |
408
+ | Phase 1.5 | Max rounds reached (5) | No | Force confirmation with current state |
409
+ | Phase 2 | Single CLI perspective fails | No | Continue with available perspectives |
410
+ | Phase 2 | All CLI calls fail | No | Generate basic brief from seed analysis |
411
+ | Phase 3 | Gemini CLI fails | No | Use codex fallback |
412
+ | Phase 4 | Architecture review fails | No | Skip review, proceed with initial analysis |
413
+ | Phase 5 | Story generation fails | No | Generate epics without detailed stories |
414
+ | Phase 6 | Validation CLI fails | No | Generate partial report with available data |
415
+ | Phase 6.5 | Auto-fix CLI fails | No | Log failure, proceed to handoff with Review status |
416
+ | Phase 6.5 | Max iterations reached | No | Force handoff, report remaining issues |
417
+ | Phase 7 | ccw issue create fails for one Epic | No | Log error, continue with remaining Epics |
418
+ | Phase 7 | No EPIC files found | Yes | Error and return to Phase 5 |
419
+ | Phase 7 | All issue creations fail | Yes | Error with CLI diagnostic, suggest manual creation |
420
+ | Phase 2-5 | Agent fails to return | Yes | Retry once, then fall back to inline execution |
421
+ | Phase 2-5 | Agent returns incomplete files | No | Log gaps, attempt inline completion for missing files |
422
+
423
+ ### CLI Fallback Chain
424
+
425
+ Gemini -> Codex -> Claude -> degraded mode (local analysis only)