5-phase-workflow 1.1.1 → 1.2.0

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.
@@ -1,50 +1,89 @@
1
1
  ---
2
2
  name: 5:review-code
3
- description: Reviews code changes using CodeRabbit CLI by delegating execution and parsing to review-processor agent. Handles user interaction and fix application in main context.
3
+ description: Reviews code changes using Claude (built-in) or CodeRabbit CLI. Handles user interaction and fix application in main context.
4
4
  allowed-tools: Bash, Read, Edit, Write, Glob, Grep, AskUserQuestion, Task, mcp__jetbrains__*
5
5
  model: sonnet
6
6
  context: fork
7
7
  user-invocable: true
8
8
  ---
9
9
 
10
- # Review Code with CodeRabbit (Phase 5)
10
+ # Review Code (Phase 5)
11
11
 
12
12
  ## Overview
13
13
 
14
- This skill automates code review using the CodeRabbit CLI. It supports two workflows:
14
+ This command automates code review using a configurable review tool. The review tool is set in `.claude/.5/config.json` (`reviewTool` field). Two tools are supported:
15
+
16
+ - **Claude** (default) — Built-in, zero setup. A fresh-context agent reviews code blind with no knowledge of what was built.
17
+ - **CodeRabbit** — External CLI tool. Requires installation and authentication.
18
+
19
+ Both tools produce the same structured output format, so all downstream steps (presenting results, applying fixes, saving reports) work identically regardless of which tool is used.
15
20
 
16
21
  **Workflow A: Interactive Review** (default)
17
22
  1. Checks prerequisites in main context
18
23
  2. Asks user what to review
19
- 3. Delegates CodeRabbit execution and output parsing to review-processor agent
24
+ 3. Delegates review execution and output parsing to a spawned agent
20
25
  4. Presents structured results and asks user for decisions
21
26
  5. Applies fixes based on user approval
22
27
  6. Reports results
23
28
 
24
29
  **Workflow B: File-Based Annotation** (user preference)
25
- 1. Runs CodeRabbit and saves findings to `.5/{feature-name}/review-{timestamp}-findings.md`
30
+ 1. Runs review and saves findings to `.5/{feature-name}/review-{timestamp}-findings.md`
26
31
  2. User edits the file to mark which findings to fix ([FIX], [SKIP], [MANUAL])
27
32
  3. User runs `/review-code apply` to read annotations and apply marked fixes
28
33
 
29
- **Architecture:** `Command -> Agent -> CodeRabbit CLI`
34
+ **Architecture:** `Command -> Agent -> Review Tool`
30
35
  - This command stays in the main context (user interaction, fix application)
31
- - review-processor agent runs CodeRabbit and categorizes findings (forked context)
36
+ - Spawned agent runs the review and categorizes findings (forked context)
37
+
38
+ ## ⚠️ Scope Constraint
39
+
40
+ **THIS COMMAND REVIEWS CODE AND APPLIES USER-APPROVED FIXES ONLY.**
41
+
42
+ ✅ Read config to determine review tool
43
+ ✅ Check prerequisites for the selected tool
44
+ ✅ Ask user what to review
45
+ ✅ Spawn review agent (Claude or CodeRabbit)
46
+ ✅ Present findings overview to user
47
+ ✅ Ask user which fixes to apply
48
+ ✅ Apply ONLY user-approved fixes
49
+ ✅ Verify changes (compile and test)
50
+ ✅ Save review report
51
+
52
+ ❌ Run the review tool directly (agent does this)
53
+ ❌ Parse review output directly (agent does this)
54
+ ❌ Apply fixes without user approval
55
+ ❌ Skip the overview step — user must see all findings first
56
+ ❌ Skip verification — always compile and test after fixes
57
+
58
+ **ALWAYS GET USER CONSENT BEFORE APPLYING ANY FIXES.**
32
59
 
33
60
  ## Prerequisites
34
61
 
35
- **Required:**
62
+ **Claude reviewer (default):**
63
+ - Git repository with changes to review
64
+ - No additional setup needed
65
+
66
+ **CodeRabbit reviewer:**
36
67
  - CodeRabbit CLI installed (`coderabbit` command available)
