claude-code-workflow 7.2.29 → 7.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json +2 -2
  2. package/.ccw/workflows/cli-templates/schemas/task-schema.json +14 -7
  3. package/.claude/agents/action-planning-agent.md +7 -4
  4. package/.claude/agents/cli-explore-agent.md +77 -63
  5. package/.claude/agents/cli-lite-planning-agent.md +11 -10
  6. package/.claude/agents/issue-plan-agent.md +421 -426
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/skills/ccw-chain/SKILL.md +119 -0
  9. package/.claude/skills/ccw-chain/chains/ccw-cycle.json +21 -0
  10. package/.claude/skills/ccw-chain/chains/ccw-exploration.json +47 -0
  11. package/.claude/skills/ccw-chain/chains/ccw-issue.json +33 -0
  12. package/.claude/skills/ccw-chain/chains/ccw-lightweight.json +57 -0
  13. package/.claude/skills/ccw-chain/chains/ccw-main.json +52 -0
  14. package/.claude/skills/ccw-chain/chains/ccw-standard.json +39 -0
  15. package/.claude/skills/ccw-chain/chains/ccw-team.json +10 -0
  16. package/.claude/skills/ccw-chain/chains/ccw-with-file.json +31 -0
  17. package/.claude/skills/ccw-chain/phases/analyze-with-file.md +788 -0
  18. package/.claude/skills/ccw-chain/phases/brainstorm/SKILL.md +408 -0
  19. package/.claude/skills/ccw-chain/phases/brainstorm/phases/01-mode-routing.md +207 -0
  20. package/.claude/skills/ccw-chain/phases/brainstorm/phases/02-artifacts.md +567 -0
  21. package/.claude/skills/ccw-chain/phases/brainstorm/phases/03-role-analysis.md +748 -0
  22. package/.claude/skills/ccw-chain/phases/brainstorm/phases/04-synthesis.md +827 -0
  23. package/.claude/skills/ccw-chain/phases/brainstorm-with-file.md +482 -0
  24. package/.claude/skills/ccw-chain/phases/collaborative-plan-with-file.md +639 -0
  25. package/.claude/skills/ccw-chain/phases/debug-with-file.md +656 -0
  26. package/.claude/skills/ccw-chain/phases/integration-test-cycle.md +936 -0
  27. package/.claude/skills/ccw-chain/phases/issue-convert-to-plan.md +720 -0
  28. package/.claude/skills/ccw-chain/phases/issue-discover.md +483 -0
  29. package/.claude/skills/ccw-chain/phases/issue-execute.md +629 -0
  30. package/.claude/skills/ccw-chain/phases/issue-from-brainstorm.md +382 -0
  31. package/.claude/skills/ccw-chain/phases/issue-plan.md +343 -0
  32. package/.claude/skills/ccw-chain/phases/issue-queue.md +464 -0
  33. package/.claude/skills/ccw-chain/phases/refactor-cycle.md +852 -0
  34. package/.claude/skills/ccw-chain/phases/review-cycle/SKILL.md +132 -0
  35. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-fix.md +760 -0
  36. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-module.md +764 -0
  37. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-session.md +775 -0
  38. package/.claude/skills/ccw-chain/phases/roadmap-with-file.md +544 -0
  39. package/.claude/skills/ccw-chain/phases/spec-generator/SKILL.md +338 -0
  40. package/.claude/skills/ccw-chain/phases/spec-generator/phases/01-5-requirement-clarification.md +404 -0
  41. package/.claude/skills/ccw-chain/phases/spec-generator/phases/01-discovery.md +257 -0
  42. package/.claude/skills/ccw-chain/phases/spec-generator/phases/02-product-brief.md +274 -0
  43. package/.claude/skills/ccw-chain/phases/spec-generator/phases/03-requirements.md +184 -0
  44. package/.claude/skills/ccw-chain/phases/spec-generator/phases/04-architecture.md +248 -0
  45. package/.claude/skills/ccw-chain/phases/spec-generator/phases/05-epics-stories.md +178 -0
  46. package/.claude/skills/ccw-chain/phases/spec-generator/phases/06-5-auto-fix.md +144 -0
  47. package/.claude/skills/ccw-chain/phases/spec-generator/phases/06-readiness-check.md +480 -0
  48. package/.claude/skills/ccw-chain/phases/team-planex.md +123 -0
  49. package/.claude/skills/ccw-chain/phases/ui-design-explore-auto.md +678 -0
  50. package/.claude/skills/ccw-chain/phases/unified-execute-with-file.md +870 -0
  51. package/.claude/skills/ccw-chain/phases/workflow-execute/SKILL.md +625 -0
  52. package/.claude/skills/ccw-chain/phases/workflow-execute/phases/06-review.md +215 -0
  53. package/.claude/skills/ccw-chain/phases/workflow-lite-plan.md +616 -0
  54. package/.claude/skills/ccw-chain/phases/workflow-multi-cli-plan.md +424 -0
  55. package/.claude/skills/ccw-chain/phases/workflow-plan/SKILL.md +466 -0
  56. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/01-session-discovery.md +99 -0
  57. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/02-context-gathering.md +338 -0
  58. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/03-conflict-resolution.md +422 -0
  59. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/04-task-generation.md +440 -0
  60. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/05-plan-verify.md +395 -0
  61. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/06-replan.md +594 -0
  62. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/SKILL.md +527 -0
  63. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/01-session-discovery.md +57 -0
  64. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/02-context-gathering.md +407 -0
  65. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/03-test-coverage-analysis.md +172 -0
  66. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -0
  67. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/05-tdd-task-generation.md +473 -0
  68. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/06-tdd-structure-validation.md +189 -0
  69. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/07-tdd-verify.md +635 -0
  70. package/.claude/skills/ccw-chain/phases/workflow-test-fix/SKILL.md +482 -0
  71. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/01-session-start.md +60 -0
  72. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/02-test-context-gather.md +493 -0
  73. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/03-test-concept-enhanced.md +150 -0
  74. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/04-test-task-generate.md +346 -0
  75. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/05-test-cycle-execute.md +538 -0
  76. package/.claude/skills/ccw-chain/specs/auto-mode.md +47 -0
  77. package/.claude/skills/ccw-chain/specs/intent-patterns.md +60 -0
  78. package/.claude/skills/chain-loader/SKILL.md +78 -0
  79. package/.claude/skills/chain-loader/phases/01-analyze-skill.md +53 -0
  80. package/.claude/skills/chain-loader/phases/02-design-graph.md +73 -0
  81. package/.claude/skills/chain-loader/phases/03-generate-validate.md +75 -0
  82. package/.claude/skills/chain-loader/specs/chain-schema.md +99 -0
  83. package/.claude/skills/chain-loader/specs/design-patterns.md +99 -0
  84. package/.claude/skills/chain-loader/templates/chain-json.md +63 -0
  85. package/.claude/skills/review-cycle/phases/review-module.md +764 -764
  86. package/.claude/skills/review-cycle/phases/review-session.md +775 -775
  87. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +2 -2
  88. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +422 -422
  89. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +395 -395
  90. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +407 -407
  91. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -426
  92. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +493 -493
  93. package/README.md +14 -0
  94. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  95. package/ccw/dist/core/routes/litellm-api-routes.js +0 -23
  96. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  97. package/ccw/dist/tools/chain-loader.d.ts +10 -0
  98. package/ccw/dist/tools/chain-loader.d.ts.map +1 -0
  99. package/ccw/dist/tools/chain-loader.js +642 -0
  100. package/ccw/dist/tools/chain-loader.js.map +1 -0
  101. package/ccw/dist/tools/index.d.ts.map +1 -1
  102. package/ccw/dist/tools/index.js +2 -0
  103. package/ccw/dist/tools/index.js.map +1 -1
  104. package/ccw/dist/tools/json-builder.js +20 -0
  105. package/ccw/dist/tools/json-builder.js.map +1 -1
  106. package/ccw/dist/types/chain-types.d.ts +72 -0
  107. package/ccw/dist/types/chain-types.d.ts.map +1 -0
  108. package/ccw/dist/types/chain-types.js +5 -0
  109. package/ccw/dist/types/chain-types.js.map +1 -0
  110. package/ccw/scripts/prepublish-clean.mjs +0 -1
  111. package/package.json +1 -3
  112. package/ccw-litellm/README.md +0 -180
  113. package/ccw-litellm/pyproject.toml +0 -35
  114. package/ccw-litellm/src/ccw_litellm/__init__.py +0 -47
  115. package/ccw-litellm/src/ccw_litellm/cli.py +0 -108
  116. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +0 -12
  117. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +0 -270
  118. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +0 -198
  119. package/ccw-litellm/src/ccw_litellm/config/__init__.py +0 -22
  120. package/ccw-litellm/src/ccw_litellm/config/loader.py +0 -343
  121. package/ccw-litellm/src/ccw_litellm/config/models.py +0 -162
  122. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +0 -14
  123. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +0 -52
  124. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +0 -45
