specdacular 0.5.1 → 0.5.2

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/README.md CHANGED
@@ -30,7 +30,7 @@ A structured flow for planning features with enough detail for agent implementat
30
30
  ```
31
31
  feature:new -> feature:discuss -> feature:research -> feature:plan (roadmap) ->
32
32
  [for each phase]
33
- phase:prepare? -> phase:plan -> phase:execute
33
+ phase:prepare? -> phase:plan -> phase:execute -> phase:review?
34
34
  phase:insert? -> phase:renumber? <- mid-flight adjustments
35
35
  ```
36
36
 
@@ -86,6 +86,7 @@ Work with individual phases — prepare, plan, and execute one at a time.
86
86
  | `/specd:phase:research [feature] [phase]` | Research patterns for a phase (standalone) |
87
87
  | `/specd:phase:plan [feature] [phase]` | Create detailed PLAN.md files for one phase |
88
88
  | `/specd:phase:execute [feature]` | Execute plans with progress tracking |
89
+ | `/specd:phase:review [feature] [phase]` | Review executed plans against actual code |
89
90
  | `/specd:phase:insert [feature] [after] [desc]` | Insert a new phase after an existing one |
90
91
  | `/specd:phase:renumber [feature]` | Renumber phases to clean integer sequence |
91
92
 
@@ -93,6 +94,7 @@ Work with individual phases — prepare, plan, and execute one at a time.
93
94
 
94
95
  | Command | Description |
95
96
  |---------|-------------|
97
+ | `/specd:status [--all]` | Show feature status dashboard |
96
98
  | `/specd:blueprint [name] [sub]` | Generate visual blueprint (wireframes, diagrams) |
97
99
  | `/specd:help` | Show available commands |
98
100
  | `/specd:update` | Update to latest version |