37
68
  - User logged in to CodeRabbit (`coderabbit auth status` shows authenticated)
38
69
  - Git repository with changes to review
39
70
 
40
- **Installation:**
41
- If CodeRabbit is not installed, see: https://docs.coderabbit.ai/cli/installation
42
-
43
71
  ## Review Process
44
72
 
45
- ### Step 1: Check Prerequisites
73
+ ### Step 1: Determine Review Tool and Check Prerequisites
46
74
 
47
- Check if CodeRabbit CLI is installed and user is authenticated:
75
+ **1a. Read config:**
76
+ ```bash
77
+ # Read review tool preference
78
+ cat .claude/.5/config.json
79
+ # Look for "reviewTool" field — values: "claude", "coderabbit", or "none"
80
+ ```
81
+
82
+ If no config exists or `reviewTool` is not set, default to `"claude"`.
83
+
84
+ If `reviewTool` is `"none"`, inform user that automated review is disabled and exit.
85
+
86
+ **1b. If review tool is CodeRabbit, check prerequisites:**
48
87
 
49
88
  ```bash
50
89
  # Check if coderabbit command exists
@@ -54,10 +93,18 @@ which coderabbit
54
93
  coderabbit auth status
55
94
  ```
56
95
 
57
- **If not installed or not logged in:**
96
+ **If CodeRabbit not installed or not logged in:**
58
97
  - Inform user: "CodeRabbit CLI is not installed or you're not logged in."
59
- - Provide installation/login instructions
60
- - Exit without reviewing
98
+ - Provide installation guidance:
99
+ - macOS: `brew install --cask coderabbit`
100
+ - Other: `curl -fsSL https://cli.coderabbit.ai/install.sh | sh`
101
+ - Then: `coderabbit auth login`
102
+ - Ask user (via AskUserQuestion): "Would you like to switch to Claude (built-in) for this review instead?"
103
+ - Options: "Yes, use Claude for this review (Recommended)", "No, I'll install CodeRabbit first"
104
+ - If yes: proceed with Claude as the review tool for this session
105
+ - If no: exit without reviewing
106
+
107
+ **1c. If review tool is Claude:** no prerequisites to check — proceed directly.
61
108
 
62
109
  ### Step 2: Check for Special Modes
63
110
 
@@ -87,34 +134,149 @@ Ask the user what to review and how to present results using AskUserQuestion:
87
134
  1. **Interactive** (default) - Show findings and apply fixes immediately
88
135
  2. **Save to file** - Save findings to `.5/{feature-name}/` for later annotation
89
136
 
90
- ### Step 4: Spawn review-processor Agent
137
+ ### Step 4: Spawn Review Agent
138
+
139
+ Branch based on the review tool determined in Step 1.
140
+
141
+ #### Step 4A: CodeRabbit Review Agent
91
142
 
92
- Read `.claude/agents/review-processor.md` for agent instructions, then spawn via Task tool:
143
+ If the review tool is **CodeRabbit**, spawn:
93
144
 
