maestro-flow 0.3.22 → 0.3.24

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 (144) hide show
  1. package/.claude/commands/maestro-analyze.md +1 -1
  2. package/.claude/commands/maestro-brainstorm.md +1 -1
  3. package/.claude/commands/maestro-composer.md +3 -3
  4. package/.claude/commands/maestro-init.md +4 -4
  5. package/.claude/commands/maestro-roadmap.md +164 -108
  6. package/.claude/commands/maestro.md +19 -10
  7. package/.claude/commands/quality-business-test.md +2 -2
  8. package/.claude/skills/team-quality-assurance/roles/scout/role.md +1 -1
  9. package/.claude/skills/team-review/roles/reviewer/role.md +1 -1
  10. package/.claude/skills/team-review/roles/scanner/role.md +1 -1
  11. package/.claude/skills/team-tech-debt/roles/scanner/role.md +3 -3
  12. package/.codex/skills/maestro/SKILL.md +12 -9
  13. package/.codex/skills/maestro-brainstorm/SKILL.md +1 -1
  14. package/.codex/skills/maestro-composer/SKILL.md +3 -3
  15. package/.codex/skills/maestro-init/SKILL.md +1 -1
  16. package/.codex/skills/maestro-link-coordinate/SKILL.md +1 -1
  17. package/.codex/skills/maestro-player/SKILL.md +2 -2
  18. package/.codex/skills/maestro-roadmap/SKILL.md +443 -332
  19. package/.codex/skills/quality-business-test/SKILL.md +2 -2
  20. package/.codex/skills/team-coordinate/roles/coordinator/role.md +1 -1
  21. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +1 -1
  22. package/.codex/skills/team-quality-assurance/roles/scout/role.md +1 -1
  23. package/.codex/skills/team-review/roles/reviewer/role.md +1 -1
  24. package/.codex/skills/team-review/roles/scanner/role.md +1 -1
  25. package/.codex/skills/team-tech-debt/roles/scanner/role.md +3 -3
  26. package/chains/singles/spec-generate.json +3 -3
  27. package/chains/spec-driven.json +2 -2
  28. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -0
  29. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  30. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js +2 -2
  31. package/dashboard/dist-server/dashboard/src/server/coordinator/chain-map.js.map +1 -1
  32. package/dashboard/dist-server/dashboard/src/server/routes/install-utils.d.ts +5 -12
  33. package/dashboard/dist-server/dashboard/src/server/routes/install-utils.js +10 -65
  34. package/dashboard/dist-server/dashboard/src/server/routes/install-utils.js.map +1 -1
  35. package/dashboard/dist-server/dashboard/src/server/routes/install.js +17 -11
  36. package/dashboard/dist-server/dashboard/src/server/routes/install.js.map +1 -1
  37. package/dashboard/dist-server/src/agents/cli-agent-runner.d.ts +4 -0
  38. package/dashboard/dist-server/src/agents/cli-agent-runner.js +4 -2
  39. package/dashboard/dist-server/src/agents/cli-agent-runner.js.map +1 -1
  40. package/dashboard/dist-server/src/commands/delegate.d.ts +2 -0
  41. package/dashboard/dist-server/src/commands/delegate.js +20 -4
  42. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  43. package/dashboard/dist-server/src/config/cli-tools-config.d.ts +68 -3
  44. package/dashboard/dist-server/src/config/cli-tools-config.js +248 -9
  45. package/dashboard/dist-server/src/config/cli-tools-config.js.map +1 -1
  46. package/dist/src/agents/cli-agent-runner.d.ts +4 -0
  47. package/dist/src/agents/cli-agent-runner.d.ts.map +1 -1
  48. package/dist/src/agents/cli-agent-runner.js +4 -2
  49. package/dist/src/agents/cli-agent-runner.js.map +1 -1
  50. package/dist/src/cli.js +2 -0
  51. package/dist/src/cli.js.map +1 -1
  52. package/dist/src/commands/cli.d.ts.map +1 -1
  53. package/dist/src/commands/cli.js +21 -4
  54. package/dist/src/commands/cli.js.map +1 -1
  55. package/dist/src/commands/delegate.d.ts +2 -0
  56. package/dist/src/commands/delegate.d.ts.map +1 -1
  57. package/dist/src/commands/delegate.js +20 -4
  58. package/dist/src/commands/delegate.js.map +1 -1
  59. package/dist/src/commands/install-backend.d.ts +5 -16
  60. package/dist/src/commands/install-backend.d.ts.map +1 -1
  61. package/dist/src/commands/install-backend.js +8 -104
  62. package/dist/src/commands/install-backend.js.map +1 -1
  63. package/dist/src/commands/install-ui/ExecutionView.js +1 -1
  64. package/dist/src/commands/install-ui/ExecutionView.js.map +1 -1
  65. package/dist/src/commands/install-ui/InstallExecution.d.ts +1 -0
  66. package/dist/src/commands/install-ui/InstallExecution.d.ts.map +1 -1
  67. package/dist/src/commands/install-ui/InstallExecution.js +19 -4
  68. package/dist/src/commands/install-ui/InstallExecution.js.map +1 -1
  69. package/dist/src/commands/install-ui/InstallResult.d.ts.map +1 -1
  70. package/dist/src/commands/install-ui/InstallResult.js +1 -1
  71. package/dist/src/commands/install-ui/InstallResult.js.map +1 -1
  72. package/dist/src/commands/install.d.ts.map +1 -1
  73. package/dist/src/commands/install.js +28 -3
  74. package/dist/src/commands/install.js.map +1 -1
  75. package/dist/src/commands/tools-ui/CommandReference.d.ts +7 -0
  76. package/dist/src/commands/tools-ui/CommandReference.d.ts.map +1 -0
  77. package/dist/src/commands/tools-ui/CommandReference.js +33 -0
  78. package/dist/src/commands/tools-ui/CommandReference.js.map +1 -0
  79. package/dist/src/commands/tools-ui/ConfigSources.d.ts +6 -0
  80. package/dist/src/commands/tools-ui/ConfigSources.d.ts.map +1 -0
  81. package/dist/src/commands/tools-ui/ConfigSources.js +27 -0
  82. package/dist/src/commands/tools-ui/ConfigSources.js.map +1 -0
  83. package/dist/src/commands/tools-ui/RegisterSettings.d.ts +8 -0
  84. package/dist/src/commands/tools-ui/RegisterSettings.d.ts.map +1 -0
  85. package/dist/src/commands/tools-ui/RegisterSettings.js +125 -0
  86. package/dist/src/commands/tools-ui/RegisterSettings.js.map +1 -0
  87. package/dist/src/commands/tools-ui/RoleMappings.d.ts +9 -0
  88. package/dist/src/commands/tools-ui/RoleMappings.d.ts.map +1 -0
  89. package/dist/src/commands/tools-ui/RoleMappings.js +104 -0
  90. package/dist/src/commands/tools-ui/RoleMappings.js.map +1 -0
  91. package/dist/src/commands/tools-ui/ToolsDashboard.d.ts +8 -0
  92. package/dist/src/commands/tools-ui/ToolsDashboard.d.ts.map +1 -0
  93. package/dist/src/commands/tools-ui/ToolsDashboard.js +60 -0
  94. package/dist/src/commands/tools-ui/ToolsDashboard.js.map +1 -0
  95. package/dist/src/commands/tools-ui/ToolsOverview.d.ts +9 -0
  96. package/dist/src/commands/tools-ui/ToolsOverview.d.ts.map +1 -0
  97. package/dist/src/commands/tools-ui/ToolsOverview.js +84 -0
  98. package/dist/src/commands/tools-ui/ToolsOverview.js.map +1 -0
  99. package/dist/src/commands/tools.d.ts +3 -0
  100. package/dist/src/commands/tools.d.ts.map +1 -0
  101. package/dist/src/commands/tools.js +78 -0
  102. package/dist/src/commands/tools.js.map +1 -0
  103. package/dist/src/config/cli-tools-config.d.ts +68 -3
  104. package/dist/src/config/cli-tools-config.d.ts.map +1 -1
  105. package/dist/src/config/cli-tools-config.js +248 -9
  106. package/dist/src/config/cli-tools-config.js.map +1 -1
  107. package/dist/src/core/component-defs.d.ts +16 -0
  108. package/dist/src/core/component-defs.d.ts.map +1 -0
  109. package/dist/src/core/component-defs.js +142 -0
  110. package/dist/src/core/component-defs.js.map +1 -0
  111. package/dist/src/core/manifest.d.ts +8 -1
  112. package/dist/src/core/manifest.d.ts.map +1 -1
  113. package/dist/src/core/manifest.js +29 -40
  114. package/dist/src/core/manifest.js.map +1 -1
  115. package/dist/src/core/tag-injector.d.ts +72 -0
  116. package/dist/src/core/tag-injector.d.ts.map +1 -0
  117. package/dist/src/core/tag-injector.js +228 -0
  118. package/dist/src/core/tag-injector.js.map +1 -0
  119. package/dist/src/index.d.ts +4 -0
  120. package/dist/src/index.d.ts.map +1 -1
  121. package/dist/src/index.js +2 -0
  122. package/dist/src/index.js.map +1 -1
  123. package/dist/tsconfig.tsbuildinfo +1 -0
  124. package/package.json +1 -1
  125. package/templates/cli/prompts/workflow-skill-conflict-patterns.txt +1 -1
  126. package/templates/cli/prompts/workflow-skill-lessons-learned.txt +1 -1
  127. package/templates/search-tools.md +1 -1
  128. package/templates/workflows/specs/node-catalog.md +1 -1
  129. package/workflows/brainstorm.md +1 -1
  130. package/{.claude/CLAUDE.md → workflows/claude-instructions.md} +25 -26
  131. package/workflows/cli-tools-usage.md +16 -2
  132. package/workflows/codex-instructions.md +150 -0
  133. package/workflows/delegate-usage.md +16 -2
  134. package/workflows/execute.md +28 -14
  135. package/workflows/init.md +2 -2
  136. package/workflows/issue-discover.md +2 -2
  137. package/workflows/maestro-super.md +120 -0
  138. package/workflows/maestro.codex.md +4 -4
  139. package/workflows/maestro.md +5 -5
  140. package/workflows/roadmap-common.md +197 -0
  141. package/workflows/roadmap.md +190 -355
  142. package/workflows/spec-generate.md +457 -544
  143. package/.claude/commands/maestro-spec-generate.md +0 -78
  144. package/.codex/skills/maestro-spec-generate/SKILL.md +0 -355
