claude-code-workflow 7.2.24 → 7.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ccw/workflows/cli-tools-usage.md +123 -521
- package/.claude/CLAUDE.md +20 -0
- package/.claude/agents/action-planning-agent.md +6 -0
- package/.claude/agents/cli-explore-agent.md +63 -77
- package/.claude/agents/cli-lite-planning-agent.md +10 -11
- package/.claude/agents/issue-plan-agent.md +7 -2
- package/.claude/commands/workflow/spec/setup.md +1 -1
- package/.claude/skills/brainstorm/SKILL.md +408 -408
- package/.claude/skills/review-cycle/SKILL.md +132 -132
- package/.claude/skills/review-cycle/phases/review-module.md +4 -4
- package/.claude/skills/review-cycle/phases/review-session.md +4 -4
- package/.claude/skills/spec-generator/SKILL.md +1 -1
- package/.claude/skills/team-designer/phases/02-scaffold-generation.md +1 -1
- package/.claude/skills/team-lifecycle-v4/SKILL.md +1 -1
- package/.claude/skills/team-review/SKILL.md +1 -1
- package/.claude/skills/team-ultra-analyze/SKILL.md +1 -1
- package/.claude/skills/workflow-multi-cli-plan/SKILL.md +3 -3
- package/.claude/skills/workflow-plan/SKILL.md +1 -1
- package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +2 -2
- package/.claude/skills/workflow-plan/phases/05-plan-verify.md +2 -2
- package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +3 -3
- package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +2 -2
- package/.claude/skills/workflow-test-fix/SKILL.md +1 -1
- package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +2 -2
- package/.codex/AGENTS.md +16 -0
- package/.codex/skills/analyze-with-file/SKILL.md +966 -966
- package/.codex/skills/issue-discover/SKILL.md +361 -361
- package/.codex/skills/review-cycle/SKILL.md +1 -1
- package/.codex/skills/roadmap-with-file/SKILL.md +901 -901
- package/.codex/skills/spec-generator/SKILL.md +425 -425
- package/.codex/skills/spec-setup/SKILL.md +669 -669
- package/.codex/skills/team-designer/phases/02-scaffold-generation.md +1 -1
- package/.codex/skills/workflow-test-fix-cycle/SKILL.md +402 -402
- package/ccw/dist/tools/index.d.ts.map +1 -1
- package/ccw/dist/tools/index.js +2 -0
- package/ccw/dist/tools/index.js.map +1 -1
- package/ccw/dist/tools/json-builder.d.ts +17 -0
- package/ccw/dist/tools/json-builder.d.ts.map +1 -0
- package/ccw/dist/tools/json-builder.js +746 -0
- package/ccw/dist/tools/json-builder.js.map +1 -0
- package/ccw/dist/tools/schema-registry.d.ts +71 -0
- package/ccw/dist/tools/schema-registry.d.ts.map +1 -0
- package/ccw/dist/tools/schema-registry.js +136 -0
- package/ccw/dist/tools/schema-registry.js.map +1 -0
- package/package.json +1 -1
- package/.claude/skills/team-iterdev/SKILL.md +0 -127
- package/.claude/skills/team-iterdev/roles/architect/role.md +0 -65
- package/.claude/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
- package/.claude/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -234
- package/.claude/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -182
- package/.claude/skills/team-iterdev/roles/coordinator/role.md +0 -153
- package/.claude/skills/team-iterdev/roles/developer/role.md +0 -74
- package/.claude/skills/team-iterdev/roles/reviewer/role.md +0 -66
- package/.claude/skills/team-iterdev/roles/tester/role.md +0 -88
- package/.claude/skills/team-iterdev/specs/pipelines.md +0 -94
- package/.claude/skills/team-iterdev/specs/team-config.json +0 -172
- package/.codex/prompts/prep-cycle.md +0 -416
- package/.codex/prompts/prep-plan.md +0 -371
- package/.codex/skills/team-iterdev/SKILL.md +0 -219
- package/.codex/skills/team-iterdev/roles/architect/role.md +0 -65
- package/.codex/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
- package/.codex/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -187
- package/.codex/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -227
- package/.codex/skills/team-iterdev/roles/coordinator/role.md +0 -193
- package/.codex/skills/team-iterdev/roles/developer/role.md +0 -74
- package/.codex/skills/team-iterdev/roles/reviewer/role.md +0 -66
- package/.codex/skills/team-iterdev/roles/tester/role.md +0 -88
- package/.codex/skills/team-iterdev/specs/pipelines.md +0 -94
- 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)
|