94
145
  ```
95
146
  Task tool call:
96
147
  subagent_type: general-purpose
148
+ model: sonnet
97
149
  description: "Run CodeRabbit review"
98
150
  prompt: |
99
- {Contents of review-processor.md}
151
+ Run CodeRabbit CLI and categorize findings.
152
+
153
+ ## Review Scope
154
+ Scope: {scope from Step 3}
155
+ Base Branch: {branch-name if scope is "branch"}
156
+ Files: [{file-paths if scope is "files"}]
157
+
158
+ ## Process
159
+
160
+ 1. **Run CodeRabbit** based on scope:
161
+ - staged: `coderabbit review --plain`
162
+ - files: `coderabbit review --plain {file1} {file2}`
163
+ - branch: `coderabbit review --plain --base {base-branch}`
100
164
 
101
- ---
165
+ 2. **Parse output** - Extract file paths, line numbers, severity, descriptions, suggested fixes
102
166
 
103
- ## Your Task
167
+ 3. **Categorize each finding:**
168
+ - **Fixable**: Mechanical fixes (unused imports, null checks, formatting, typos)
169
+ - **Questions**: Clarifications needed (validation logic, trade-offs)
170
+ - **Manual**: Requires judgment (refactoring, architecture, security)
104
171
 
105
- Review Scope: {scope from Step 3}
172
+ ## Output Format
173
+ Return:
174
+ ```
175
+ Status: success | failed
176
+ Error: {if failed}
177
+
178
+ Summary:
179
+ total: {N}, fixable: {N}, questions: {N}, manual: {N}
180
+
181
+ Fixable Issues:
182
+ - file: {path}, line: {N}, description: {what}, fix: {suggestion}
183
+
184
+ Questions:
185
+ - file: {path}, line: {N}, question: {what the reviewer asks}
186
+
187
+ Manual Review:
188
+ - file: {path}, line: {N}, description: {what}, severity: {level}
189
+
190
+ Raw Output:
191
+ {full review output}
192
+ ```
193
+
194
+ ## Rules
195
+ - DO NOT apply fixes (parent handles with user consent)
196
+ - DO NOT interact with user
197
+ - Include ALL findings - let parent decide what to apply
198
+ ```
199
+
200
+ #### Step 4B: Claude Review Agent
201
+
202
+ If the review tool is **Claude**, spawn:
203
+
204
+ ```
205
+ Task tool call:
206
+ subagent_type: general-purpose
207
+ model: sonnet
208
+ description: "Run Claude code review"
209
+ prompt: |
210
+ You are a code reviewer. You have NO prior knowledge of what was built, why it was built,
211
+ or what the implementation plan was. You are reviewing this code blind, purely on its merits.
212
+
213
+ ## Review Scope
214
+ Scope: {scope from Step 3}
106
215
  Base Branch: {branch-name if scope is "branch"}
107
216
  Files: [{file-paths if scope is "files"}]
217
+
218
+ ## Process
219
+
220
+ 1. **Get the diff** based on scope:
221
+ - staged: run `git diff --cached`
222
+ - unstaged: run `git diff`
223
+ - all: run `git diff HEAD`
224
+ - branch: run `git diff {base-branch}...HEAD`
225
+ - files: run `git diff -- {file1} {file2}` (or `git diff --cached -- {file1} {file2}` if staged)
226
+
227
+ 2. **Read full files** — For every file that appears in the diff, read the complete file content.
228
+ Also read 1 level of imports (files directly imported by changed files) to understand context.
229
+
230
+ 3. **Review for:**
231
+ - **Bugs**: Logic errors, off-by-one, null/undefined access, race conditions, missing error handling
232
+ - **Security**: Injection, XSS, auth bypass, secrets exposure, insecure defaults
233
+ - **Performance**: N+1 queries, unnecessary allocations, missing pagination, blocking operations
234
+ - **Code quality**: Dead code, unclear naming, duplicated logic, overly complex conditionals
235
+ - **API design**: Inconsistent interfaces, missing validation, breaking changes, poor error responses
236
+
237
+ 4. **Categorize each finding:**
238
+ - **Fixable**: Mechanical fixes (unused imports, null checks, formatting, typos, dead code removal)
239
+ - **Questions**: Clarifications needed (validation logic, trade-offs, ambiguous intent)
240
+ - **Manual**: Requires judgment (refactoring, architecture decisions, security implications)
241
+
242
+ ## Output Format
243
+ Return:
244
+ ```
245
+ Status: success | failed
246
+ Error: {if failed}
247
+
248
+ Summary:
249
+ total: {N}, fixable: {N}, questions: {N}, manual: {N}
250
+
251
+ Fixable Issues:
252
+ - file: {path}, line: {N}, description: {what}, fix: {suggestion}
253
+
254
+ Questions:
255
+ - file: {path}, line: {N}, question: {what the reviewer asks}
256
+
257
+ Manual Review:
258
+ - file: {path}, line: {N}, description: {what}, severity: {level}
259
+
260
+ Raw Output:
261
+ {full review analysis}
262
+ ```
263
+
264
+ ## Rules
265
+ - DO NOT apply fixes (parent handles with user consent)
266
+ - DO NOT interact with user
267
+ - Include ALL findings - let parent decide what to apply
268
+ - Be thorough but practical — focus on real issues, not style nitpicks
269
+ - You have NO context about the feature intent — review what the code DOES, not what it was supposed to do
108
270
  ```