@@ -142,6 +144,7 @@ Creates `ROADMAP.md` with phases derived from dependency analysis (types -> API
142
144
  /specd:phase:prepare user-dashboard 1 # Discuss phase gray areas + optional research
143
145
  /specd:phase:plan user-dashboard 1 # Create detailed PLAN.md files
144
146
  /specd:phase:execute user-dashboard # Execute with progress tracking
147
+ /specd:phase:review user-dashboard 1 # Review phase against actual code
145
148
  ```
146
149
 
147
150
  Repeat for each phase. Plans are created just-in-time so they stay fresh.
@@ -206,6 +209,13 @@ Plans are created just-in-time — right before execution — so they incorporat
206
209
  - Commits after each task
207
210
  - Progress tracking in `STATE.md`
208
211
 
212
+ **`phase:review`** reviews executed plans against actual code:
213
+ - Claude inspects each plan's `creates`/`modifies` against actual files
214
+ - Per-plan status table with ✅/⚠️/❌/⏸️ icons
215
+ - User conversation captures additional issues
216
+ - Generates corrective plans if needed (fed back into `phase:execute`)
217
+ - Review cycle tracked in `STATE.md`
218
+
209
219
  **`phase:insert`** adds a new phase using decimal numbering (e.g., Phase 3.1 after Phase 3). The `(INSERTED)` marker in `ROADMAP.md` identifies mid-flight additions.
210
220
 
211
221
  **`phase:renumber`** cleans up decimal phases to sequential integers after insertions stabilize.
@@ -271,6 +281,12 @@ Specdacular spawns specialized agents that run simultaneously:
271
281
  │ │ phase: │ │
272
282
  │ │ execute │ │
273
283
  │ └──────────┘ │
284
+ │ │ │
285
+ │ ▼ │
286
+ │ ┌──────────┐ │
287
+ │ │ phase: │ │
288
+ │ │ review │ │
289
+ │ └──────────┘ │
274
290
  │ │
275
291
  │ Mid-flight adjustments: │
276
292
  │ ┌──────────┐ │
@@ -39,6 +39,7 @@ Display available specdacular commands and usage guidance.
39
39
  | `/specd:phase:research [feature] [phase]` | Research patterns for a phase (standalone) |
40
40
  | `/specd:phase:plan [feature] [phase]` | Create detailed PLAN.md files for one phase |
41
41
  | `/specd:phase:execute [feature] [plan]` | Execute a plan with progress tracking |
42
+ | `/specd:phase:review [feature] [phase]` | Review executed plans against actual code |
42
43
  | `/specd:phase:insert [feature] [after] [desc]` | Insert a new phase after an existing one |
43
44
  | `/specd:phase:renumber [feature]` | Renumber phases to clean integer sequence |
44
45
 
@@ -60,7 +61,7 @@ The feature flow helps you plan features specific enough that an agent can imple
60
61
  ```
61
62
  feature:new -> feature:discuss -> feature:research -> feature:plan (roadmap) ->
62
63
  [for each phase]
63
- phase:prepare? -> phase:plan -> phase:execute
64
+ phase:prepare? -> phase:plan -> phase:execute -> phase:review?
64
65
  phase:insert? -> phase:renumber? <- mid-flight adjustments
65
66
  ```
66
67
 
@@ -72,6 +73,7 @@ feature:new -> feature:discuss -> feature:research -> feature:plan (roadmap) ->
72
73
  - `phase:prepare` — Discuss gray areas + optionally research (per phase)
73
74
  - `phase:plan` — Create detailed PLAN.md files for one phase
74
75
  - `phase:execute` — Execute plans with progress tracking
76
+ - `phase:review` — Review executed plans, generate corrective plans if needed
75
77
  - `phase:insert` — Insert a new phase mid-flight with decimal numbering (e.g., Phase 3.1)
76
78
  - `phase:renumber` — Clean up decimal phases to sequential integers
77
79
 
@@ -102,6 +104,7 @@ Then for each phase:
102
104
  /specd:phase:prepare user-dashboard 1 # Discuss + optionally research
103
105
  /specd:phase:plan user-dashboard 1 # Create detailed plans
104
106
  /specd:phase:execute user-dashboard # Execute with progress tracking
107
+ /specd:phase:review user-dashboard 1 # Review phase against actual code
105
108
  ```
106
109
 
107
110
  ---
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: specd:phase:review
3
+ description: Review executed plans against actual code and identify deviations
4
+ argument-hint: "[feature-name] [phase-number]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - AskUserQuestion
13
+ ---
14
+
15
+ <objective>
16
+ Review executed plans for a phase, comparing intended changes against actual code. Surfaces deviations, captures decisions, and generates corrective plans when needed.
17
+
18
+ **What it does:**
19
+ 1. Load context — STATE.md, plans, DECISIONS.md, codebase docs
20
+ 2. Filter plans — Only review plans with status Complete (DEC-006)
21
+ 3. Inspect each plan — Compare creates/modifies frontmatter against actual files
22
+ 4. Present findings — Per-plan status table with expandable details (DEC-005)
23
+ 5. Gather user input — Ask about satisfaction, additional issues (DEC-001)
24
+ 6. Record decisions — New decisions to DECISIONS.md
25
+ 7. Generate correctives — Corrective plans if issues found (DEC-003)
26
+ 8. Update state — Review Cycles in STATE.md (DEC-004)
27
+ 9. Commit and suggest next steps
28
+ </objective>
29
+
30
+ <execution_context>
31
+ @~/.claude/specdacular/workflows/review-phase.md
32
+ </execution_context>
33
+
34
+ <context>
35
+ Feature name: $ARGUMENTS (first argument)
36
+ Phase number: $ARGUMENTS (second argument)
37
+
38
+ **Load ALL feature context:**
39
+ @.specd/features/{name}/STATE.md — Progress tracking, completed plans
40
+ @.specd/features/{name}/DECISIONS.md — Existing decisions
41
+ @.specd/features/{name}/RESEARCH.md — Implementation notes (if exists)
42
+ @.specd/features/{name}/ROADMAP.md — Phase overview
43
+ @.specd/features/{name}/CHANGELOG.md — Existing deviations (if exists)
44
+
45
+ **Load plan files for the phase:**
46
+ @.specd/features/{name}/plans/phase-{NN}/*.md — All plan files
47
+
48
+ **Load codebase context:**
49
+ @.specd/codebase/PATTERNS.md — Code patterns
50
+ @.specd/codebase/STRUCTURE.md — File locations
51
+ @.specd/codebase/MAP.md — System overview
52
+ </context>
53
+
54
+ <process>
55
+ 1. **Validate** — Feature exists, phase exists, has execution history
56
+ 2. **Load Context** — Read all feature, plan, and codebase docs
57
+ 3. **Filter Plans** — Get only completed plans for this phase
58
+ 4. **Inspect Phase** — Compare each plan's intent against actual code
59
+ 5. **Present Findings** — Per-plan status table + deviation details
60
+ 6. **Gather User Input** — Ask about satisfaction, additional issues
61
+ 7. **Record Decisions** — Save new decisions to DECISIONS.md
62
+ 8. **Generate Correctives** — Create corrective plans if needed
63
+ 9. **Update State** — Update Review Cycles section in STATE.md
64
+ 10. **Update Changelog** — Log deviations to CHANGELOG.md
65
+ 11. **Commit and Next** — Commit changes, suggest next steps
66
+ </process>
67
+
68
+ <success_criteria>
69
+ - [ ] Feature and phase validated with execution history
70
+ - [ ] All completed plans inspected against actual code
71
+ - [ ] Per-plan status table displayed (✅/⚠️/❌/⏸️)
72
+ - [ ] Deviations surfaced with planned vs actual comparison
73
+ - [ ] User input captured (satisfaction, additional issues)
74
+ - [ ] New decisions recorded in DECISIONS.md
75
+ - [ ] Corrective plans generated if issues identified
76
+ - [ ] Review Cycles section updated in STATE.md
77
+ - [ ] Deviations logged in CHANGELOG.md
78
+ - [ ] Changes committed
79
+ - [ ] Next steps suggested
80
+ </success_criteria>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specdacular",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Feature planning system for existing codebases. Map, understand, and plan features in large projects.",
5
5
  "bin": {
6
6
  "specdacular": "bin/install.js"
@@ -41,6 +41,13 @@
41
41
 
42
42
  ---
43
43
 
44
+ ## Review Cycles
45
+
46
+ | Phase | Cycle | Date | Findings | Corrective Plans | Status |
47
+ |-------|-------|------|----------|------------------|--------|
48
+
49
+ ---
50
+
44
51
  ## Discussion Sessions
45
52
 
46
53
  | Date | Focus | Outcome |
@@ -81,6 +88,7 @@
81
88
  - `/specd:phase:prepare {feature-name} {N}` — Prepare a specific phase
82
89
  - `/specd:phase:plan {feature-name} {N}` — Create detailed plans for a phase
83
90
  - `/specd:phase:execute {feature-name}` — Execute plans with progress tracking
91
+ - `/specd:phase:review {feature-name} {N}` — Review executed plans against actual code
84
92
 
85
93
  ---
86
94
 
@@ -0,0 +1,555 @@
1
+ <purpose>
2
+ Review executed plans for a phase by comparing intended changes against actual code.
3
+ Surfaces deviations, captures user feedback, records decisions, and generates corrective plans.
4
+
5
+ **Key principles:**
6
+ - Inspect semantically, not literally — did the code achieve what the plan intended?
7
+ - Claude inspects first, then asks the user (DEC-001)
8
+ - Support partial review — only inspect completed plans (DEC-006)
9
+ - Progressive disclosure — summary, then details, then conversation (DEC-005)
10
+
11
+ **Output:** Review findings, updated STATE.md (Review Cycles), CHANGELOG.md entries, corrective plans (if needed)
12
+ </purpose>
13
+
14
+ <philosophy>
15
+
16
+ ## Semantic Review, Not Literal Diff
17
+
18
+ Plans describe intent. Code implements intent. The review checks whether intent was fulfilled,
19
+ not whether every word matches. A plan saying "create user service" that results in `users.service.ts`
20
+ instead of `user-service.ts` is a match, not a deviation.
21
+
22
+ Use plan `creates`/`modifies` frontmatter for file-level verification.
23
+ Use Claude's understanding for intent-level verification.
24
+
25
+ ## Deviations Are Neutral
26
+
27
+ A deviation means code differs from the plan. It might be an improvement, a mistake, or an
28
+ intentional change. The review surfaces it; the user decides if it matters.
29
+
30
+ ## Corrective Plans Fix Gaps, Not Add Features
31
+
32
+ When generating corrective plans, scope them to what the original plan intended but didn't achieve.
33
+ Don't use review as a backdoor to add features or refactor code.
34
+
35
+ ## Iteration Has Limits
36
+
37
+ Max 3 review cycles per phase. If findings increase between cycles, stop and discuss.
38
+ Show progress: "Cycle 2/3: 2 issues (down from 5)".
39
+
40
+ </philosophy>
41
+
42
+ <process>
43
+
44
+ <step name="validate">
45
+ Validate feature exists, phase exists, and has execution history.
46
+
47
+ **Check feature:**
48
+ - `.specd/features/{feature}` directory exists
49
+ - `STATE.md`, `DECISIONS.md`, `ROADMAP.md` exist
50
+
51
+ **Check phase:**
52
+ - Phase {N} exists in ROADMAP.md
53
+ - `.specd/features/{feature}/plans/phase-{NN}/` directory exists
54
+ - At least one plan file exists in the phase directory
55
+
56
+ **Check execution:**
57
+ - STATE.md has at least one plan from this phase in the Completed Plans table
58
+ - If no completed plans: show error and suggest running `/specd:phase:execute` first
59
+
60
+ **Check git state:**
61
+ - Warn if uncommitted changes exist (review may not reflect actual state)
62
+
63
+ **If feature not found:**
64
+ ```
65
+ Feature '{name}' not found.
66
+
67
+ Run /specd:feature:new {name} to create it.
68
+ ```
69
+
70
+ **If no executed plans:**
71
+ ```
72
+ No executed plans found for {feature} phase {N}.
73
+
74
+ Run /specd:phase:execute {feature} to execute plans first.
75
+ ```
76
+
77
+ Continue to load_context.
78
+ </step>
79
+
80
+ <step name="load_context">
81
+ Load ALL context needed for review.
82
+
83
+ **Read feature context:**
84
+ - `config.json` — Feature settings
85
+ - `STATE.md` — Current progress, completed plans, existing review cycles
86
+ - `DECISIONS.md` — Active decisions to be aware of
87
+ - `RESEARCH.md` — Implementation notes, pitfalls (if exists)
88
+ - `ROADMAP.md` — Phase overview, success criteria
89
+ - `CHANGELOG.md` — Existing logged deviations (if exists, to avoid duplicates)
90
+
91
+ **Read phase context:**
92
+ - `plans/phase-{NN}/CONTEXT.md` — Phase-specific discussion resolutions (if exists)
93
+ - `plans/phase-{NN}/RESEARCH.md` — Phase-specific research findings (if exists)
94
+
95
+ **Read ALL plan files for this phase:**
96
+ - `plans/phase-{NN}/*-PLAN.md` — Every plan file, including any corrective plans
97
+ - Parse YAML frontmatter: `creates`, `modifies`, `corrects`, `depends_on`
98
+ - Parse plan objectives and task descriptions
99
+
100
+ **Read codebase context (if available):**
101
+ - `PATTERNS.md` — Code patterns to follow
102
+ - `STRUCTURE.md` — Where files go
103
+ - `MAP.md` — System overview
104
+
105
+ **Internalize:**
106
+ - Which plans are complete vs pending (from STATE.md Completed Plans table)
107
+ - What files each plan was supposed to create or modify
108
+ - Phase success criteria from ROADMAP.md
109
+ - Existing review cycles (to determine cycle number)
110
+ - Existing CHANGELOG.md entries (to avoid duplicate logging)
111
+
112
+ Continue to filter_plans.
113
+ </step>
114
+
115
+ <step name="filter_plans">
116
+ Separate completed and pending plans for this phase (DEC-006).
117
+
118
+ **From STATE.md Completed Plans table:**
119
+ 1. Identify plans from this phase with status "Complete"
120
+ 2. These are the plans to inspect
121
+
122
+ **Remaining plans:**
123
+ - Plans without a completion entry are "pending" (not yet executed)
124
+ - Show as ⏸️ in the status table but don't inspect
125
+
126
+ **Build plan list:**
127
+ For each completed plan, collect:
128
+ - Plan path (e.g., `phase-01/01-PLAN.md`)
129
+ - Plan title
130
+ - `creates` list from frontmatter
131
+ - `modifies` list from frontmatter
132
+ - `corrects` list from frontmatter (if corrective plan)
133
+ - Completion date from STATE.md
134
+
135
+ **If corrective plans exist (have `corrects` frontmatter):**
136
+ - Note which original plans they correct
137
+ - Inspection of corrective plans follows the same process
138
+
139
+ Continue to inspect_phase.
140
+ </step>
141
+
142
+ <step name="inspect_phase">
143
+ For each completed plan, compare intended changes against actual code.
144
+
145
+ **For each completed plan:**
146
+
147
+ ### 1. File-level verification
148
+ For each file in `creates`:
149
+ - Check if file exists on disk
150
+ - If missing: mark ❌ Incomplete
151
+
152
+ For each file in `modifies`:
153
+ - Check if file exists on disk
154
+ - If missing: mark ❌ Incomplete (file may have been deleted)
155
+
156
+ ### 2. Intent-level verification
157
+ For each file that exists:
158
+ - Read the file content
159
+ - Read the plan's task descriptions for that file
160
+ - Compare semantically: did the code achieve what the plan described?
161
+ - Consider:
162
+ - Does the file fulfill the plan's stated objective?
163
+ - Are the key structures/patterns the plan specified present?
164
+ - Are there significant omissions vs what the plan described?
165
+
166
+ ### 3. Classify each plan
167
+ Assign a status based on findings:
168
+
169
+ | Status | Icon | Criteria |
170
+ |--------|------|----------|
171
+ | Match | ✅ | All files exist, intent fulfilled, no significant deviations |
172
+ | Deviation | ⚠️ | Files exist and work, but implementation differs from plan |
173
+ | Incomplete | ❌ | Missing files, or plan objectives clearly not met |
174
+ | Not executed | ⏸️ | Plan not in Completed Plans table (pending) |
175
+
176
+ ### 4. Collect deviation details
177
+ For each deviation (⚠️) or incomplete (❌):
178
+ - **Plan reference:** Which plan, which task
179
+ - **Planned:** What the plan specified
180
+ - **Actual:** What was actually implemented (or what's missing)
181
+ - **Files:** Affected file paths
182
+ - **Impact:** Low (cosmetic/naming), Medium (behavioral), High (missing functionality)
183
+
184
+ ### 5. Check phase success criteria
185
+ Read phase success criteria from ROADMAP.md.
186
+ For each criterion, assess if it's been met by the executed plans.
187
+ Flag unmet criteria as additional findings.
188
+
189
+ Continue to present_findings.
190
+ </step>
191
+
192
+ <step name="present_findings">
193
+ Present review findings using progressive disclosure (DEC-005).
194
+
195
+ **Display review header:**
196
+ ```
197
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
198
+ PHASE REVIEW
199
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
200
+
201
+ **Feature:** {feature-name}
202
+ **Phase:** {N} — {phase title}
203
+ **Review Cycle:** {cycle number}
204
+ **Plans reviewed:** {completed count} of {total count}
205
+ ```
206
+
207
+ **1. Summary line:**
208
+ ```
209
+ Summary: {N} ✅ | {N} ⚠️ | {N} ❌ | {N} ⏸️
210
+ ```
211
+
212
+ **2. Per-plan status table:**
213
+ ```
214
+ | Plan | Title | Status | Files |
215
+ |------|-------|--------|-------|
216
+ | 01 | {title} | ✅ Match | {N} files checked |
217
+ | 02 | {title} | ⚠️ Deviation | {N} of {M} files match |
218
+ | 03 | {title} | ❌ Incomplete | {N} files missing |
219
+ | 04 | {title} | ⏸️ Not executed | — |
220
+ ```
221
+
222
+ **3. Expanded details (only for ⚠️ and ❌):**
223
+
224
+ For each plan with deviations or incomplete status:
225
+ ```
226
+ ───────────────────────────────────────────────────────
227
+ Plan {NN}: {Title} — {⚠️ Deviation | ❌ Incomplete}
228
+ ───────────────────────────────────────────────────────
229
+
230
+ **Finding 1: {Short description}**
231
+ - **Planned:** {What the plan specified}
232
+ - **Actual:** {What was implemented or what's missing}
233
+ - **Files:** `{file paths}`
234
+ - **Impact:** {Low | Medium | High}
235
+
236
+ **Finding 2: {Short description}**
237
+ ...
238
+ ```
239
+
240
+ **4. Phase success criteria check:**
241
+ ```
242
+ Phase Success Criteria:
243
+ - [x] {Met criterion}
244
+ - [ ] {Unmet criterion} — {brief explanation}
245
+ ```
246
+
247
+ **If all clean (no ⚠️ or ❌):**
248
+ ```
249
+ All executed plans match their intended implementation. Phase {N} is clean.
250
+ ```
251
+
252
+ Continue to gather_user_input.
253
+ </step>
254
+
255
+ <step name="gather_user_input">
256
+ Ask the user for feedback on the review findings (DEC-001).
257
+
258
+ **If findings exist (⚠️ or ❌):**
259
+
260
+ Use AskUserQuestion:
261
+ - header: "Review"
262
+ - question: "How would you like to handle these findings?"
263
+ - options:
264
+ - "Generate corrective plans" — Create corrective plans for all issues
265
+ - "Discuss findings" — Talk through each finding before deciding
266
+ - "Accept all deviations" — Mark all deviations as intentional, phase is clean
267
+ - "Accept some, fix others" — Go through findings one by one
268
+
269
+ **If "Discuss findings" or "Accept some, fix others":**
270
+ For each finding, ask:
271
+ - header: "Finding"
272
+ - question: "{Finding description} — how to handle?"
273
+ - options:
274
+ - "Accept as-is" — Deviation is intentional, no action needed
275
+ - "Generate corrective plan" — Create a plan to fix this
276
+ - "Record as decision" — This is a deliberate choice, record in DECISIONS.md
277
+
278
+ Collect user's response for each finding.
279
+
280
+ **If clean (no ⚠️ or ❌):**
281
+
282
+ Use AskUserQuestion:
283
+ - header: "Review"
284
+ - question: "Review is clean. Any additional issues to flag?"
285
+ - options:
286
+ - "No, phase looks good" — Mark phase as clean
287
+ - "Yes, I have concerns" — Capture user's additional issues
288
+
289
+ **If user has additional concerns:**
290
+ Ask them to describe the issues. For each issue:
291
+ - Classify as deviation or new requirement
292
+ - Add to findings list for corrective plan generation
293
+
294
+ Continue to record_decisions.
295
+ </step>
296
+
297
+ <step name="record_decisions">
298
+ Record any new decisions made during the review conversation.
299
+
300
+ **Collect decisions from:**
301
+ - User accepting deviations as intentional ("we meant to do it this way")
302
+ - User choosing a different approach than the plan specified
303
+ - User flagging issues that reveal design choices
304
+
305
+ **For each new decision:**
306
+ Append to `.specd/features/{feature}/DECISIONS.md`:
307
+ ```markdown
308
+ ### DEC-{NNN}: {Decision title}
309
+
310
+ **Date:** {YYYY-MM-DD}
311
+ **Status:** Active
312
+ **Context:** Discovered during phase {N} review (cycle {C})
313
+ **Decision:** {What was decided}
314
+ **Rationale:**
315
+ - {Why this decision was made}
316
+ **Implications:**
317
+ - {What this means for implementation}
318
+ ```
319
+
320
+ **Update decision count** in `config.json`.
321
+
322
+ **If no new decisions:** Skip this step.
323
+
324
+ Continue to generate_correctives.
325
+ </step>
326
+
327
+ <step name="generate_correctives">
328
+ Generate corrective plans for findings that need fixes (DEC-003).
329
+
330
+ **Skip if:** All findings were accepted or no findings exist.
331
+
332
+ **Determine next plan number:**
333
+ - Count existing plan files in the phase directory
334
+ - Next corrective plan number = max existing number + 1
335
+
336
+ **For each group of findings to fix:**
337
+
338
+ Create a corrective plan file at `plans/phase-{NN}/{MM}-PLAN.md`:
339
+
340
+ ```yaml
341
+ ---
342
+ feature: {feature-name}
343
+ phase: {N}
344
+ plan: {MM}
345
+ depends_on:
346
+ - phase-{NN}/{last-executed}-PLAN.md
347
+ creates:
348
+ - {any new files needed}
349
+ modifies:
350
+ - {files that need fixing}
351
+ corrects:
352
+ - {original plan numbers being corrected, e.g., [01, 03]}
353
+ ---
354
+ ```
355
+
356
+ **Corrective plan content:**
357
+ - Objective: Fix specific deviations/issues from review cycle {C}
358
+ - Reference the original plan's intent
359
+ - Tasks scoped to fixing gaps, not adding features
360
+ - Each task has verification
361
+ - Include the planned vs actual from review findings
362
+
363
+ **Scoping rules (CAPA framework):**
364
+ - Corrective plans should modify fewer files than the original plans, not more
365
+ - Fix what was intended but not done — don't add features
366
+ - If a finding spans multiple original plans, one corrective plan can reference multiple via `corrects: [01, 03]`
367
+ - Ask user before generating if scope seems large
368
+
369
+ **Present generated plans:**
370
+ ```
371
+ Generated corrective plans:
372
+
373
+ | Plan | Corrects | Title | Files |
374
+ |------|----------|-------|-------|
375
+ | {MM}-PLAN.md | Plan(s) {NN} | {title} | {file count} |
376
+
377
+ These will be picked up by /specd:phase:execute automatically.
378
+ ```
379
+
380
+ Continue to update_state.
381
+ </step>
382
+
383
+ <step name="update_state">
384
+ Update STATE.md with review cycle data (DEC-004).
385
+
386
+ **Determine cycle number:**
387
+ - Read existing Review Cycles table in STATE.md
388
+ - If section doesn't exist, create it
389
+ - Cycle number = max existing cycle for this phase + 1
390
+
391
+ **Add/create Review Cycles section** (after "Execution Progress", before "Discussion Sessions"):
392
+
393
+ ```markdown
394
+ ## Review Cycles
395
+
396
+ | Phase | Cycle | Date | Findings | Corrective Plans | Status |
397
+ |-------|-------|------|----------|------------------|--------|
398
+ | {N} | {C} | {YYYY-MM-DD} | {summary, e.g., "2 deviations, 1 incomplete"} | {plan refs or "—"} | {clean or fixes-pending} |
399
+ ```
400
+
401
+ **Status values:**
402
+ - `clean` — No unresolved findings, all accepted or no deviations
403
+ - `fixes-pending` — Corrective plans generated, awaiting execution
404
+
405
+ **If status is `clean` and all plans executed:**
406
+ - Update Execution Progress to mark phase as complete:
407
+ ```markdown
408
+ - [x] Phase {N} complete
409
+ ```
410
+
411
+ **If this is a subsequent cycle (cycle > 1):**
412
+ - Show progress: "Cycle {C}: {N} findings (down from {M})"
413
+ - If findings increased, add warning: "Findings increased from {M} to {N}. Consider discussing before continuing."
414
+
415
+ Continue to update_changelog.
416
+ </step>
417
+
418
+ <step name="update_changelog">
419
+ Log deviations to CHANGELOG.md.
420
+
421
+ **Skip if:** No deviations found, or all deviations already logged from a previous review cycle.
422
+
423
+ **Check for duplicates:**
424
+ - Read existing CHANGELOG.md entries
425
+ - Skip any deviation already logged (compare file paths and descriptions)
426
+
427
+ **Add review entry:**
428
+ ```markdown
429
+ ### {YYYY-MM-DD} - Review {feature}/phase-{NN} (Cycle {C})
430
+
431
+ **[Deviation] {Short description}**
432
+ - **Planned:** {What plan specified}
433
+ - **Actual:** {What was actually implemented}
434
+ - **Files:** `{affected file paths}`
435
+ - **Impact:** {Low | Medium | High}
436
+ ```
437
+
438
+ **For accepted deviations (user said "accept as-is"):**
439
+ ```markdown
440
+ **[Accepted] {Short description}**
441
+ - **Planned:** {What plan specified}
442
+ - **Actual:** {What was actually implemented}
443
+ - **Files:** `{affected file paths}`
444
+ - **Reason:** {User's reason for accepting}
445
+ ```
446
+
447
+ Continue to commit_and_next.
448
+ </step>
449
+
450
+ <step name="commit_and_next">
451
+ Commit review changes and suggest next steps.
452
+
453
+ **Commit changes:**
454
+ ```bash
455
+ git add .specd/features/{feature}/STATE.md
456
+ git add .specd/features/{feature}/DECISIONS.md
457
+ git add .specd/features/{feature}/CHANGELOG.md
458
+ # If corrective plans were generated:
459
+ git add .specd/features/{feature}/plans/phase-{NN}/
460
+ git add .specd/features/{feature}/config.json
461
+
462
+ git commit -m "docs({feature}): review phase {N} (cycle {C})
463
+
464
+ Review findings: {summary}
465
+ Status: {clean | fixes-pending}
466
+ {If corrective plans:}Corrective plans: {list}"
467
+ ```
468
+
469
+ **Present next steps:**
470
+
471
+ **If status = `fixes-pending`:**
472
+ ```
473
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
474
+ REVIEW COMPLETE — Fixes Pending
475
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
476
+
477
+ Review cycle {C} recorded. Corrective plans ready for execution.
478
+
479
+ **Next steps:**
480
+ - `/specd:phase:execute {feature}` — Execute corrective plans
481
+ - Then `/specd:phase:review {feature} {N}` — Re-review after fixes
482
+ ```
483
+
484
+ **If status = `clean` and phase complete:**
485
+ ```
486
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
487
+ REVIEW COMPLETE — Phase Clean
488
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
489
+
490
+ Phase {N} review is clean. All executed plans match their intent.
491
+
492
+ {If all plans executed:}
493
+ Phase {N} is complete!
494
+
495
+ **Next steps:**
496
+ {If next phase exists:}
497
+ - `/specd:phase:prepare {feature} {N+1}` — Prepare next phase
498
+ - `/specd:phase:plan {feature} {N+1}` — Plan next phase
499
+
500
+ {If last phase:}
501
+ Feature '{feature}' implementation is complete!
502
+ Review STATE.md for full summary.
503
+ ```
504
+
505
+ **If status = `clean` but partial execution:**
506
+ ```
507
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
508
+ REVIEW COMPLETE — Clean (Partial)
509
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
510
+
511
+ Reviewed {M} of {N} plans. All reviewed plans are clean.
512
+
513
+ **Next steps:**
514
+ - `/specd:phase:execute {feature}` — Continue executing remaining plans
515
+ - `/specd:phase:review {feature} {N}` — Re-review after more execution
516
+ ```
517
+
518
+ End workflow.
519
+ </step>
520
+
521
+ </process>
522
+
523
+ <changelog_format>
524
+ When logging to CHANGELOG.md during review, use these types:
525
+
526
+ ```markdown
527
+ ### {YYYY-MM-DD} - Review {feature}/phase-{NN} (Cycle {C})
528
+
529
+ **[{Type}] {Short description}**
530
+ - **Planned:** {What plan specified}
531
+ - **Actual:** {What was implemented or missing}
532
+ - **Files:** `{comma-separated file paths}`
533
+ - **Impact:** {Low | Medium | High}
534
+ ```
535
+
536
+ Types:
537
+ - `[Deviation]` — Code works but differs from plan
538
+ - `[Incomplete]` — Plan objective not fully met
539
+ - `[Accepted]` — User accepted deviation as intentional
540
+ - `[User-flagged]` — Issue raised by user during conversation phase
541
+ </changelog_format>
542
+
543
+ <success_criteria>
544
+ - Feature and phase validated with execution history
545
+ - All completed plans inspected against actual code
546
+ - Per-plan status table displayed with correct icons
547
+ - Deviations surfaced with planned vs actual comparison
548
+ - User input captured and processed
549
+ - New decisions recorded in DECISIONS.md
550
+ - Corrective plans generated with `corrects` frontmatter (if needed)
551
+ - Review Cycles section updated in STATE.md
552
+ - Deviations logged in CHANGELOG.md (no duplicates)
553
+ - Changes committed
554
+ - Next steps suggested based on review outcome
555
+ </success_criteria>