@@ -1,544 +1,457 @@
1
- # Workflow: Spec Generate
2
-
3
- Specification document chain producing a complete specification package (Product Brief, PRD, Architecture, Epics, Roadmap) through 7 sequential phases with multi-CLI analysis and interactive refinement. Pure documentation — no code generation.
4
-
5
- ## Worktree Guard
6
-
7
- Block if `.workflow/worktree-scope.json` exists — must run from main worktree.
8
-
9
- ## Pipeline Position
10
-
11
- ```
12
- brainstorm (optional) → init (REQUIRED) → spec-generate → plan → execute → verify
13
- Alternative light path: init → roadmap → plan (skip spec-generate)
14
- ```
15
-
16
- ## Architecture
17
-
18
- ```
19
- P0: Spec StudyP1: Discovery P1.5: Req Expansion P2: Product Brief P3: PRD P4: Architecture P5: EpicsP6: Readiness Check → P7: Roadmap
20
-
21
- P6 gate: Pass (>=80%) → P7 | Review (60-79%) → P7 w/caveats | Fail (<60%) → P6.5 Auto-Fix (max 2 iter) → re-check
22
- ```
23
-
24
- ## Arguments
25
-
26
- ```
27
- $ARGUMENTS: "<idea or @file> [-y] [-c] [--from-brainstorm SESSION-ID]"
28
-
29
- <idea> -- Idea text or @file reference
30
- -y / --yes -- Auto mode, skip interactive questions
31
- -c / --continue -- Resume from last checkpoint
32
- --from-brainstorm -- Import brainstorm session as enriched seed
33
- ```
34
-
35
- ## Output Structure
36
-
37
- ```
38
- .workflow/.spec/SPEC-{slug}-{YYYY-MM-DD}/
39
- ├── spec-config.json # Session configuration + phase state
40
- ├── discovery-context.json # Codebase exploration (optional)
41
- ├── refined-requirements.json # Phase 1.5: Confirmed requirements
42
- ├── glossary.json # Phase 2: Terminology glossary
43
- ├── product-brief.md # Phase 2: Product brief
44
- ├── requirements/ # Phase 3: Detailed PRD
45
- ├── _index.md # Summary, MoSCoW table, traceability
46
- ├── REQ-NNN-{slug}.md # Functional requirement
47
- └── NFR-{type}-NNN-{slug}.md # Non-functional requirement
48
- ├── architecture/ # Phase 4: Architecture decisions
49
- ├── _index.md # Overview, components, tech stack
50
- └── ADR-NNN-{slug}.md # Architecture Decision Record
51
- ├── epics/ # Phase 5: Epic/Story breakdown
52
- ├── _index.md # Epic table, dependency map, MVP
53
- │ └── EPIC-NNN-{slug}.md # Individual Epic with Stories
54
- ├── readiness-report.md # Phase 6: Quality report
55
- ├── spec-summary.md # Phase 6: Executive summary
56
- └── roadmap.md # Phase 7: Project roadmap (also written to .workflow/roadmap.md)
57
- ```
58
-
59
- ---
60
-
61
- ## Process
62
-
63
- ### Step 1: Prerequisite Loading (Phase 0)
64
-
65
- Before any operations, load specification and template documents:
66
-
67
- | Document | Purpose | Priority |
68
- |----------|---------|----------|
69
- | Document standards | Format, frontmatter, naming conventions | P0 - must read |
70
- | Quality gates | Per-phase quality criteria and scoring | P0 - must read |
71
- | Templates | product-brief, requirements-prd, architecture-doc, epics-template | Read on-demand per phase |
72
-
73
- **Load project specs:**
74
- ```
75
- specs_content = maestro spec load --category arch
76
- ```
77
- Used in Phase 3 (architecture doc) and Phase 6 (epic decomposition) for constraint awareness.
78
-
79
- These inform validation and output formatting for all subsequent phases.
80
-
81
- **Load project history (if `.workflow/` exists):**
82
- - `project.md` already_shipped (Validated), current_scope (Active), project_history (Context), locked_decisions (Key Decisions)
83
- - `state.json.accumulated_context` deferred[] (high priority candidates), key_decisions[] (architectural constraints)
84
-
85
- **Rules**:
86
- - Features in `already_shipped` are EXCLUDED from spec generation scope — they are done
87
- - `deferred` items from previous milestone are HIGH PRIORITY candidates
88
- - `locked_decisions` constrain architecture choices in Phase 4
89
- - `lessons_learned` inform risk assessment in Phase 1 and architecture decisions in Phase 4
90
- - Pass assembled `project_context` to Phase 1 seed analysis and Phase 7 roadmap generation
91
-
92
- ### Step 2: Discovery & Seed Analysis (Phase 1)
93
-
94
- Parse input, analyze the seed idea, optionally explore codebase, establish session.
95
-
96
- **Step 2.1: Input Parsing**
97
- - Parse $ARGUMENTS: extract idea/topic, flags (-y, -c, --from-brainstorm)
98
- - If `-c`: read spec-config.json, resume from first incomplete phase
99
- - If `--from-brainstorm SESSION-ID`:
100
- - Locate brainstorm session directory
101
- - Read `guidance-specification.md` as enriched seed (already has terminology, non-goals, feature decomposition)
102
- - Extract problem statement, features, roles from specification
103
- - Set `input_type: "brainstorm"` — skip Phase 1.5 (requirements already clarified)
104
- - If `@file`: read file content as seed
105
- - If text: use directly as seed
106
- - Missing input → error E001
107
-
108
- **Step 2.2: Session Initialization**
109
- ```
110
- Session ID: SPEC-{slug}-{YYYY-MM-DD}
111
- Output dir: .workflow/.spec/{session_id}/
112
- ```
113
-
114
- **Step 2.3: Seed Analysis via CLI**
115
- - Spawn CLI analysis to extract: problem_statement, target_users, domain, constraints, dimensions (3-5)
116
- - Assess complexity: simple (1-2 components) / moderate (3-5) / complex (6+)
117
- - For brainstorm input: enrich with feature decomposition data
118
-
119
- **Step 2.4: Codebase Exploration (conditional)**
120
- - Detect if project has source files (*.ts, *.js, *.py, etc.)
121
- - If yes: spawn cli-explore-agent for context discovery
122
- - Output: `discovery-context.json` with relevant_files, patterns, tech_stack
123
-
124
- **Step 2.5: External Research API & Technology Details (Optional)**
125
-
126
- Spawn `workflow-external-researcher` agent to gather concrete API details, library versions, and integration patterns for the technologies identified in seed analysis and codebase exploration.
127
-
128
- **Trigger**: When seed analysis identifies specific technologies, APIs, or external services. Auto-trigger in auto mode (`-y`). Skip if topic is purely conceptual with no technology keywords.
129
-
130
- Extract named technologies/APIs/frameworks/protocols from seed analysis and codebase exploration.
131
-
132
- If topics found spawn `workflow-external-researcher` agent for API research:
133
- - Per technology: stable version, API surface (endpoints, auth, rate limits), integration patterns, data models, limitations/deprecations
134
- - Focus on concrete details (versions, method signatures, config options)
135
- - Output `apiResearchContext` (in-memory)
136
-
137
- If no topics `apiResearchContext = null`, skip to Step 2.6.
138
-
139
- `apiResearchContext` is passed into:
140
- - Step 4 (Product Brief): technology feasibility assessment
141
- - Step 5 (Requirements): API-aware requirement writing with concrete constraints
142
- - Step 6 (Architecture): informed ADR decisions with version-specific details
143
- - Step 7 (Epics): realistic story sizing based on API complexity
144
-
145
- If research fails (W005): `apiResearchContext = null`, continue without external context.
146
-
147
- **Step 2.6: Spec Type Selection**
148
- - Interactive (AskUserQuestion): Service / API / Library / Platform
149
- - `--yes`: default to "service"
150
- - Each type loads a profile template for domain-specific sections
151
-
152
- **Step 2.7: User Confirmation (interactive)**
153
- - Confirm problem statement, select depth (Light/Standard/Comprehensive), select focus areas
154
- - `--yes`: accept all defaults
155
-
156
- **Output**: `spec-config.json` (session state), `discovery-context.json` (optional), `apiResearchContext` (in-memory, optional)
157
-
158
- ### Step 3: Requirement Expansion & Clarification (Phase 1.5)
159
-
160
- Skip if `--from-brainstorm` (requirements already in guidance-specification.md).
161
-
162
- **Step 3.1: CLI Gap Analysis**
163
- - Analyze seed for completeness (score 1-10), identify missing dimensions
164
- - Generate 3-5 clarification areas with questions and expansion suggestions
165
- - Dimensions checked: functional scope, user scenarios, NFRs, integrations, data model, error handling
166
-
167
- **Step 3.2: Interactive Discussion Loop (max 5 rounds)**
168
- - Round 1: present gap analysis + expansion suggestions via AskUserQuestion
169
- - Round N: CLI follow-up analysis based on user responses, refine requirements
170
- - User can: answer questions, accept suggestions, or skip to generation
171
- - `--yes`: CLI auto-expansion without interaction
172
-
173
- **Step 3.3: User Confirmation**
174
- - Present requirement summary, user confirms or requests adjustments
175
- - `--yes`: auto-confirm
176
-
177
- **Output**: `refined-requirements.json` (confirmed features, NFRs, boundaries, assumptions)
178
-
179
- ### Step 4: Product Brief (Phase 2)
180
-
181
- Generate product brief through multi-perspective CLI analysis.
182
-
183
- **Step 4.1: Load Context**
184
- - Read refined-requirements.json (preferred) or seed_analysis fallback
185
- - Read discovery-context.json (if codebase detected)
186
- - For brainstorm input: read guidance-specification.md sections
187
-
188
- **Step 4.2: Multi-CLI Parallel Analysis (3 perspectives)**
189
-
190
- | Perspective | CLI Tool | Focus |
191
- |-------------|----------|-------|
192
- | Product | gemini | Vision, market fit, success criteria, scope boundaries |
193
- | Technical | codex | Feasibility, constraints, integration complexity, tech recommendations |
194
- | User | claude | Personas, journey maps, pain points, UX criteria |
195
-
196
- **Step 4.3: Synthesis**
197
- - Extract convergent themes (all agree), conflicts (need resolution), unique insights
198
- - For brainstorm input: cross-reference with guidance-specification decisions
199
- - If `apiResearchContext` is set: inject API details into technical feasibility assessment, enrich technology recommendations with concrete versions and constraints
200
-
201
- **Step 4.4: Interactive Refinement**
202
- - Present synthesis, user adjusts scope/vision
203
- - `--yes`: accept synthesis as-is
204
-
205
- **Step 4.5: Generate Outputs**
206
- - `product-brief.md` from template (YAML frontmatter + filled content)
207
- - `glossary.json` — 5+ core terms extracted from product brief and CLI analysis
208
- - Each term: canonical name, definition, aliases, category (core/technical/business)
209
- - Injected into all subsequent phase CLI prompts for terminology consistency
210
-
211
- **Output**: `product-brief.md`, `glossary.json`
212
-
213
- ### Step 5: Requirements / PRD (Phase 3)
214
-
215
- Generate detailed PRD with functional/non-functional requirements.
216
-
217
- **Step 5.1: Requirement Expansion via CLI**
218
- - For each product brief goal, generate 3-7 functional requirements
219
- - Each requirement: REQ-NNN ID, title, description, user story, 2-4 acceptance criteria
220
- - Generate non-functional requirements: performance, security, scalability, usability
221
- - Apply RFC 2119 keywords (MUST/SHOULD/MAY) to all behavioral constraints
222
- - Define core entity data models: fields, types, constraints, relationships
223
- - Inject glossary.json for terminology consistency
224
-
225
- **Step 5.2: MoSCoW Priority Sorting (interactive)**
226
- - Present requirements grouped by initial priority
227
- - User adjusts Must/Should/Could/Won't labels
228
- - Select MVP scope: Must-only / Must+key Should / Comprehensive
229
- - `--yes`: accept CLI-suggested priorities
230
-
231
- **Step 5.3: Generate Directory**
232
- - `requirements/_index.md` summary table, MoSCoW breakdown, traceability matrix
233
- - `requirements/REQ-NNN-{slug}.md` — one per functional requirement
234
- - `requirements/NFR-{type}-NNN-{slug}.md` — one per non-functional requirement
235
-
236
- **Output**: `requirements/` directory (index + individual files)
237
-
238
- ### Step 6: Architecture (Phase 4)
239
-
240
- Generate architecture decisions, component design, and technology selections.
241
-
242
- **Step 6.1: Architecture Analysis via CLI (gemini)**
243
- - System architecture style with justification
244
- - Core components and responsibilities
245
- - Component interaction diagram (Mermaid graph TD)
246
- - Technology stack: languages, frameworks, databases, infrastructure
247
- - 2-4 Architecture Decision Records (ADRs): context, decision, alternatives, consequences
248
- - Data model: entities and relationships (Mermaid erDiagram)
249
- - Security architecture: auth, authorization, data protection
250
- - **State machine**: ASCII diagram + transition table for lifecycle entities (service/platform type)
251
- - **Configuration model**: all configurable fields with type, default, constraint
252
- - **Error handling strategy**: per-component classification (transient/permanent/degraded), recovery mechanisms
253
- - **Observability**: key metrics (5+), structured log events, health checks
254
- - Spec type profile injection for domain-specific depth
255
- - Glossary injection for terminology consistency
256
- - If `apiResearchContext` is set: inject as "External API Research" context — concrete versions, API surfaces, integration patterns inform ADR decisions and technology stack selection
257
-
258
- **Step 6.2: Architecture Review via CLI (codex)**
259
- - Challenge each ADR, identify scalability bottlenecks
260
- - Assess security gaps, evaluate technology choices
261
- - Rate overall quality 1-5
262
-
263
- **Step 6.3: Interactive ADR Decisions**
264
- - Present ADRs with review feedback, user decides: accept / incorporate feedback / simplify
265
- - `--yes`: auto-accept
266
-
267
- **Step 6.4: Codebase Integration Mapping (conditional)**
268
- - Map new components to existing code modules
269
-
270
- **Step 6.5: Generate Directory**
271
- - `architecture/_index.md` — overview, component diagram, tech stack, data model, security
272
- - `architecture/ADR-NNN-{slug}.md` one per Architecture Decision Record
273
-
274
- **Output**: `architecture/` directory (index + individual ADR files)
275
-
276
- ### Step 7: Epics & Stories (Phase 5)
277
-
278
- Decompose specification into executable Epics and Stories.
279
-
280
- **Step 7.1: Epic Decomposition via CLI**
281
- - Group requirements into logical Epics (EPIC-NNN IDs). Epic count is unconstrained Phase 7 will merge Epics into minimal phases via the minimum-phase principle.
282
- - Tag MVP subset
283
- - For each Epic: 2-5 Stories in "As a...I want...So that..." format
284
- - Each Story: 2-4 testable acceptance criteria, relative size (S/M/L/XL), trace to REQ-NNN
285
- - Cross-Epic dependency map (Mermaid graph LR)
286
- - Recommended execution order with rationale
287
- - MVP definition of done (3-5 criteria)
288
-
289
- **Epic sizing awareness** (informs Phase 7 roadmap generation):
290
- - Epics that are too small (1-2 Stories, all size S) should be flagged for merge in Phase 7
291
- - Each Epic should carry enough substance to become part of a phase with 5+ tasks
292
- - Prefer fewer, larger Epics over many tiny ones
293
-
294
- **Step 7.2: Interactive Validation**
295
- - Present Epic overview, user adjusts: merge/split epics, adjust MVP scope
296
- - `--yes`: accept as-is
297
-
298
- **Step 7.3: Generate Directory**
299
- - `epics/_index.md` — overview table, dependency map, MVP scope, execution order, traceability
300
- - `epics/EPIC-NNN-{slug}.md` one per Epic with embedded Stories
301
-
302
- **Output**: `epics/` directory (index + individual Epic files)
303
-
304
- ### Step 8: Readiness Check & Handoff (Phase 6)
305
-
306
- Validate specification package and provide execution handoff.
307
-
308
- **Step 8.1: Cross-Document Validation via CLI**
309
- Score on 4 dimensions (25% each):
310
- 1. **Completeness**: all required sections present with substantive content
311
- 2. **Consistency**: terminology uniform (glossary compliance), scope containment, non-goals respected
312
- 3. **Traceability**: goals → requirements → architecture → epics (matrix generated)
313
- 4. **Depth**: acceptance criteria testable, ADRs justified, stories estimable
314
-
315
- Gate decision: Pass (>=80) / Review (60-79) / Fail (<60)
316
-
317
- **Step 8.2: Generate Reports**
318
- - `readiness-report.md` — quality scores, issue list (Error/Warning/Info), traceability matrix
319
- - `spec-summary.md` one-page executive summary
320
-
321
- **Step 8.3: Update Document Status**
322
- - All document frontmatter updated to `status: complete`
323
-
324
- **Step 8.4: Gate Routing**
325
-
326
- | Gate Result | Action |
327
- |-------------|--------|
328
- | Pass (>=80%) | Proceed to Step 11 (Phase 7: Roadmap Generation) |
329
- | Review (60-79%) | Proceed to Step 11 with caveats logged |
330
- | Fail (<60%) | Trigger Step 9 (Phase 6.5 Auto-Fix), then re-run Step 8 |
331
-
332
- ### Step 9: Auto-Fix (Phase 6.5, conditional)
333
-
334
- Triggered when Phase 6 score < 60%. Automatically repair specification issues.
335
-
336
- **Step 9.1: Parse Readiness Report**
337
- - Extract Error and Warning items
338
- - Group by originating phase (2-5)
339
- - Map to affected output files
340
-
341
- **Step 9.2: Fix Affected Phases (sequential, Phase 2→3→4→5)**
342
- - For each phase with issues:
343
- - Read current phase output
344
- - CLI re-generation with error context injected
345
- - Inject glossary for terminology consistency
346
- - Preserve unflagged content, only fix flagged issues
347
- - Increment document version
348
-
349
- **Step 9.3: Re-run Phase 6**
350
- - Generate new readiness-report.md
351
- - If still Fail and iteration_count < 2: loop back
352
- - If Pass or max iterations (2) reached: proceed to handoff
353
-
354
- **Output**: Updated Phase 2-5 documents, updated spec-config.json with iteration tracking
355
-
356
- ### Step 11: Roadmap Generation (Phase 7)
357
-
358
- Convert Epics into an interactive roadmap with user confirmation.
359
-
360
- **Step 11.1: Epic→Phase Mapping**
361
- - Read `epics/_index.md` for Epic table, dependency map, MVP tags
362
- - Read individual `EPIC-NNN-{slug}.md` for Stories and acceptance criteria
363
- - Read `architecture/_index.md` for technical constraints (ADR decisions)
364
-
365
- **Minimum-Phase Principle (MANDATORY applied during mapping):**
366
-
367
- Phase = synchronization barrier (full plan→execute→verify cycle). Minimize phases for maximum execution efficiency. The wave DAG inside each Phase handles task ordering and parallelism.
368
-
369
- | Rule | Constraint |
370
- |------|-----------|
371
- | **Default** | **1 Phase**. Merge all Epics into a single phase; wave DAG handles internal ordering. |
372
- | **Maximum** | **2 Phases**. Only when a hard dependency boundary exists that cannot be resolved. |
373
- | **Exceptional** | **3 Phases**. Must explicitly justify why 2 is insufficient. |
374
- | **Minimum Stories per phase** | 5 Stories. If an Epic maps to fewer than 5 Stories, merge with related Epic. |
375
- | **Merge principle** | Small Epics (1-2 Stories, all size S) MUST be merged. Same-module or same-concern Epics belong together. Multiple Epics → one phase is normal. |
376
- | **Split principle** | Only split when ALL three hard-dependency conditions are met: (1) runtime dependency — cannot mock/stub, (2) not parallelizable via contract/interface, (3) full barrier — all of Phase A must complete before any of Phase B starts. |
377
-
378
- - Map (with minimum-phase principle applied):
379
- - Default: ALL Epics → 1 Phase (wave DAG orders tasks by Epic dependencies)
380
- - Only split if hard dependency conditions are all met
381
- - MVP-tagged Epics → Milestone 1, Post-MVP → Milestone 2+
382
- - Epic dependencies → wave ordering within phase (not phase splits)
383
- - Stories within Epics phase success criteria
384
- - ADR decisions phase technical constraints
385
-
386
- **Post-mapping sizing check:**
387
- 1. Count total phases. If > 2 justify each split against the 3 hard-dependency conditions, merge if unjustified.
388
- 2. Count Stories per phase. Any phase < 5 Stories → merge into neighbor.
389
- 3. Verify each phase has a meaningful deliverable boundary.
390
-
391
- **Scope escalation:**
392
- - **Single project** (any size): 1-2 Phases. Use wave DAG for internal parallelism.
393
- - **Large scope** (monorepo with 2+ independently deployable services): Use **Milestones**. Each Milestone follows the 1-2 Phase limit independently.
394
-
395
- **Step 11.2: Generate Draft Roadmap**
396
- - Produce `roadmap.md` following `@templates/roadmap.md` structure:
397
- ```markdown
398
- # Roadmap: {project_name}
399
-
400
- ## Overview
401
- <from product-brief.md vision>
402
-
403
- ## Phases
404
- - [ ] **Phase 1: {Epic Title}** - {one-line goal}
405
- - [ ] **Phase 2: {Epic Title}** - {one-line goal}
406
-
407
- ## Phase Details
408
-
409
- ### Phase 1: {Epic Title}
410
- **Goal**: {Epic goal}
411
- **Depends on**: {from Epic dependency map}
412
- **Requirements**: {REQ-IDs traced from Epic→Stories→Requirements}
413
- **Success Criteria** (what must be TRUE):
414
- 1. {from Stories' acceptance criteria — observable behavior}
415
- 2. {from Stories' acceptance criteria — observable behavior}
416
-
417
- ## Scope Decisions
418
- - **In scope**: {MVP Epics}
419
- - **Deferred**: {Post-MVP Epics}
420
- - **Out of scope**: {from product-brief non-goals}
421
-
422
- ## Progress
423
- | Phase | Status | Completed |
424
- |-------|--------|-----------|
425
- | 1. {Title} | Not started | - |
426
- ```
427
-
428
- **Step 11.3: Interactive Refinement (max 3 rounds)**
429
- - Present roadmap overview: phase count, milestone structure, dependency graph
430
- - **Before presenting**: validate minimum-phase principle (default 1, max 2, exceptional 3). Auto-merge violations and inform user.
431
- - User feedback via AskUserQuestion:
432
- - **Approve**: Run final sizing check before accepting
433
- - **Adjust Scope**: Move Epics between milestones, merge phases (enforce minimum-phase principle)
434
- - **Reorder**: Change phase sequencing
435
- - **Split/Merge**: Combine small phases (min 5 tasks enforced); splits require hard-dependency justification
436
- - `--yes`: auto-approve draft roadmap (minimum-phase principle still enforced automatically)
437
- - Each round: update roadmap.md, log change in iteration history
438
-
439
- **Step 11.4: Write Outputs**
440
- - Write `roadmap.md` to spec directory: `{spec_dir}/roadmap.md`
441
- - If `.workflow/` exists: also write to `.workflow/roadmap.md`
442
- - Update `spec-config.json`: add Phase 7 completion
443
-
444
- **Step 11.5: Handoff Options (AskUserQuestion)**
445
-
446
- | Option | Action |
447
- |--------|--------|
448
- | Initialize project | Skill({ skill: "maestro-init" }) set up project infrastructure |
449
- | Plan first phase | Skill({ skill: "maestro-plan", args: "1" }) plan first roadmap phase |
450
- | Create issues | Generate issues per phase via Skill({ skill: "manage-issue" }) |
451
- | Export only | Spec + roadmap complete, no further action |
452
-
453
- ### Step 12: Final Report
454
-
455
- ```
456
- == spec-generate complete ==
457
- Session: SPEC-{slug}-{date} | Quality: {score}% ({gate}) | Phases: {completed_count}/7
458
- Output: .workflow/.spec/{session_id}/
459
- spec-config.json, product-brief.md, requirements/, architecture/, epics/,
460
- readiness-report.md, spec-summary.md, roadmap.md
461
-
462
- Next: maestro-init (setup) | maestro-plan 1 (plan first phase)
463
- ```
464
-
465
- ---
466
-
467
- ## Key Design Principles
468
-
469
- 1. **Document Chain**: Each phase builds on previous outputs with traceability
470
- 2. **Multi-Perspective Analysis**: CLI tools provide product, technical, and user perspectives
471
- 3. **Interactive by Default**: Each phase offers user confirmation; `-y` enables auto mode
472
- 4. **Resumable Sessions**: spec-config.json tracks phases; `-c` resumes from checkpoint
473
- 5. **Template-Driven**: All documents from standardized templates with YAML frontmatter
474
- 6. **Spec Type Specialization**: Templates adapt to service/api/library/platform via profiles
475
- 7. **Terminology Consistency**: glossary.json from Phase 2 injected into all subsequent phases
476
- 8. **Iterative Quality**: Phase 6.5 auto-fix loop (max 2 iterations)
477
- 9. **Brainstorm Integration**: `--from-brainstorm` imports guidance-specification.md as seed
478
-
479
- ## State Management
480
-
481
- **spec-config.json**:
482
- ```json
483
- {
484
- "session_id": "SPEC-xxx-2026-03-15",
485
- "seed_input": "User input text",
486
- "input_type": "text|file|brainstorm",
487
- "timestamp": "ISO8601",
488
- "mode": "interactive|auto",
489
- "complexity": "simple|moderate|complex",
490
- "depth": "light|standard|comprehensive",
491
- "focus_areas": [],
492
- "spec_type": "service|api|library|platform",
493
- "iteration_count": 0,
494
- "iteration_history": [],
495
- "seed_analysis": {
496
- "problem_statement": "...",
497
- "target_users": [],
498
- "domain": "...",
499
- "constraints": [],
500
- "dimensions": []
501
- },
502
- "has_codebase": false,
503
- "phasesCompleted": [
504
- { "phase": 1, "name": "discovery", "output_file": "spec-config.json", "completed_at": "ISO8601" }
505
- ]
506
- }
507
- ```
508
-
509
- Resume: `-c` reads spec-config.json, resumes from first incomplete phase.
510
-
511
- ## Quality Dimensions (Phase 6)
512
-
513
- | Dimension | Weight | Focus |
514
- |-----------|--------|-------|
515
- | Completeness | 25% | All sections present with substance |
516
- | Consistency | 25% | Terminology, scope, non-goals alignment |
517
- | Traceability | 25% | Goals → Reqs → Arch → Epics chain |
518
- | Depth | 25% | Testable criteria, justified decisions, estimable stories |
519
-
520
- **Gate**: Pass (>=80%) / Review (60-79%) / Fail (<60%)
521
-
522
- ## Handoff to maestro-init
523
-
524
- When spec-generate completes, `roadmap.md` is already generated (Phase 7).
525
- Run `maestro-init` to set up project infrastructure (project.md, state.json, config.json, specs/).
526
- Init detects existing `.workflow/roadmap.md` and skips roadmap creation.
527
-
528
- ## Error Handling
529
-
530
- | Phase | Error | Blocking? | Action |
531
- |-------|-------|-----------|--------|
532
- | Phase 1 | Empty input | Yes | Error and exit |
533
- | Phase 1 | CLI analysis fails | No | Basic parsing fallback |
534
- | Phase 1.5 | Gap analysis fails | No | Skip to basic prompts |
535
- | Phase 2 | Single CLI fails | No | Continue with available |
536
- | Phase 3 | Gemini fails | No | Codex fallback |
537
- | Phase 4 | Review fails | No | Skip review |
538
- | Phase 5 | Story generation fails | No | Generate epics only |
539
- | Phase 6 | Validation fails | No | Partial report |
540
- | Phase 6.5 | Max iterations (2) | No | Force handoff |
541
-
542
- | Step 2.5 | External research fails | No | apiResearchContext = null, continue |
543
-
544
- CLI Fallback Chain: Gemini → Codex → Claude → degraded mode (local only)
1
+ # Workflow: Spec Generate (Full Mode)
2
+
3
+ Specification document chain producing a complete specification package (Product Brief, PRD, Architecture, Epics, Roadmap) through 7 sequential phases with multi-CLI analysis and interactive refinement. Pure documentation — no code generation.
4
+
5
+ **Shared logic**: `@roadmap-common.md` (worktree guard, context loading, codebase exploration, external research, minimum-phase principle, roadmap write logic)
6
+
7
+ ## Pipeline Position
8
+
9
+ ```
10
+ brainstorm (optional) → init (REQUIRED) → spec-generate → plan → execute → verify
11
+ Alternative light path: init → roadmap (light mode) → plan (skip spec-generate)
12
+ ```
13
+
14
+ ## Architecture
15
+
16
+ ```
17
+ P0: Spec Study → P1: Discovery → P1.5: Req Expansion → P2: Product Brief → P3: PRD → P4: Architecture → P5: Epics → P6: Readiness Check → P7: Roadmap
18
+
19
+ P6 gate: Pass (>=80%)P7 | Review (60-79%)P7 w/caveats | Fail (<60%)P6.5 Auto-Fix (max 2 iter)re-check
20
+ ```
21
+
22
+ ## Arguments
23
+
24
+ ```
25
+ $ARGUMENTS: "<idea or @file> [-y] [-c] [--from-brainstorm SESSION-ID]"
26
+
27
+ <idea> -- Idea text or @file reference
28
+ -y / --yes -- Auto mode, skip interactive questions
29
+ -c / --continue -- Resume from last checkpoint
30
+ --from-brainstorm -- Import brainstorm session as enriched seed
31
+ ```
32
+
33
+ ## Output Structure
34
+
35
+ ```
36
+ .workflow/.spec/SPEC-{slug}-{YYYY-MM-DD}/
37
+ ├── spec-config.json # Session configuration + phase state
38
+ ├── discovery-context.json # Codebase exploration (optional)
39
+ ├── refined-requirements.json # Phase 1.5: Confirmed requirements
40
+ ├── glossary.json # Phase 2: Terminology glossary
41
+ ├── product-brief.md # Phase 2: Product brief
42
+ ├── requirements/ # Phase 3: Detailed PRD
43
+ ├── _index.md # Summary, MoSCoW table, traceability
44
+ ├── REQ-NNN-{slug}.md # Functional requirement
45
+ └── NFR-{type}-NNN-{slug}.md # Non-functional requirement
46
+ ├── architecture/ # Phase 4: Architecture decisions
47
+ ├── _index.md # Overview, components, tech stack
48
+ │ └── ADR-NNN-{slug}.md # Architecture Decision Record
49
+ ├── epics/ # Phase 5: Epic/Story breakdown
50
+ ├── _index.md # Epic table, dependency map, MVP
51
+ │ └── EPIC-NNN-{slug}.md # Individual Epic with Stories
52
+ ├── readiness-report.md # Phase 6: Quality report
53
+ ├── spec-summary.md # Phase 6: Executive summary
54
+ └── roadmap.md # Phase 7: Project roadmap (also written to .workflow/roadmap.md)
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Process
60
+
61
+ ### Step 1: Prerequisite Loading (Phase 0)
62
+
63
+ Load specification and template documents:
64
+
65
+ | Document | Purpose | Priority |
66
+ |----------|---------|----------|
67
+ | Document standards | Format, frontmatter, naming conventions | P0 - must read |
68
+ | Quality gates | Per-phase quality criteria and scoring | P0 - must read |
69
+ | Templates | product-brief, requirements-prd, architecture-doc, epics-template | Read on-demand per phase |
70
+
71
+ **Load project specs and history**: Follow roadmap-common.md "Load Project Context".
72
+
73
+ Additional full-mode rules:
74
+ - Features in `already_shipped` are EXCLUDED from spec generation scope
75
+ - `lessons_learned` inform risk assessment in Phase 1 and architecture decisions in Phase 4
76
+ - Pass assembled `project_context` to Phase 1 seed analysis and Phase 7 roadmap generation
77
+
78
+ ### Step 2: Discovery & Seed Analysis (Phase 1)
79
+
80
+ Parse input, analyze the seed idea, optionally explore codebase, establish session.
81
+
82
+ **Step 2.1: Input Parsing**
83
+ - Parse $ARGUMENTS: extract idea/topic, flags (-y, -c, --from-brainstorm)
84
+ - If `-c`: read spec-config.json, resume from first incomplete phase
85
+ - If `--from-brainstorm SESSION-ID`:
86
+ - Locate brainstorm session directory
87
+ - Read `guidance-specification.md` as enriched seed
88
+ - Set `input_type: "brainstorm"` skip Phase 1.5
89
+ - If `@file`: read file content as seed
90
+ - If text: use directly as seed
91
+ - Missing input → error E001
92
+
93
+ **Step 2.2: Session Initialization**
94
+ ```
95
+ Session ID: SPEC-{slug}-{YYYY-MM-DD}
96
+ Output dir: .workflow/.spec/{session_id}/
97
+ ```
98
+
99
+ **Step 2.3: Seed Analysis via CLI**
100
+ - Spawn CLI analysis to extract: problem_statement, target_users, domain, constraints, dimensions (3-5)
101
+ - Assess complexity: simple (1-2 components) / moderate (3-5) / complex (6+)
102
+ - For brainstorm input: enrich with feature decomposition data
103
+
104
+ **Step 2.4: Codebase Exploration** follow roadmap-common.md
105
+ - Output: `discovery-context.json` with relevant_files, patterns, tech_stack
106
+
107
+ **Step 2.5: External Research** — follow roadmap-common.md
108
+
109
+ `apiResearchContext` is passed into:
110
+ - Step 4 (Product Brief): technology feasibility assessment
111
+ - Step 5 (Requirements): API-aware requirement writing with concrete constraints
112
+ - Step 6 (Architecture): informed ADR decisions with version-specific details
113
+ - Step 7 (Epics): realistic story sizing based on API complexity
114
+
115
+ **Step 2.6: Spec Type Selection**
116
+ - Interactive (AskUserQuestion): Service / API / Library / Platform
117
+ - `--yes`: default to "service"
118
+ - Each type loads a profile template for domain-specific sections
119
+
120
+ **Step 2.7: User Confirmation (interactive)**
121
+ - Confirm problem statement, select depth (Light/Standard/Comprehensive), select focus areas
122
+ - `--yes`: accept all defaults
123
+
124
+ **Output**: `spec-config.json`, `discovery-context.json` (optional), `apiResearchContext` (in-memory, optional)
125
+
126
+ ### Step 3: Requirement Expansion & Clarification (Phase 1.5)
127
+
128
+ Skip if `--from-brainstorm` (requirements already in guidance-specification.md).
129
+
130
+ **Step 3.1: CLI Gap Analysis**
131
+ - Analyze seed for completeness (score 1-10), identify missing dimensions
132
+ - Generate 3-5 clarification areas with questions and expansion suggestions
133
+ - Dimensions checked: functional scope, user scenarios, NFRs, integrations, data model, error handling
134
+
135
+ **Step 3.2: Interactive Discussion Loop (max 5 rounds)**
136
+ - Round 1: present gap analysis + expansion suggestions via AskUserQuestion
137
+ - Round N: CLI follow-up analysis based on user responses, refine requirements
138
+ - User can: answer questions, accept suggestions, or skip to generation
139
+ - `--yes`: CLI auto-expansion without interaction
140
+
141
+ **Step 3.3: User Confirmation**
142
+ - Present requirement summary, user confirms or requests adjustments
143
+ - `--yes`: auto-confirm
144
+
145
+ **Output**: `refined-requirements.json` (confirmed features, NFRs, boundaries, assumptions)
146
+
147
+ ### Step 4: Product Brief (Phase 2)
148
+
149
+ Generate product brief through multi-perspective CLI analysis.
150
+
151
+ **Step 4.1: Load Context**
152
+ - Read refined-requirements.json (preferred) or seed_analysis fallback
153
+ - Read discovery-context.json (if codebase detected)
154
+ - For brainstorm input: read guidance-specification.md sections
155
+
156
+ **Step 4.2: Multi-CLI Parallel Analysis (3 perspectives)**
157
+
158
+ | Perspective | Role | Focus |
159
+ |-------------|------|-------|
160
+ | Product | analyze | Vision, market fit, success criteria, scope boundaries |
161
+ | Technical | review | Feasibility, constraints, integration complexity, tech recommendations |
162
+ | User | explore | Personas, journey maps, pain points, UX criteria |
163
+
164
+ **Step 4.3: Synthesis**
165
+ - Extract convergent themes (all agree), conflicts (need resolution), unique insights
166
+ - For brainstorm input: cross-reference with guidance-specification decisions
167
+ - If `apiResearchContext` is set: inject API details into technical feasibility assessment
168
+
169
+ **Step 4.4: Interactive Refinement**
170
+ - Present synthesis, user adjusts scope/vision
171
+ - `--yes`: accept synthesis as-is
172
+
173
+ **Step 4.5: Generate Outputs**
174
+ - `product-brief.md` from template (YAML frontmatter + filled content)
175
+ - `glossary.json` — 5+ core terms extracted from product brief and CLI analysis
176
+ - Each term: canonical name, definition, aliases, category (core/technical/business)
177
+ - Injected into all subsequent phase CLI prompts for terminology consistency
178
+
179
+ **Output**: `product-brief.md`, `glossary.json`
180
+
181
+ ### Step 5: Requirements / PRD (Phase 3)
182
+
183
+ Generate detailed PRD with functional/non-functional requirements.
184
+
185
+ **Step 5.1: Requirement Expansion via CLI**
186
+ - For each product brief goal, generate 3-7 functional requirements
187
+ - Each requirement: REQ-NNN ID, title, description, user story, 2-4 acceptance criteria
188
+ - Generate non-functional requirements: performance, security, scalability, usability
189
+ - Apply RFC 2119 keywords (MUST/SHOULD/MAY) to all behavioral constraints
190
+ - Define core entity data models: fields, types, constraints, relationships
191
+ - Inject glossary.json for terminology consistency
192
+
193
+ **Step 5.2: MoSCoW Priority Sorting (interactive)**
194
+ - Present requirements grouped by initial priority
195
+ - User adjusts Must/Should/Could/Won't labels
196
+ - Select MVP scope: Must-only / Must+key Should / Comprehensive
197
+ - `--yes`: accept CLI-suggested priorities
198
+
199
+ **Step 5.3: Generate Directory**
200
+ - `requirements/_index.md` — summary table, MoSCoW breakdown, traceability matrix
201
+ - `requirements/REQ-NNN-{slug}.md` one per functional requirement
202
+ - `requirements/NFR-{type}-NNN-{slug}.md` one per non-functional requirement
203
+
204
+ **Output**: `requirements/` directory (index + individual files)
205
+
206
+ ### Step 6: Architecture (Phase 4)
207
+
208
+ Generate architecture decisions, component design, and technology selections.
209
+
210
+ **Step 6.1: Architecture Analysis via CLI (role: review)**
211
+ - System architecture style with justification
212
+ - Core components and responsibilities
213
+ - Component interaction diagram (Mermaid graph TD)
214
+ - Technology stack: languages, frameworks, databases, infrastructure
215
+ - 2-4 Architecture Decision Records (ADRs): context, decision, alternatives, consequences
216
+ - Data model: entities and relationships (Mermaid erDiagram)
217
+ - Security architecture: auth, authorization, data protection
218
+ - **State machine**: ASCII diagram + transition table for lifecycle entities (service/platform type)
219
+ - **Configuration model**: all configurable fields with type, default, constraint
220
+ - **Error handling strategy**: per-component classification (transient/permanent/degraded), recovery mechanisms
221
+ - **Observability**: key metrics (5+), structured log events, health checks
222
+ - Spec type profile injection for domain-specific depth
223
+ - Glossary injection for terminology consistency
224
+ - If `apiResearchContext` is set: inject as "External API Research" context
225
+
226
+ **Step 6.2: Architecture Review via CLI (role: review)**
227
+ - Challenge each ADR, identify scalability bottlenecks
228
+ - Assess security gaps, evaluate technology choices
229
+ - Rate overall quality 1-5
230
+
231
+ **Step 6.3: Interactive ADR Decisions**
232
+ - Present ADRs with review feedback, user decides: accept / incorporate feedback / simplify
233
+ - `--yes`: auto-accept
234
+
235
+ **Step 6.4: Codebase Integration Mapping (conditional)**
236
+ - Map new components to existing code modules
237
+
238
+ **Step 6.5: Generate Directory**
239
+ - `architecture/_index.md` — overview, component diagram, tech stack, data model, security
240
+ - `architecture/ADR-NNN-{slug}.md` one per Architecture Decision Record
241
+
242
+ **Output**: `architecture/` directory (index + individual ADR files)
243
+
244
+ ### Step 7: Epics & Stories (Phase 5)
245
+
246
+ Decompose specification into executable Epics and Stories.
247
+
248
+ **Step 7.1: Epic Decomposition via CLI**
249
+ - Group requirements into logical Epics (EPIC-NNN IDs). Epic count is unconstrained — Phase 7 will merge Epics into minimal phases via the minimum-phase principle.
250
+ - Tag MVP subset
251
+ - For each Epic: 2-5 Stories in "As a...I want...So that..." format
252
+ - Each Story: 2-4 testable acceptance criteria, relative size (S/M/L/XL), trace to REQ-NNN
253
+ - Cross-Epic dependency map (Mermaid graph LR)
254
+ - Recommended execution order with rationale
255
+ - MVP definition of done (3-5 criteria)
256
+
257
+ **Epic sizing awareness** (informs Phase 7 roadmap generation):
258
+ - Epics that are too small (1-2 Stories, all size S) should be flagged for merge in Phase 7
259
+ - Each Epic should carry enough substance to become part of a phase with 5+ tasks
260
+ - Prefer fewer, larger Epics over many tiny ones
261
+
262
+ **Step 7.2: Interactive Validation**
263
+ - Present Epic overview, user adjusts: merge/split epics, adjust MVP scope
264
+ - `--yes`: accept as-is
265
+
266
+ **Step 7.3: Generate Directory**
267
+ - `epics/_index.md` overview table, dependency map, MVP scope, execution order, traceability
268
+ - `epics/EPIC-NNN-{slug}.md` one per Epic with embedded Stories
269
+
270
+ **Output**: `epics/` directory (index + individual Epic files)
271
+
272
+ ### Step 8: Readiness Check & Handoff (Phase 6)
273
+
274
+ Validate specification package and provide execution handoff.
275
+
276
+ **Step 8.1: Cross-Document Validation via CLI**
277
+ Score on 4 dimensions (25% each):
278
+ 1. **Completeness**: all required sections present with substantive content
279
+ 2. **Consistency**: terminology uniform (glossary compliance), scope containment, non-goals respected
280
+ 3. **Traceability**: goals requirements architecture → epics (matrix generated)
281
+ 4. **Depth**: acceptance criteria testable, ADRs justified, stories estimable
282
+
283
+ Gate decision: Pass (>=80) / Review (60-79) / Fail (<60)
284
+
285
+ **Step 8.2: Generate Reports**
286
+ - `readiness-report.md` quality scores, issue list (Error/Warning/Info), traceability matrix
287
+ - `spec-summary.md` one-page executive summary
288
+
289
+ **Step 8.3: Update Document Status**
290
+ - All document frontmatter updated to `status: complete`
291
+
292
+ **Step 8.4: Gate Routing**
293
+
294
+ | Gate Result | Action |
295
+ |-------------|--------|
296
+ | Pass (>=80%) | Proceed to Step 11 (Phase 7: Roadmap) |
297
+ | Review (60-79%) | Proceed to Step 11 with caveats logged |
298
+ | Fail (<60%) | Trigger Step 9 (Auto-Fix), then re-run Step 8 |
299
+
300
+ ### Step 9: Auto-Fix (Phase 6.5, conditional)
301
+
302
+ Triggered when Phase 6 score < 60%.
303
+
304
+ **Step 9.1: Parse Readiness Report**
305
+ - Extract Error and Warning items, group by originating phase (2-5), map to affected files
306
+
307
+ **Step 9.2: Fix Affected Phases (sequential, Phase 2→3→4→5)**
308
+ - Read current phase output
309
+ - CLI re-generation with error context injected
310
+ - Inject glossary for terminology consistency
311
+ - Preserve unflagged content, only fix flagged issues
312
+ - Increment document version
313
+
314
+ **Step 9.3: Re-run Phase 6**
315
+ - Generate new readiness-report.md
316
+ - If still Fail and iteration_count < 2: loop back
317
+ - If Pass or max iterations (2) reached: proceed to handoff
318
+
319
+ **Output**: Updated Phase 2-5 documents, updated spec-config.json with iteration tracking
320
+
321
+ ### Step 11: Roadmap Generation (Phase 7)
322
+
323
+ Convert Epics into an interactive roadmap with user confirmation.
324
+
325
+ **Step 11.1: Epic→Phase Mapping**
326
+ - Read `epics/_index.md` for Epic table, dependency map, MVP tags
327
+ - Read individual `EPIC-NNN-{slug}.md` for Stories and acceptance criteria
328
+ - Read `architecture/_index.md` for technical constraints (ADR decisions)
329
+
330
+ Apply **Minimum-Phase Principle** from roadmap-common.md for Epic→Phase mapping:
331
+ - Default: ALL Epics → 1 Phase (wave DAG orders tasks by Epic dependencies)
332
+ - Only split if hard dependency conditions are all met
333
+ - MVP-tagged Epics → Milestone 1, Post-MVP → Milestone 2+
334
+ - Small Epics (1-2 Stories, all size S) MUST be merged
335
+ - Epic dependencies → wave ordering within phase (not phase splits)
336
+ - Stories within Epics → phase success criteria
337
+ - ADR decisions phase technical constraints
338
+
339
+ **Step 11.2: Generate Draft Roadmap**
340
+ Follow roadmap-common.md **Roadmap Template** format. For full mode, populate from product-brief.md vision and Epic→Stories acceptance criteria.
341
+
342
+ **Step 11.3: Interactive Refinement (max 3 rounds)**
343
+ - Present roadmap overview: phase count, milestone structure, dependency graph
344
+ - **Before presenting**: validate minimum-phase principle. Auto-merge violations and inform user.
345
+ - User feedback via AskUserQuestion:
346
+ - **Approve**: Run final sizing check before accepting
347
+ - **Adjust Scope**: Move Epics between milestones, merge phases
348
+ - **Reorder**: Change phase sequencing
349
+ - **Split/Merge**: Combine small phases (min 5 tasks enforced); splits require hard-dependency justification
350
+ - `--yes`: auto-approve (minimum-phase principle still enforced automatically)
351
+
352
+ **Step 11.4: Write Outputs**
353
+ - Write `roadmap.md` to spec directory: `{spec_dir}/roadmap.md`
354
+ - Write `.workflow/roadmap.md` follow roadmap-common.md **Overwrite vs Edit Rules**
355
+ - Update `spec-config.json`: add Phase 7 completion
356
+ - Update `state.json` follow roadmap-common.md **state.json Update Rules**
357
+
358
+ **Step 11.5: Handoff Options (AskUserQuestion)**
359
+
360
+ | Option | Action |
361
+ |--------|--------|
362
+ | Initialize project | Skill({ skill: "maestro-init" }) |
363
+ | Plan first phase | Skill({ skill: "maestro-plan", args: "1" }) |
364
+ | Create issues | Generate issues per phase via Skill({ skill: "manage-issue" }) |
365
+ | Export only | Spec + roadmap complete, no further action |
366
+
367
+ ### Step 12: Final Report
368
+
369
+ ```
370
+ == spec-generate complete ==
371
+ Session: SPEC-{slug}-{date} | Quality: {score}% ({gate}) | Phases: {completed_count}/7
372
+ Output: .workflow/.spec/{session_id}/
373
+ spec-config.json, product-brief.md, requirements/, architecture/, epics/,
374
+ readiness-report.md, spec-summary.md, roadmap.md
375
+
376
+ Next: maestro-init (setup) | maestro-plan 1 (plan first phase)
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Key Design Principles
382
+
383
+ 1. **Document Chain**: Each phase builds on previous outputs with traceability
384
+ 2. **Multi-Perspective Analysis**: CLI tools provide product, technical, and user perspectives
385
+ 3. **Interactive by Default**: Each phase offers user confirmation; `-y` enables auto mode
386
+ 4. **Resumable Sessions**: spec-config.json tracks phases; `-c` resumes from checkpoint
387
+ 5. **Template-Driven**: All documents from standardized templates with YAML frontmatter
388
+ 6. **Spec Type Specialization**: Templates adapt to service/api/library/platform via profiles
389
+ 7. **Terminology Consistency**: glossary.json from Phase 2 injected into all subsequent phases
390
+ 8. **Iterative Quality**: Phase 6.5 auto-fix loop (max 2 iterations)
391
+ 9. **Brainstorm Integration**: `--from-brainstorm` imports guidance-specification.md as seed
392
+
393
+ ## State Management
394
+
395
+ **spec-config.json**:
396
+ ```json
397
+ {
398
+ "session_id": "SPEC-xxx-2026-03-15",
399
+ "seed_input": "User input text",
400
+ "input_type": "text|file|brainstorm",
401
+ "timestamp": "ISO8601",
402
+ "mode": "interactive|auto",
403
+ "complexity": "simple|moderate|complex",
404
+ "depth": "light|standard|comprehensive",
405
+ "focus_areas": [],
406
+ "spec_type": "service|api|library|platform",
407
+ "iteration_count": 0,
408
+ "iteration_history": [],
409
+ "seed_analysis": {
410
+ "problem_statement": "...",
411
+ "target_users": [],
412
+ "domain": "...",
413
+ "constraints": [],
414
+ "dimensions": []
415
+ },
416
+ "has_codebase": false,
417
+ "phasesCompleted": [
418
+ { "phase": 1, "name": "discovery", "output_file": "spec-config.json", "completed_at": "ISO8601" }
419
+ ]
420
+ }
421
+ ```
422
+
423
+ Resume: `-c` reads spec-config.json, resumes from first incomplete phase.
424
+
425
+ ## Quality Dimensions (Phase 6)
426
+
427
+ | Dimension | Weight | Focus |
428
+ |-----------|--------|-------|
429
+ | Completeness | 25% | All sections present with substance |
430
+ | Consistency | 25% | Terminology, scope, non-goals alignment |
431
+ | Traceability | 25% | Goals → Reqs → Arch → Epics chain |
432
+ | Depth | 25% | Testable criteria, justified decisions, estimable stories |
433
+
434
+ **Gate**: Pass (>=80%) / Review (60-79%) / Fail (<60%)
435
+
436
+ ## Handoff to maestro-init
437
+
438
+ When spec-generate completes, `roadmap.md` is already generated (Phase 7).
439
+ Run `maestro-init` to set up project infrastructure (project.md, state.json, config.json, specs/).
440
+ Init detects existing `.workflow/roadmap.md` and skips roadmap creation.
441
+
442
+ ## Error Handling
443
+
444
+ | Phase | Error | Blocking? | Action |
445
+ |-------|-------|-----------|--------|
446
+ | Phase 1 | Empty input | Yes | Error and exit |
447
+ | Phase 1 | CLI analysis fails | No | Basic parsing fallback |
448
+ | Phase 1.5 | Gap analysis fails | No | Skip to basic prompts |
449
+ | Phase 2 | Single CLI fails | No | Continue with available |
450
+ | Phase 3 | Gemini fails | No | Codex fallback |
451
+ | Phase 4 | Review fails | No | Skip review |
452
+ | Phase 5 | Story generation fails | No | Generate epics only |
453
+ | Phase 6 | Validation fails | No | Partial report |
454
+ | Phase 6.5 | Max iterations (2) | No | Force handoff |
455
+ | Step 2.5 | External research fails | No | apiResearchContext = null, continue |
456
+
457
+ CLI Fallback Chain: Role-based resolution degraded mode (local only)