109
271
 
110
272
  ### Step 5: Process Agent Results
111
273
 
112
- Receive structured results from review-processor:
274
+ Receive structured results from the agent:
113
275
  - Total issues count
114
276
  - Categorized findings: fixable, questions, manual
115
- - Raw CodeRabbit output
277
+ - Raw review output
116
278
 
117
- If agent returned failure (CodeRabbit failed), report error and exit.
279
+ If agent returned failure (review failed), report error and exit.
118
280
 
119
281
  ### Step 6: Branch Based on Review Mode
120
282
 
@@ -129,7 +291,7 @@ If agent returned failure (CodeRabbit failed), report error and exit.
129
291
  Present a concise overview of all findings:
130
292
 
131
293
  ```
132
- CodeRabbit Review Results:
294
+ Code Review Results:
133
295
 
134
296
  Summary:
135
297
  - Total Issues: {N}
@@ -174,7 +336,7 @@ Only apply fixes that the user has agreed to:
174
336
 
175
337
  ### Step 9: Handle Questions Based on User Preference
176
338
 
177
- If there are questions from CodeRabbit, use AskUserQuestion:
339
+ If there are questions from the reviewer, use AskUserQuestion:
178
340
 
179
341
  **Options:**
180
342
  1. "Ask me for each" - Present each question individually
@@ -215,45 +377,18 @@ After applying fixes:
215
377
 
216
378
  ### Step 9c: Generate Review Summary
217
379
 
218
- Create comprehensive summary report:
219
-
220
- ```markdown
221
- # CodeRabbit Review Summary
222
-
223
- **Reviewed:** {scope}
224
- **Timestamp:** {timestamp in ISO 8601 format, e.g., 2026-01-28T10:30:45Z}
225
- **User Decisions:** {summary of user choices}
226
-
227
- ## Summary
228
-
229
- - **Total Issues:** {N}
230
- - **Applied with User Approval:** {N}
231
- - **User-Resolved Questions:** {N}
232
- - **Manual Review Needed:** {N}
233
- - **Skipped by User:** {N}
234
-
235
- ## Applied Fixes (User Approved)
236
-
237
- - `ProductFactory.ts:45` - Added null check for parameter
238
- - `OrderValidator.ts:23` - Removed unused import
380
+ Create comprehensive summary report using the template structure.
239
381
 
240
- ## User-Resolved Questions
382
+ **Template Reference:** Use the structure from `.claude/templates/workflow/REVIEW-SUMMARY.md`
241
383
 