@@ -0,0 +1,338 @@
1
+ ---
2
+ name: spec-generator
3
+ description: "Specification generator - 7 phase document chain producing product brief, PRD, architecture, epics, and issues with Codex review gates. Triggers on generate spec, create specification, spec generator, workflow:spec."
4
+ allowed-tools: Agent, AskUserQuestion, 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) through 6 sequential phases with multi-CLI analysis and interactive refinement. **Document generation only** - execution handoff to existing workflows (lite-plan, plan, req-plan).
10
+
11
+ ## Architecture Overview
12
+
13
+ ```
14
+ Phase 0: Specification Study (Read specs/ + templates/ - mandatory prerequisite)
15
+ |
16
+ Phase 1: Discovery -> spec-config.json + discovery-context.json
17
+ | (includes spec_type selection)
18
+ Phase 1.5: Req Expansion -> refined-requirements.json (interactive discussion + CLI gap analysis)
19
+ | (-y auto mode: auto-expansion, skip interaction)
20
+ Phase 2: Product Brief -> product-brief.md + glossary.json (multi-CLI parallel analysis)
21
+ |
22
+ Phase 3: Requirements (PRD) -> requirements/ (_index.md + REQ-*.md + NFR-*.md)
23
+ | (RFC 2119 keywords, data model definitions)
24
+ Phase 4: Architecture -> architecture/ (_index.md + ADR-*.md, multi-CLI review)
25
+ | (state machine, config model, error handling, observability)
26
+ Phase 5: Epics & Stories -> epics/ (_index.md + EPIC-*.md)
27
+ |
28
+ Phase 6: Readiness Check -> readiness-report.md + spec-summary.md
29
+ | (terminology + scope consistency validation)
30
+ ├── Pass (>=80%): Handoff to execution workflows
31
+ ├── Review (60-79%): Handoff with caveats
32
+ └── Fail (<60%): Phase 6.5 Auto-Fix (max 2 iterations)
33
+ |
34
+ Phase 6.5: Auto-Fix -> Updated Phase 2-5 documents
35
+ |
36
+ └── Re-run Phase 6 validation
37
+ ```
38
+
39
+ ## Key Design Principles
40
+
41
+ 1. **Document Chain**: Each phase builds on previous outputs, creating a traceable specification chain from idea to executable stories
42
+ 2. **Multi-Perspective Analysis**: CLI tools (Gemini/Codex/Claude) provide product, technical, and user perspectives in parallel
43
+ 3. **Interactive by Default**: Each phase offers user confirmation points; `-y` flag enables full auto mode
44
+ 4. **Resumable Sessions**: `spec-config.json` tracks completed phases; `-c` flag resumes from last checkpoint
45
+ 5. **Template-Driven**: All documents generated from standardized templates with YAML frontmatter
46
+ 6. **Pure Documentation**: No code generation or execution - clean handoff to existing execution workflows
47
+ 7. **Spec Type Specialization**: Templates adapt to spec type (service/api/library/platform) via profiles for domain-specific depth
48
+ 8. **Iterative Quality**: Phase 6.5 auto-fix loop repairs issues found in readiness check (max 2 iterations)
49
+ 9. **Terminology Consistency**: glossary.json generated in Phase 2, injected into all subsequent phases
50
+
51
+ ---
52
+
53
+ ## Mandatory Prerequisites
54
+
55
+ > **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.
56
+
57
+ ### Specification Documents (Required Reading)
58
+
59
+ | Document | Purpose | Priority |
60
+ |----------|---------|----------|
61
+ | [specs/document-standards.md](specs/document-standards.md) | Document format, frontmatter, naming conventions | **P0 - Must read before execution** |
62
+ | [specs/quality-gates.md](specs/quality-gates.md) | Per-phase quality gate criteria and scoring | **P0 - Must read before execution** |
63
+
64
+ ### Template Files (Must read before generation)
65
+
66
+ | Document | Purpose |
67
+ |----------|---------|
68
+ | [templates/product-brief.md](templates/product-brief.md) | Product brief document template |
69
+ | [templates/requirements-prd.md](templates/requirements-prd.md) | PRD document template |
70
+ | [templates/architecture-doc.md](templates/architecture-doc.md) | Architecture document template |
71
+ | [templates/epics-template.md](templates/epics-template.md) | Epic/Story document template |
72
+
73
+ ---
74
+
75
+ ## Execution Flow
76
+
77
+ ```
78
+ Input Parsing:
79
+ |- Parse $ARGUMENTS: extract idea/topic, flags (-y, -c, -m)
80
+ |- Detect mode: new | continue
81
+ |- If continue: read spec-config.json, resume from first incomplete phase
82
+ |- If new: proceed to Phase 1
83
+
84
+ Phase 1: Discovery & Seed Analysis
85
+ |- Ref: phases/01-discovery.md
86
+ |- Generate session ID: SPEC-{slug}-{YYYY-MM-DD}
87
+ |- Parse input (text or file reference)
88
+ |- Gemini CLI seed analysis (problem, users, domain, dimensions)
89
+ |- Codebase exploration (conditional, if project detected)
90
+ |- Spec type selection: service|api|library|platform (interactive, -y defaults to service)
91
+ |- User confirmation (interactive, -y skips)
92
+ |- Output: spec-config.json, discovery-context.json (optional)
93
+
94
+ Phase 1.5: Requirement Expansion & Clarification
95
+ |- Ref: phases/01-5-requirement-clarification.md
96
+ |- CLI gap analysis: completeness scoring, missing dimensions detection
97
+ |- Multi-round interactive discussion (max 5 rounds)
98
+ | |- Round 1: present gap analysis + expansion suggestions
99
+ | |- Round N: follow-up refinement based on user responses
100
+ |- User final confirmation of requirements
101
+ |- Auto mode (-y): CLI auto-expansion without interaction
102
+ |- Output: refined-requirements.json
103
+
104
+ Phase 2: Product Brief
105
+ |- Ref: phases/02-product-brief.md
106
+ |- 3 parallel CLI analyses: Product (Gemini) + Technical (Codex) + User (Claude)
107
+ |- Synthesize perspectives: convergent themes + conflicts
108
+ |- Generate glossary.json (terminology from product brief + CLI analysis)
109
+ |- Interactive refinement (-y skips)
110
+ |- Output: product-brief.md (from template), glossary.json
111
+
112
+ Phase 3: Requirements / PRD
113
+ |- Ref: phases/03-requirements.md
114
+ |- Gemini CLI: expand goals into functional + non-functional requirements
115
+ |- Generate acceptance criteria per requirement
116
+ |- RFC 2119 behavioral constraints (MUST/SHOULD/MAY)
117
+ |- Core entity data model definitions
118
+ |- Glossary injection for terminology consistency
119
+ |- User priority sorting: MoSCoW (interactive, -y auto-assigns)
120
+ |- Output: requirements/ directory (_index.md + REQ-*.md + NFR-*.md, from template)
121
+
122
+ Phase 4: Architecture
123
+ |- Ref: phases/04-architecture.md
124
+ |- Gemini CLI: core components, tech stack, ADRs
125
+ |- Codebase integration mapping (conditional)
126
+ |- State machine generation (ASCII diagrams for lifecycle entities)
127
+ |- Configuration model definition (fields, types, defaults, constraints)
128
+ |- Error handling strategy (per-component classification + recovery)
129
+ |- Observability specification (metrics, logs, health checks)
130
+ |- Spec type profile injection (templates/profiles/{type}-profile.md)
131
+ |- Glossary injection for terminology consistency
132
+ |- Codex CLI: architecture challenge + review
133
+ |- Interactive ADR decisions (-y auto-accepts)
134
+ |- Output: architecture/ directory (_index.md + ADR-*.md, from template)
135
+
136
+ Phase 5: Epics & Stories
137
+ |- Ref: phases/05-epics-stories.md
138
+ |- Gemini CLI: requirement grouping into Epics, MVP subset tagging
139
+ |- Story generation: As a...I want...So that...
140
+ |- Dependency mapping (Mermaid)
141
+ |- Interactive validation (-y skips)
142
+ |- Output: epics/ directory (_index.md + EPIC-*.md, from template)
143
+
144
+ Phase 6: Readiness Check
145
+ |- Ref: phases/06-readiness-check.md
146
+ |- Cross-document validation (completeness, consistency, traceability)
147
+ |- Quality scoring per dimension
148
+ |- Terminology consistency validation (glossary compliance)
149
+ |- Scope containment validation (PRD <= Brief scope)
150
+ |- Output: readiness-report.md, spec-summary.md
151
+ |- Handoff options: lite-plan, req-plan, plan, issue:new, export only, iterate
152
+
153
+ Phase 6.5: Auto-Fix (conditional, triggered when Phase 6 score < 60%)
154
+ |- Ref: phases/06-5-auto-fix.md
155
+ |- Parse readiness-report.md for Error/Warning items
156
+ |- Group issues by originating Phase (2-5)
157
+ |- Re-generate affected sections via CLI with error context
158
+ |- Re-run Phase 6 validation
159
+ |- Max 2 iterations, then force handoff
160
+ |- Output: Updated Phase 2-5 documents
161
+
162
+ Complete: Full specification package ready for execution
163
+
164
+ Phase 6 → Handoff Bridge (conditional, based on user selection):
165
+ ├─ lite-plan: Extract first MVP Epic description → direct text input
166
+ ├─ plan / req-plan: Create WFS session + .brainstorming/ bridge files
167
+ │ ├─ guidance-specification.md (synthesized from spec outputs)
168
+ │ ├─ feature-specs/feature-index.json (Epic → Feature mapping)
169
+ │ └─ feature-specs/F-{num}-{slug}.md (one per Epic)
170
+ ├─ issue:new: Create issues per Epic
171
+ └─ context-search-agent auto-discovers .brainstorming/
172
+ → context-package.json.brainstorm_artifacts populated
173
+ → action-planning-agent consumes: guidance_spec (P1) → feature_index (P2)
174
+ ```
175
+
176
+ ## Directory Setup
177
+
178
+ ```javascript
179
+ // Session ID generation
180
+ const slug = topic.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-').slice(0, 40);
181
+ const date = new Date().toISOString().slice(0, 10);
182
+ const sessionId = `SPEC-${slug}-${date}`;
183
+ const workDir = `.workflow/.spec/${sessionId}`;
184
+
185
+ Bash(`mkdir -p "${workDir}"`);
186
+ ```
187
+
188
+ ## Output Structure
189
+
190
+ ```
191
+ .workflow/.spec/SPEC-{slug}-{YYYY-MM-DD}/
192
+ ├── spec-config.json # Session configuration + phase state
193
+ ├── discovery-context.json # Codebase exploration results (optional)
194
+ ├── refined-requirements.json # Phase 1.5: Confirmed requirements after discussion
195
+ ├── glossary.json # Phase 2: Terminology glossary for cross-doc consistency
196
+ ├── product-brief.md # Phase 2: Product brief
197
+ ├── requirements/ # Phase 3: Detailed PRD (directory)
198
+ │ ├── _index.md # Summary, MoSCoW table, traceability, links
199
+ │ ├── REQ-NNN-{slug}.md # Individual functional requirement
200
+ │ └── NFR-{type}-NNN-{slug}.md # Individual non-functional requirement
201
+ ├── architecture/ # Phase 4: Architecture decisions (directory)
202
+ │ ├── _index.md # Overview, components, tech stack, links
203
+ │ └── ADR-NNN-{slug}.md # Individual Architecture Decision Record
204
+ ├── epics/ # Phase 5: Epic/Story breakdown (directory)
205
+ │ ├── _index.md # Epic table, dependency map, MVP scope
206
+ │ └── EPIC-NNN-{slug}.md # Individual Epic with Stories
207
+ ├── readiness-report.md # Phase 6: Quality report
208
+ └── spec-summary.md # Phase 6: One-page executive summary
209
+ ```
210
+
211
+ ## State Management
212
+
213
+ **spec-config.json** serves as core state file:
214
+ ```json
215
+ {
216
+ "session_id": "SPEC-xxx-2026-02-11",
217
+ "seed_input": "User input text",
218
+ "input_type": "text",
219
+ "timestamp": "ISO8601",
220
+ "mode": "interactive",
221
+ "complexity": "moderate",
222
+ "depth": "standard",
223
+ "focus_areas": [],
224
+ "spec_type": "service",
225
+ "iteration_count": 0,
226
+ "iteration_history": [],
227
+ "seed_analysis": {
228
+ "problem_statement": "...",
229
+ "target_users": [],
230
+ "domain": "...",
231
+ "constraints": [],
232
+ "dimensions": []
233
+ },
234
+ "has_codebase": false,
235
+ "refined_requirements_file": "refined-requirements.json",
236
+ "phasesCompleted": [
237
+ { "phase": 1, "name": "discovery", "output_file": "spec-config.json", "completed_at": "ISO8601" },
238
+ { "phase": 1.5, "name": "requirement-clarification", "output_file": "refined-requirements.json", "discussion_rounds": 2, "completed_at": "ISO8601" },
239
+ { "phase": 3, "name": "requirements", "output_dir": "requirements/", "output_index": "requirements/_index.md", "file_count": 8, "completed_at": "ISO8601" }
240
+ ]
241
+ }
242
+ ```
243
+
244
+ **Resume mechanism**: `-c|--continue` flag reads `spec-config.json.phasesCompleted`, resumes from first incomplete phase.
245
+
246
+ ## Core Rules
247
+
248
+ 1. **Start Immediately**: First action is TaskCreate initialization, then Phase 0 (spec study), then Phase 1
249
+ 2. **Progressive Phase Loading**: Read phase docs ONLY when that phase is about to execute
250
+ 3. **Auto-Continue**: All phases run autonomously; check TaskList to execute next pending phase
251
+ 4. **Parse Every Output**: Extract required data from each phase for next phase context
252
+ 5. **DO NOT STOP**: Continuous 6-phase pipeline until all phases complete or user exits
253
+ 6. **Respect -y Flag**: When auto mode, skip all AskUserQuestion calls, use recommended defaults
254
+ 7. **Respect -c Flag**: When continue mode, load spec-config.json and resume from checkpoint
255
+ 8. **Inject Glossary**: From Phase 3 onward, inject glossary.json terms into every CLI prompt
256
+ 9. **Load Profile**: Read templates/profiles/{spec_type}-profile.md and inject requirements into Phase 2-5 prompts
257
+ 10. **Iterate on Failure**: When Phase 6 score < 60%, auto-trigger Phase 6.5 (max 2 iterations)
258
+
259
+ ## Reference Documents by Phase
260
+
261
+ ### Phase 1: Discovery
262
+ | Document | Purpose | When to Use |
263
+ |----------|---------|-------------|
264
+ | [phases/01-discovery.md](phases/01-discovery.md) | Seed analysis and session setup | Phase start |
265
+ | [templates/profiles/](templates/profiles/) | Spec type profiles | Spec type selection |
266
+ | [specs/document-standards.md](specs/document-standards.md) | Frontmatter format for spec-config.json | Config generation |
267
+
268
+ ### Phase 1.5: Requirement Expansion & Clarification
269
+ | Document | Purpose | When to Use |
270
+ |----------|---------|-------------|
271
+ | [phases/01-5-requirement-clarification.md](phases/01-5-requirement-clarification.md) | Interactive requirement discussion workflow | Phase start |
272
+ | [specs/quality-gates.md](specs/quality-gates.md) | Quality criteria for refined requirements | Validation |
273
+
274
+ ### Phase 2: Product Brief
275
+ | Document | Purpose | When to Use |
276
+ |----------|---------|-------------|
277
+ | [phases/02-product-brief.md](phases/02-product-brief.md) | Multi-CLI analysis orchestration | Phase start |
278
+ | [templates/product-brief.md](templates/product-brief.md) | Document template | Document generation |
279
+ | [specs/glossary-template.json](specs/glossary-template.json) | Glossary schema | Glossary generation |
280
+
281
+ ### Phase 3: Requirements
282
+ | Document | Purpose | When to Use |
283
+ |----------|---------|-------------|
284
+ | [phases/03-requirements.md](phases/03-requirements.md) | PRD generation workflow | Phase start |
285
+ | [templates/requirements-prd.md](templates/requirements-prd.md) | Document template | Document generation |
286
+
287
+ ### Phase 4: Architecture
288
+ | Document | Purpose | When to Use |
289
+ |----------|---------|-------------|
290
+ | [phases/04-architecture.md](phases/04-architecture.md) | Architecture decision workflow | Phase start |
291
+ | [templates/architecture-doc.md](templates/architecture-doc.md) | Document template | Document generation |
292
+
293
+ ### Phase 5: Epics & Stories
294
+ | Document | Purpose | When to Use |
295
+ |----------|---------|-------------|
296
+ | [phases/05-epics-stories.md](phases/05-epics-stories.md) | Epic/Story decomposition | Phase start |
297
+ | [templates/epics-template.md](templates/epics-template.md) | Document template | Document generation |
298
+
299
+ ### Phase 6: Readiness Check
300
+ | Document | Purpose | When to Use |
301
+ |----------|---------|-------------|
302
+ | [phases/06-readiness-check.md](phases/06-readiness-check.md) | Cross-document validation | Phase start |
303
+ | [specs/quality-gates.md](specs/quality-gates.md) | Quality scoring criteria | Validation |
304
+
305
+ ### Phase 6.5: Auto-Fix
306
+ | Document | Purpose | When to Use |
307
+ |----------|---------|-------------|
308
+ | [phases/06-5-auto-fix.md](phases/06-5-auto-fix.md) | Auto-fix workflow for readiness issues | When Phase 6 score < 60% |
309
+ | [specs/quality-gates.md](specs/quality-gates.md) | Iteration exit criteria | Validation |
310
+
311
+ ### Debugging & Troubleshooting
312
+ | Issue | Solution Document |
313
+ |-------|-------------------|
314
+ | Phase execution failed | Refer to the relevant Phase documentation |
315
+ | Output does not meet expectations | [specs/quality-gates.md](specs/quality-gates.md) |
316
+ | Document format issues | [specs/document-standards.md](specs/document-standards.md) |
317
+
318
+ ## Error Handling
319
+
320
+ | Phase | Error | Blocking? | Action |
321
+ |-------|-------|-----------|--------|
322
+ | Phase 1 | Empty input | Yes | Error and exit |
323
+ | Phase 1 | CLI seed analysis fails | No | Use basic parsing fallback |
324
+ | Phase 1.5 | Gap analysis CLI fails | No | Skip to user questions with basic prompts |
325
+ | Phase 1.5 | User skips discussion | No | Proceed with seed_analysis as-is |
326
+ | Phase 1.5 | Max rounds reached (5) | No | Force confirmation with current state |
327
+ | Phase 2 | Single CLI perspective fails | No | Continue with available perspectives |
328
+ | Phase 2 | All CLI calls fail | No | Generate basic brief from seed analysis |
329
+ | Phase 3 | Gemini CLI fails | No | Use codex fallback |
330
+ | Phase 4 | Architecture review fails | No | Skip review, proceed with initial analysis |
331
+ | Phase 5 | Story generation fails | No | Generate epics without detailed stories |
332
+ | Phase 6 | Validation CLI fails | No | Generate partial report with available data |
333
+ | Phase 6.5 | Auto-fix CLI fails | No | Log failure, proceed to handoff with Review status |
334
+ | Phase 6.5 | Max iterations reached | No | Force handoff, report remaining issues |
335
+
336
+ ### CLI Fallback Chain
337
+
338
+ Gemini -> Codex -> Claude -> degraded mode (local analysis only)