5-phase-workflow 1.9.5 → 2.0.1

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 (44) hide show
  1. package/README.md +81 -410
  2. package/bin/install.js +385 -70
  3. package/bin/sync-agents.js +50 -11
  4. package/docs/findings.md +3 -3
  5. package/docs/workflow-guide.md +110 -1046
  6. package/package.json +6 -5
  7. package/src/agents/step-executor-agent.md +49 -0
  8. package/src/agents/step-orchestrator-agent.md +111 -0
  9. package/src/agents/verification-agent.md +78 -0
  10. package/src/commands/5/address-review-findings.md +69 -403
  11. package/src/commands/5/apply-review-findings.md +66 -0
  12. package/src/commands/5/configure.md +110 -76
  13. package/src/commands/5/discuss-feature.md +47 -57
  14. package/src/commands/5/eject.md +7 -6
  15. package/src/commands/5/implement.md +202 -0
  16. package/src/commands/5/plan.md +164 -0
  17. package/src/commands/5/reconfigure.md +32 -31
  18. package/src/commands/5/reply-pr-comments.md +46 -0
  19. package/src/commands/5/review.md +95 -0
  20. package/src/commands/5/split.md +190 -0
  21. package/src/commands/5/synchronize-agents.md +4 -4
  22. package/src/commands/5/triage-pr-comments.md +70 -0
  23. package/src/commands/5/update.md +8 -8
  24. package/src/hooks/check-updates.js +50 -7
  25. package/src/hooks/plan-guard.js +28 -22
  26. package/src/hooks/statusline.js +55 -4
  27. package/src/skills/configure-docs-index/SKILL.md +16 -21
  28. package/src/skills/configure-skills/SKILL.md +21 -24
  29. package/src/templates/AGENTS.md +94 -0
  30. package/src/templates/workflow/FIX-PLAN.md +1 -1
  31. package/src/templates/workflow/PLAN-COMPACT.md +42 -0
  32. package/src/templates/workflow/PLAN.md +58 -34
  33. package/src/templates/workflow/REVIEW-FINDINGS.md +7 -16
  34. package/src/templates/workflow/REVIEW-SUMMARY.md +5 -0
  35. package/src/templates/workflow/STATE.json +32 -3
  36. package/src/agents/component-executor.md +0 -57
  37. package/src/commands/5/implement-feature.md +0 -381
  38. package/src/commands/5/plan-feature.md +0 -293
  39. package/src/commands/5/plan-implementation.md +0 -333
  40. package/src/commands/5/quick-implement.md +0 -375
  41. package/src/commands/5/review-code.md +0 -212
  42. package/src/commands/5/verify-implementation.md +0 -277
  43. package/src/templates/workflow/FEATURE-SPEC.md +0 -100
  44. package/src/templates/workflow/VERIFICATION-REPORT.md +0 -103
@@ -1,424 +1,90 @@
1
1
  ---
2
2
  name: 5:address-review-findings
3
- description: Applies annotated review findings and/or addresses GitHub PR review comments. Use --github to process PR comments only.
4
- allowed-tools: Bash, Read, Edit, Write, Glob, Grep, AskUserQuestion, Agent, Skill, mcp__jetbrains__*
3
+ description: Coordinates interactive review finding decisions and optionally handles GitHub PR review comments.
4
+ allowed-tools: Bash, Read, Write, Glob, AskUserQuestion
5
5
  user-invocable: true
6
- model: sonnet
7
- context: fork
6
+ model: haiku
7
+ context: inherit
8
8
  ---
9
9
 
10
10
  <role>
11
- You are a Fix Applicator. You read annotated review findings and apply approved fixes.
12
- You do NOT review code. You do NOT implement new features. You do NOT refactor beyond what findings specify.
13
- You apply fixes exactly as described in the findings file and confirmed by the user.
14
- You follow the exact step sequence below. Do not skip or reorder steps.
11
+ You are a Review Fix Coordinator. You keep context lean, collect user decisions one finding at a time, route work to narrower helper commands, and do not review code or implement unrelated changes.
15
12
  </role>