242
- - `ProductFactory.ts:67` - Added empty string validation (user answered: yes)
243
-
244
- ## Manual Review Needed
245
-
246
- - `ProductFactory.ts:120` - Consider extracting this method (complexity: 15)
247
-
248
- ## Skipped Issues
249
-
250
- - `ProductFactory.ts:200` - User chose not to apply
251
-
252
- ## Files Modified
253
-
254
- - ProductFactory.ts (2 fixes applied)
255
- - OrderValidator.ts (1 fix applied)
256
- ```
384
+ The template contains placeholders for:
385
+ - **Header:** Reviewed scope, timestamp, user decisions summary
386
+ - **Summary:** Counts for total issues, applied fixes, user-resolved questions, manual review, skipped
387
+ - **Applied Fixes:** List of fixes applied with user approval (file:line - description)
388
+ - **User-Resolved Questions:** Questions answered by user with their decisions
389
+ - **Manual Review Needed:** Issues requiring human judgment
390
+ - **Skipped Issues:** Fixes user chose not to apply
391
+ - **Files Modified:** Summary of modified files with fix counts
257
392
 
258
393
  ### Step 10: Save Findings to File (File-Based Mode)
259
394
 
@@ -282,72 +417,20 @@ Example: 20260128-103045
282
417
 
283
418
  **File format:**
284
419
 
285
- ```markdown
286
- # Code Review Findings
287
-
288
- **Generated:** {timestamp in ISO 8601 format, e.g., 2026-01-28T10:30:45Z}
289
- **Scope:** {what was reviewed}
290
- **Total Findings:** {N}
291
-
292
- ---
293
-
294
- ## How to Use This File
295
-
296
- 1. Review each finding below
297
- 2. For each finding, choose an action:
298
- - `[FIX]` - Apply this fix automatically (leave as-is)
299
- - `[SKIP]` - Don't apply this fix (change FIX to SKIP)
300
- - `[MANUAL]` - Custom instructions (change FIX to MANUAL and add instructions)
301
- 3. Save this file
302
- 4. Run: `/review-code apply`
303
-
304
- The apply command will read your annotations and apply marked fixes.
305
-
306
- ---
307
-
308
- ## Finding 1/{total}
309
-
310
- **File:** {file-path}
311
- **Line:** {line-number}
312
- **Category:** {Fixable|Question|Manual}
313
- **Severity:** {error|warning|suggestion}
314
-
315
- **Description:**
316
- {what CodeRabbit found}
317
-
318
- **Suggested Fix:**
319
- {how to fix it - can be multi-line}
320
-
321
- **Original CodeRabbit Message:**
322
- ```
323
- {raw output from CodeRabbit}
324
- ```
325
-
326
- **Action:** [FIX]
327
-
328
- **Custom Instructions:** (only if you selected [MANUAL])
329
- <!-- Add detailed instructions here if you want a custom fix -->
330
-
331
-
332
- ---
333
-
334
- ## Finding 2/{total}
335
-
336
- ...
337
-
338
- ---
339
-
340
- ## Summary
341
-
342
- - Total: {N}
343
- - Fixable: {N}
344
- - Questions: {N}
345
- - Manual Review: {N}
346
-
347
- **Next Steps:**
348
- 1. Edit this file to mark which findings to fix
349
- 2. Run: `/review-code apply`
350
- ```
420
+ **Template Reference:** Use the structure from `.claude/templates/workflow/REVIEW-FINDINGS.md`
421
+
422
+ The template contains:
423
+ - **Header:** Generated timestamp, scope, total findings count
424
+ - **How to Use This File:** Instructions for user annotation with [FIX], [SKIP], [MANUAL] actions
425
+ - **Finding sections:** Repeated for each finding with:
426
+ - File path, line number, category, severity
427
+ - Description of what the reviewer found
428
+ - Suggested fix
429
+ - Original reviewer message
430
+ - Action placeholder (default [FIX])
431
+ - Custom instructions field for [MANUAL] fixes
432
+ - **Summary:** Counts of total, fixable, questions, manual review
433
+ - **Next Steps:** Instructions to edit and run `/review-code apply`
351
434
 
352
435
  **After saving file:**
353
436
  - Inform user: "Findings saved to .5/{feature-name}/review-{timestamp}-findings.md"
@@ -448,55 +531,6 @@ For interactive mode only, save the review summary to:
448
531
  .5/{feature-name}/review-{timestamp}.md
449
532
  ```
450
533
 
451
- ## Instructions Summary
452
-
453
- ### Interactive Mode (Default)
454
- 1. **Check prerequisites** - CodeRabbit installed and logged in
455
- 2. **Ask what to review** - Staged, unstaged, branch, or specific files
456
- 3. **Ask review mode** - Interactive or save to file
457
- 4. **Spawn review-processor** - Delegate CodeRabbit execution and parsing
458
- 5. **Process results** - Receive categorized findings
459
- 6. **Provide overview** - Show concise summary to user
460
- 7. **Ask user** - Which fixes to apply, how to handle questions
461
- 8. **Apply fixes** - Only user-approved fixes, using Edit tool
462
- 9. **Handle questions** - Ask user for each if requested
463
- 10. **Verify changes** - Compile and test after applying fixes
464
- 11. **Save report** - Store in `.5/{feature-name}/`
465
-
466
- ### File-Based Annotation Mode
467
- 1. **Check prerequisites** - CodeRabbit installed and logged in
468
- 2. **Ask what to review** - Staged, unstaged, branch, or specific files
469
- 3. **User selects "Save to file"**
470
- 4. **Spawn review-processor** - Delegate CodeRabbit execution and parsing
471
- 5. **Process results** - Receive categorized findings
472
- 6. **Save findings file** - Store structured findings in `.5/{feature-name}/review-{timestamp}-findings.md`
473
- 7. **User edits file** - Mark findings as [FIX], [SKIP], or [MANUAL] with instructions
474
- 8. **User runs `/review-code apply`** - Apply annotated fixes
475
- 9. **Parse annotations** - Read user's action markers and custom instructions
476
- 10. **Apply marked fixes** - Apply [FIX] and [MANUAL] fixes automatically
477
- 11. **Verify changes** - Compile and test after applying fixes
478
- 12. **Update findings file** - Append application results
479
-
480
- ## Key Principles
481
-
482
- 1. **Thin orchestrator** - Delegate CodeRabbit execution to agent, keep interaction in main context
483
- 2. **User consent first** - Always get user approval before applying any fixes
484
- 3. **Provide overview** - Give user a clear summary before asking for decisions
485
- 4. **Transparency** - Report all actions taken and user decisions made
486
- 5. **Verification** - Always compile and test after applying fixes
487
- 6. **Non-intrusive** - If not installed or logged in, gracefully exit
488
-
489
- ## DO NOT
490
-
491
- - DO NOT run CodeRabbit directly (agent handles this)
492
- - DO NOT parse CodeRabbit output directly (agent handles this)
493
- - DO NOT apply fixes without user approval
494
- - DO NOT auto-apply complex refactoring suggestions
495
- - DO NOT skip the overview step
496
- - DO NOT skip verification (compilation/tests)
497
- - DO NOT proceed if CodeRabbit is not installed
498
- - DO NOT assume user wants all fixes applied
499
-
500
534
  ## Error Handling
501
535
 
502
536
  ### CodeRabbit Not Installed
@@ -504,23 +538,37 @@ For interactive mode only, save the review summary to:
504
538
  CodeRabbit CLI is not installed.
505
539
 
506
540
  To install:
507
- 1. Visit: https://docs.coderabbit.ai/cli/installation
508
- 2. Follow installation instructions for your OS
509
- 3. Run: coderabbit auth login
510
- 4. Then re-run: /review-code
541
+ - macOS: brew install --cask coderabbit
542
+ - Other: curl -fsSL https://cli.coderabbit.ai/install.sh | sh
543
+ - Then: coderabbit auth login
544
+
545
+ Or switch to the built-in Claude reviewer by running /5:configure
546
+ and selecting "Claude" as your review tool.
511
547
  ```
512
548
 
513
- ### User Not Logged In
549
+ ### CodeRabbit User Not Logged In
514
550
  ```
515
551
  You're not logged in to CodeRabbit.
516
552
 
517
553
  To log in:
518
554
  1. Run: coderabbit auth login
519
555
  2. Follow authentication prompts
520
- 3. Then re-run: /review-code
556
+ 3. Then re-run: /5:review-code
557
+ ```
558
+
559
+ ### Claude Review Agent Failed
560
+ ```
561
+ Claude code review failed.
562
+
563
+ Error: {error from agent}
564
+
565
+ Troubleshooting:
566
+ 1. Check if git repository is valid
567
+ 2. Ensure there are changes to review (run git status)
568
+ 3. Try again — transient failures can occur
521
569
  ```
522
570
 
523
- ### Agent Failed
571
+ ### CodeRabbit Agent Failed
524
572
  ```
525
573
  CodeRabbit review failed.
526
574
 
@@ -580,5 +628,4 @@ Action: Please review the suggested fix manually.
580
628
 
581
629
  ## Related Documentation
582
630
 
583
- - [Agent: review-processor](../agents/review-processor.md)
584
631
  - [Workflow Guide](../docs/workflow-guide.md)