16
13
 
17
- # Address Review Findings (Phase 5b)
14
+ # Address Review Findings
18
15
 
19
- This command reads a `review-findings-*.md` file produced by `/5:review-code`, applies all `[FIX]` items, and optionally fetches and addresses GitHub PR review comments.
16
+ This is the stable entrypoint after `/5:review`.
20
17
 
21
18
  ## Options
22
19
 
23
- - **`--github`** Skip local findings entirely. Only fetch and process GitHub PR review comments for the current branch.
20
+ - `--github` - skip local findings and process PR comments only.
24
21
 
25
22
  ## Process
26
23
 
27
- ### Step 1: Determine Mode and Feature Context
28
-
29
- Check if the command was invoked with `--github`.
30
-
31
- - **`--github` mode:** Skip Steps 2 and 3. Proceed directly to Step 4 (GitHub PR Integration), which is now mandatory — do not ask the user whether to include PR comments.
32
- - **Normal mode:** Follow all steps in order.
33
-
34
- ---
35
-
36
- Regardless of mode, read `.5/features/*/state.json` using Glob to find all state files. Select the one with the most recent `startedAt` (or `lastUpdated` if present).
37
-
38
- Extract:
39
- - `feature` feature directory name
40
- - `ticket` ticket ID
41
- - Feature directory path: `.5/features/{feature}/`
42
-
43
- Also read `.5/config.json` if present. Extract `git.branch` if set.
44
-
45
- If no state.json files found, ask user via AskUserQuestion: "Which feature are you working on?" — prompt them to enter the feature name manually.
46
-
47
- ### Step 2: Locate Review Findings File *(skipped in --github mode)*
48
-
49
- Use Glob to find `review-findings-*.md` in the feature directory:
50
- ```
51
- .5/features/{feature}/review-findings-*.md
52
- ```
53
-
54
- - **Multiple files found:** Use the one with the most recent timestamp in the filename (format `YYYYMMDD-HHmmss`).
55
- - **One file found:** Use it.
56
- - **No file found:** Ask via AskUserQuestion:
57
- - "No review-findings file found. How would you like to proceed?"
58
- - Options: "Proceed with GitHub PR comments only" / "Stop — I'll run /5:review-code first"
59
- - If "Stop", exit with: `Run /5:review-code to generate a findings file first.`
60
- - If "GitHub PR only", skip to Step 4.
61
-
62
- #### Parse Findings
63
-
64
- Read the findings file. For each finding block, extract:
65
- - File path
66
- - Line number
67
- - Category and severity
68
- - Description
69
- - Suggested fix
70
- - Custom instructions (if MANUAL)
71
- - **Action:** `[FIX]` / `[SKIP]` / `[MANUAL]`
72
-
73
- Collect three lists:
74
- - `to_fix` — all `[FIX]` items
75
- - `to_skip` — all `[SKIP]` items
76
- - `to_manual` — all `[MANUAL]` items
77
-
78
- ### Step 3: Present Findings Summary *(skipped in --github mode)*
79
-
80
- Display a summary to the user:
81
-
82
- ```
83
- Review Findings Summary:
84
- - To fix (automatic): {N}
85
- - To skip: {N}
86
- - Manual (custom fix): {N}
87
-
88
- Fixes to apply:
89
- {#} {file}:{line} — {description}
90
-
91
- Manual items:
92
- {#} {file}:{line} — {description}
93
- Instructions: {custom instructions}
94
-
95
- Skipped items:
96
- {#} {file}:{line} — {description}
97
- ```
98
-
99
- ### Step 4: GitHub PR Integration
100
-
101
- Check if a PR exists for the current branch:
102
- ```bash
103
- gh pr list --head "$(git branch --show-current)" --json number,url,title --limit 1
104
- ```
105
-
106
- If the `gh` command is not available or returns an error:
107
- - In `--github` mode: report the error and STOP — PR comments are the only goal.
108
- - In normal mode: skip this step silently.
109
-
110
- **If no PR is found:**
111
- - In `--github` mode: report "No open PR found for the current branch." and STOP.
112
- - In normal mode: skip this step.
113
-
114
- **If a PR is found in normal mode:** Ask via AskUserQuestion:
115
- - "A PR was found: {title} ({url}). Include PR review comments?"
116
- - Options: "Yes, include PR comments" / "No, local findings only"
117
- - If "No": skip the rest of this step.
118
-
119
- **If a PR is found in `--github` mode:** proceed immediately without asking.
120
-
121
- **Fetch PR comments:**
122
-
123
- Fetch review comments (inline code comments):
124
- ```bash
125
- gh api repos/{owner}/{repo}/pulls/{number}/comments --paginate
126
- ```
127
-
128
- Fetch issue comments (general PR comments):
129
- ```bash
130
- gh api repos/{owner}/{repo}/issues/{number}/comments --paginate
131
- ```
132
-
133
- To get `{owner}` and `{repo}`, run:
134
- ```bash
135
- gh repo view --json owner,name
136
- ```
137
-
138
- Spawn a sonnet agent to analyze PR comments:
139
-
140
- ```
141
- Agent tool call:
142
- subagent_type: general-purpose
143
- model: sonnet
144
- description: "Analyze PR review comments"
145
- prompt: |
146
- Analyze these GitHub PR review comments and categorize each one.
147
-
148
- ## Local Findings (already being addressed)
149
- {list of file:line:description from to_fix + to_skip + to_manual — or "none" in --github mode}
150
-
151
- ## PR Review Comments
152
- {raw JSON of review comments}
153
-
154
- ## PR Issue Comments
155
- {raw JSON of issue comments}
156
-
157
- ## Instructions
158
- For each PR comment, categorize it as:
159
- - **actionable_fix**: Clear code change needed, not already covered by local findings
160
- - **duplicate**: Same file + similar issue already in local findings
161
- - **manual**: Requires judgment or discussion, not a simple code fix
162
- - **skip**: Automated, bot-generated, resolved, or not actionable
163
-
164
- For duplicates, note which local finding covers it.
165
-
166
- For every actionable_fix and manual comment, also provide:
167
- - **recommendation**: one of `address`, `defer`, `decline`, or `discuss`
168
- - `address` — should be fixed now, clear and reasonable
169
- - `defer` — valid concern but low urgency, can wait
170
- - `decline` — out of scope or disagree with the suggestion
171
- - `discuss` — needs more context before deciding
172
- - **reasoning**: one plain-English sentence explaining the recommendation
173
-
174
- ## Output Format
175
- Return a structured list:
176
-
177
- ---PR-COMMENTS---
178
- {id} | {file}:{line} | {category} | {description} | {duplicate_of or "none"} | {recommendation or "n/a"} | {one-sentence reasoning or "n/a"}
179
- ---END-PR-COMMENTS---
180
-
181
- Rules:
182
- - DO NOT apply fixes
183
- - DO NOT interact with user
184
- - Include every comment in the output
185
- - recommendation and reasoning are required for actionable_fix and manual; use "n/a" for skip and duplicate
186
- ```
187
-
188
- Parse the `---PR-COMMENTS---` block. For each line extract all seven fields. Build:
189
- - `pr_actionable` — actionable_fix items (with recommendation + reasoning)
190
- - `pr_manual` — manual items (with recommendation + reasoning)
191
- - `pr_duplicates` — duplicate items (auto-assign `decision: wont_fix`, no Q&A)
192
- - `pr_skip` — skip items (auto-assign `decision: wont_fix`, no Q&A)
193
-
194
- Initialize `pr_decisions` as an empty list. Append all `pr_duplicates` and `pr_skip` entries with `decision: wont_fix` and `user_note: ""`.
195
-
196
- **Display count summary:**
197
- ```
198
- PR Review Comments found:
199
- - Actionable (new): {N}
200
- - Manual/Discussion: {N}
201
- - Duplicates (covered by local): {N}
202
- - Skipped (bot/resolved): {N}
203
-
204
- You will now be asked to decide on each actionable and manual comment individually.
205
- ```
206
-
207
- If there are no `pr_actionable` and no `pr_manual` items, display `"No actionable or manual PR comments to review."` and skip the loop below.
208
-
209
- **Per-comment decision loop** — iterate over all items in `pr_actionable + pr_manual` in order, using a counter `i` from 1 to total:
210
-
211
- For each comment:
212
-
213
- 1. Display:
214
- ```
215
- ── PR Comment {i} of {total} ──────────────────────────
216
- Category: {category}
217
- File: {file}:{line}
218
- Comment: {description}
219
-
220
- Recommendation: {recommendation} — {reasoning}
221
- ──────────────────────────────────────────────────────
222
- ```
223
-
224
- 2. Ask via AskUserQuestion:
225
- - Question: `"[{i}/{total}] {file}:{line} — How do you want to handle this comment?"`
226
- - Options: `"fix — apply the suggested change"` / `"won't fix — decline"` / `"wait — defer for later"`
227
-
228
- 3. Record the decision (map to internal values: `fix`, `wont_fix`, `wait`).
229
-
230
- 4. Ask via AskUserQuestion:
231
- - Question: `"Add a note for this comment? (shown in PR reply and summary report)"`
232
- - Options: `"No note"` / `"Add a note"`
233
- - If "Add a note": ask via AskUserQuestion with free-text input (no fixed options):
234
- - Question: `"Enter your note for: {file}:{line}"`
235
-
236
- 5. Append to `pr_decisions`:
237
- ```
238
- { comment_id, file_line, category, description, decision, user_note (or ""), recommendation, reasoning }
239
- ```
240
-
241
- After the loop, display:
242
- ```
243
- Decision summary:
244
- - fix: {N} comments
245
- - won't fix: {N} comments
246
- - wait: {N} comments
247
-
248
- Proceeding to apply fixes...
249
- ```
250
-
251
- Derive `pr_approved_fixes` as the subset of `pr_decisions` where `decision == fix`. This list is used by Step 5.
252
-
253
- ### Step 5: Apply Fixes
254
-
255
- Apply fixes in this order: local `[FIX]` items first, then local `[MANUAL]` items, then approved PR fixes.
256
-
257
- #### Grouping Strategy
258
-
259
- Group fixes by target file. For each file:
260
- - **1–3 fixes:** Apply directly using Read + Edit tools (bottom-to-top by line number to preserve positions)
261
- - **4+ fixes or complex logic:** Spawn a haiku or sonnet agent per file
262
-
263
- #### Direct Application (1–3 fixes per file)
264
-
265
- For each fix:
266
- 1. Read the file
267
- 2. Apply the change using Edit tool
268
- 3. Track result: APPLIED or FAILED
269
-
270
- Apply from highest line number to lowest within each file to avoid line offset shifts.
271
-
272
- #### Agent Application (4+ fixes per file)
273
-
274
- ```
275
- Agent tool call:
276
- subagent_type: general-purpose
277
- model: {haiku for simple | sonnet for complex}
278
- description: "Apply fixes to {file-path}"
279
- prompt: |
280
- Apply these fixes to the file below. Apply all fixes.
281
- Work from the highest line number to the lowest to avoid line offset issues.
282
-
283
- ## File
284
- {file-path}
285
-
286
- ## Fixes to Apply
287
- {#1} Line {N}: {description}
288
- Fix: {suggested fix or custom instructions}
289
-
290
- {#2} Line {N}: {description}
291
- Fix: {suggested fix or custom instructions}
292
-
293
- ## Instructions
294
- 1. Read the file first
295
- 2. Apply each fix using Edit tool
296
- 3. Apply from highest line to lowest
297
- 4. Do NOT introduce unrelated changes
298
- 5. Report each fix as APPLIED or FAILED with reason
299
-
300
- ## Output Format
301
- {#} APPLIED | {description}
302
- {#} FAILED | {description} | {reason}
303
- ```
304
-
305
- Collect all APPLIED/FAILED results.
306
-
307
- #### Apply [MANUAL] Items
308
-
309
- For each `[MANUAL]` item with custom instructions:
310
- - Read the file
311
- - Apply the custom instructions using Edit tool
312
- - If instructions are ambiguous, spawn a sonnet agent with the full context
313
-
314
- ### Step 6: Reply to GitHub PR Comments
315
-
316
- Iterate over every entry in `pr_decisions` (excluding entries with category `skip` — do not reply to those). For each entry, post a reply using the GitHub API.
317
-
318
- **For review comments (inline):**
319
- ```bash
320
- gh api repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies \
321
- --method POST \
322
- --field body="{reply text}"
323
- ```
324
-
325
- **For issue comments (general):**
326
- ```bash
327
- gh api repos/{owner}/{repo}/issues/{number}/comments \
328
- --method POST \
329
- --field body="{reply text}"
330
- ```
331
-
332
- **Template selection logic:**
333
-
334
- 1. If `category == "duplicate"`: use the auto-duplicate template below
335
- 2. Else if `decision == "fix"`: use fix template, with or without note based on `user_note` presence
336
- 3. Else if `decision == "wont_fix"`: use wont_fix template, with or without note based on `user_note` presence
337
- 4. Else if `decision == "wait"`: use wait template, with or without note based on `user_note` presence
338
-
339
- **Templates:**
340
-
341
- - **`fix` (with user note):** `Applied fix: {description}. Will be included in the next push. Note: {user_note}`
342
- - **`fix` (no note):** `Applied fix: {description}. Will be included in the next push.`
343
- - **`wont_fix` (with user note):** `Reviewed — not addressing: {user_note}`
344
- - **`wont_fix` (no note):** `Reviewed — not addressing: will handle separately`
345
- - **`wait` (with user note):** `Noted for later: {user_note}`
346
- - **`wait` (no note):** `Noted for later: deferring for now`
347
- - **`wont_fix` (auto, duplicate):** `Covered by local review findings — {local_decision}` where `{local_decision}` is `"fix applied"` if the matched local finding has action `[FIX]`, otherwise `"marked as skipped"` or `"flagged for manual review"` accordingly
348
-
349
- If `gh api` is unavailable or fails, log the failure and continue. Do NOT abort for reply failures.
350
-
351
- ### Step 7: Verification
352
-
353
- After all fixes are applied:
354
-
355
- 1. **Build:** Use the project's build skill (e.g., `run-build`) generated during configure
356
- 2. **Test:** Use the project's test skill (e.g., `run-tests`) generated during configure
357
- 3. **Lint:** Check for any lint warnings and errors
358
-
359
- If build fails:
360
- - Report which file(s) were modified and likely caused the failure
361
- - Ask via AskUserQuestion: "Build failed after applying fixes. What would you like to do?"
362
- - Options: "Show me the error and I'll fix manually" / "Revert the last fix and retry"
363
- - If revert: re-read the original file content (from git: `git show HEAD:{file}`) and restore it, then re-run build
364
-
365
- ### Step 8: Save Summary Report
366
-
367
- Write `.5/features/{feature}/review-summary-{YYYYMMDD-HHmmss}.md`.
368
-
369
- Use the template structure from `.claude/templates/workflow/REVIEW-SUMMARY.md`. Include:
370
-
371
- ```markdown
372
- # Code Review Summary
373
-
374
- **Reviewed:** {feature} — findings from {findings-filename}
375
- **Timestamp:** {ISO-timestamp}
376
- **User Decisions:** Applied {N} fixes, declined {N}, deferred {N}
377
-
378
- ## Summary
379
-
380
- - **Local Fixes Applied:** {N}
381
- - **Local Fixes Skipped:** {N}
382
- - **Manual Items Applied:** {N}
383
- - **PR Comments Fixed:** {N} (decision = fix)
384
- - **PR Comments Deferred:** {N} (decision = wait)
385
- - **PR Comments Declined:** {N} (decision = won't fix, excluding auto)
386
- - **Build:** {passed/failed}
387
- - **Tests:** {passed/failed}
388
-
389
- ## Applied Fixes
390
- ...
391
-
392
- ## Skipped Items
393
- ...
394
-
395
- ## Manual Items
396
- ...
397
-
398
- ## PR Comment Decisions
399
-
400
- | # | File:Line | Description | Decision | Note |
401
- |---|-----------|-------------|----------|------|
402
- | {i} | {file}:{line} | {description} | {fix/won't fix/wait} | {user_note or "—"} |
403
-
404
- ## PR Comment Replies
405
- ...
406
- ```
407
-
408
- ### Step 9: Final Output
409
-
410
- Output exactly:
411
-
412
- ```
24
+ 1. Determine feature context:
25
+ - Find `.5/features/*/state.json`.
26
+ - Select the most recent `startedAt` or `lastUpdated`.
27
+ - If none exists, ask for the feature name.
28
+ - Read `.5/config.json` only if needed for git/review settings.
29
+ 2. Normal mode:
30
+ - Find the latest `.5/features/{feature}/review-findings-*.md`.
31
+ - If missing, ask whether to stop or continue with GitHub PR comments only.
32
+ - Parse each finding into compact records with `id`, `file`, `line`, `category`, `severity`, `description`, `suggestedFix`, and `originalReviewerMessage`.
33
+ - For each finding, present one item at a time:
34
+ - Show `Comment {current}/{total}`, file and line, category/severity, concise description, suggested fix, and a recommendation.
35
+ - Recommendation rules:
36
+ - Recommend `fix` for clear, low-risk correctness, test, type, API-contract, or documentation fixes with a specific suggested change.
37
+ - Recommend `wont_fix` for findings that are obsolete, duplicates, outside the feature scope, or based on an incorrect premise.
38
+ - Recommend `wait` for ambiguous behavior, product decisions, risky refactors, or findings needing external validation.
39
+ - Ask the user to choose `fix`, `wont_fix`, `wait`, or provide textual instructions.
40
+ - Treat textual instructions as `fix` with `customInstructions` unless the text clearly says to defer or reject the finding.
41
+ - Write decisions to `.5/features/{feature}/review-decisions-{YYYYMMDD-HHmmss}.json`.
42
+ - Invoke `/5:apply-review-findings {feature} --decisions .5/features/{feature}/review-decisions-{timestamp}.json` to apply approved local fixes.
43
+ 3. GitHub mode or user-approved PR handling:
44
+ - Invoke `/5:triage-pr-comments {feature}` to fetch and classify compact PR comments.
45
+ - Ask the user for decisions on actionable/manual comments.
46
+ - Invoke `/5:apply-review-findings {feature} --pr-approved` for approved PR fixes.
47
+ - Invoke `/5:reply-pr-comments {feature}` to post PR replies.
48
+ 4. Run configured build/test/lint skills if available, or the narrowest configured commands.
49
+ 5. Write `.5/features/{feature}/review-summary-{YYYYMMDD-HHmmss}.md` using `.claude/templates/workflow/REVIEW-SUMMARY.md`.
50
+
51
+ Keep all intermediate summaries compact. Do not paste raw diffs, raw PR JSON, or command logs unless a failure needs exact evidence.
52
+
53
+ ## Local Decision Format
54
+
55
+ Write JSON with this shape:
56
+
57
+ ```json
58
+ {
59
+ "source": ".5/features/{feature}/review-findings-{timestamp}.md",
60
+ "decidedAt": "{ISO-timestamp}",
61
+ "decisions": [
62
+ {
63
+ "id": "finding-1",
64
+ "file": "path/to/file.ts",
65
+ "line": 123,
66
+ "decision": "fix",
67
+ "recommendation": "fix",
68
+ "description": "Concise issue summary",
69
+ "suggestedFix": "Concrete fix to apply",
70
+ "customInstructions": ""
71
+ }
72
+ ]
73
+ }
74
+ ```
75
+
76
+ Allowed `decision` values are `fix`, `wont_fix`, and `wait`.
77
+
78
+ ## Completion
79
+
80
+ Output:
81
+
82
+ ```text
413
83
  Review findings addressed.
414
84
 
415
- Local findings: {N fixed / N skipped / N manual — or "skipped (--github mode)"}
416
- PR comments: {N fixed / N skipped / N replied — or "none"}
417
-
85
+ Local findings: {summary}
86
+ PR comments: {summary}
418
87
  Build: {passed/failed/skipped}
419
88
  Tests: {passed/failed/skipped}
420
-
421
89
  Summary saved at .5/features/{feature}/review-summary-{timestamp}.md
422
90
  ```
423
-
424
- STOP. Do not implement new features. Your job is done.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: 5:apply-review-findings
3
+ description: Applies approved local review findings and approved PR fixes for one feature.
4
+ allowed-tools: Read, Edit, Write, Glob, Bash, AskUserQuestion, Agent
5
+ user-invocable: false
6
+ model: haiku
7
+ argument-hint: [feature-name] [--decisions path] [--pr-approved]
8
+ ---
9
+
10
+ <role>
11
+ You are a Review Fix Applicator. Apply only approved fixes. Do not review code, broaden scope, or refactor unrelated code.
12
+ </role>
13
+
14
+ # Apply Review Findings
15
+
16
+ ## Inputs
17
+
18
+ - Feature directory: `.5/features/{feature}/`
19
+ - Local decisions: the `--decisions` JSON file written by `/5:address-review-findings`, or the latest `.5/features/{feature}/review-decisions-*.json` unless `--pr-approved` is passed.
20
+ - Approved PR fixes: decisions recorded by `/5:triage-pr-comments` when `--pr-approved` is passed.
21
+
22
+ ## Process
23
+
24
+ 1. Parse approved items:
25
+ - Local decision records where `decision` is `fix`.
26
+ - Use `customInstructions` when present; otherwise use `suggestedFix`.
27
+ - Treat `wont_fix` and `wait` as skipped.
28
+ - Approved PR comments where decision is `fix`.
29
+ 2. Group fixes by target file.
30
+ 3. Before editing a file, read it and keep an in-memory snapshot for rollback of this command's edits only.
31
+ 4. Apply fixes:
32
+ - 1-3 simple fixes in a file: edit directly, highest line number first.
33
+ - 4+ fixes or complex logic: spawn one focused agent for that file with only the file path and grouped fix list.
34
+ 5. Track each item as `APPLIED`, `FAILED`, or `SKIPPED`.
35
+ 6. If verification fails and rollback is requested, restore only this command's in-memory snapshots. Never restore from `HEAD`.
36
+
37
+ ## Agent Prompt For Grouped Fixes
38
+
39
+ ```text
40
+ Apply only these approved review fixes.
41
+
42
+ File: {file}
43
+ Fixes:
44
+ {compact numbered list}
45
+
46
+ Rules:
47
+ - Read the file first.
48
+ - Apply from highest line to lowest.
49
+ - Do not introduce unrelated changes.
50
+ - Report each item as APPLIED or FAILED.
51
+ ```
52
+
53
+ ## Output
54
+
55
+ End with:
56
+
57
+ ```text
58
+ ---APPLY-FINDINGS---
59
+ STATUS: success | partial | failed
60
+ APPLIED: {N}
61
+ FAILED: {N}
62
+ SKIPPED: {N}
63
+ FILES_MODIFIED: [comma-separated paths]
64
+ ERRORS: none | {compact summary}
65
+ ---END-APPLY-FINDINGS---
66
+ ```