Skip to content

Commit 1a9de91

Browse files
committed
ai(claude[commands]) Add /review-feedback
why: Process external code review feedback with validation and atomic commits per fix what: - Add .claude/commands/review-feedback.md with 4-phase review processor - Validates each feedback point, applies valid fixes as separate commits with quality gates
1 parent 7c41065 commit 1a9de91

1 file changed

Lines changed: 185 additions & 0 deletions

File tree

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
description: Process external code review feedback — validate each point, apply valid fixes as separate commits
3+
argument-hint: "Paste the external code review feedback here"
4+
allowed-tools: Bash(git diff:*), Bash(git log:*), Bash(git branch:*), Bash(git status:*), Bash(git add:*), Bash(git commit:*), Bash(uv run ruff:*), Bash(uv run mypy:*), Bash(uv run py.test:*), Bash(uv run pytest:*), Read, Grep, Glob, Edit, Write
5+
---
6+
7+
# External Code Review Feedback Processor
8+
9+
Process external code review feedback against the current branch. Validate each feedback point independently, apply valid fixes as separate atomic commits, and ensure all quality gates pass after each commit.
10+
11+
Review feedback to process: $ARGUMENTS
12+
13+
---
14+
15+
## Phase 1: Gather Context
16+
17+
**Goal**: Understand what changed on this branch and parse the review feedback.
18+
19+
**Actions**:
20+
21+
1. **Get the diff** against the trunk branch:
22+
```
23+
git diff origin/master --stat
24+
git diff origin/master
25+
```
26+
27+
2. **Get commit history** for this branch:
28+
```
29+
git log origin/master..HEAD --oneline
30+
```
31+
32+
3. **Read modified files** identified in the diff to understand the full context of each change
33+
34+
4. **Parse the review feedback** into a numbered list of discrete, actionable points. Each point should capture:
35+
- **What**: The specific issue or suggestion
36+
- **Where**: File and approximate location
37+
- **Category**: bug, style, logic, naming, performance, test gap, documentation, etc.
38+
39+
5. **Create a todo list** tracking each feedback point with its validation status
40+
41+
---
42+
43+
## Phase 2: Validate Each Feedback Point
44+
45+
**Goal**: Independently assess whether each feedback point is valid and actionable.
46+
47+
For EACH feedback point:
48+
49+
1. **Read the relevant code** — the exact lines the reviewer is referring to
50+
51+
2. **Assess validity** using these criteria:
52+
- **Valid**: The feedback identifies a real issue or improvement that aligns with project conventions (CLAUDE.md)
53+
- **Already addressed**: The issue was already fixed in a later commit on the branch
54+
- **Incorrect**: The reviewer misread the code or the suggestion would introduce a bug
55+
- **Out of scope**: Valid concern but belongs in a separate PR/issue
56+
- **Subjective/style**: Preference-based with no clear project convention favoring it
57+
58+
3. **Document the verdict** for each point:
59+
- If valid: note exactly what change is needed and in which file(s)
60+
- If invalid: note the specific reason (cite code, tests, or CLAUDE.md conventions)
61+
62+
4. **Present the validation results** to the user before making any changes:
63+
- List each feedback point with its verdict (valid / invalid / out of scope)
64+
- For invalid points, explain why concisely
65+
- For valid points, describe the planned fix
66+
- **Wait for user confirmation** before proceeding to Phase 3
67+
68+
---
69+
70+
## Phase 3: Apply Valid Fixes (One Commit Per Point)
71+
72+
**Goal**: Apply each valid feedback point as a separate, atomic commit.
73+
74+
**CRITICAL**: Process one feedback point at a time. Complete the full cycle for each before moving to the next.
75+
76+
For EACH valid feedback point:
77+
78+
### Step 1: Apply the Fix
79+
80+
- Make the minimal change that addresses the feedback
81+
- Do not bundle unrelated changes
82+
- Follow project conventions from CLAUDE.md:
83+
- `from __future__ import annotations` at top of files
84+
- `import typing as t` namespace style
85+
- NumPy docstring style
86+
- Functional tests only (no test classes)
87+
88+
### Step 2: Run Quality Gates
89+
90+
Run ALL quality gates and ensure they pass:
91+
92+
```bash
93+
uv run ruff check . --fix --show-fixes
94+
uv run ruff format .
95+
uv run mypy
96+
uv run py.test --reruns 0 -vvv
97+
```
98+
99+
- If any gate fails, fix the issue before proceeding
100+
- If a test fails due to the change, either:
101+
- Adjust the fix to be correct, OR
102+
- Update the test if the reviewer's feedback changes expected behavior
103+
- ALL FOUR gates must pass before committing
104+
105+
### Step 3: Commit
106+
107+
Stage only the files changed for this specific feedback point:
108+
109+
```bash
110+
git add <specific-files>
111+
```
112+
113+
Use the project commit message format with HEREDOC:
114+
115+
```bash
116+
git commit -m "$(cat <<'EOF'
117+
Component(fix[subcomponent]) Brief description of the review feedback fix
118+
119+
why: Address code review feedback — <what the reviewer pointed out>
120+
what:
121+
- <specific change 1>
122+
- <specific change 2>
123+
EOF
124+
)"
125+
```
126+
127+
**Commit type guidance**:
128+
- `fix` for bug fixes or correctness issues
129+
- `refactor` for code clarity or structure improvements
130+
- `style` for naming or formatting changes
131+
- `docs` for documentation or docstring fixes
132+
- `test` for test improvements
133+
134+
### Step 4: Verify Clean State
135+
136+
After committing, confirm:
137+
```bash
138+
git status
139+
git diff
140+
```
141+
142+
No uncommitted changes should remain before moving to the next feedback point.
143+
144+
---
145+
146+
## Phase 4: Summary
147+
148+
After processing all valid points, present a summary:
149+
150+
1. **Applied fixes**: List each committed fix with its commit hash
151+
2. **Skipped points**: List each invalid/out-of-scope point with the reason
152+
3. **Final verification**: Run the full quality gate one last time:
153+
```bash
154+
uv run ruff check . --fix --show-fixes
155+
uv run ruff format .
156+
uv run mypy
157+
uv run py.test --reruns 0 -vvv
158+
```
159+
4. Report the final pass/fail status
160+
161+
---
162+
163+
## Recovery: Quality Gate Failure
164+
165+
If quality gates fail after applying a fix:
166+
167+
1. **Identify** which gate failed and why
168+
2. **Fix** the issue (adjust the change, not bypass the gate)
169+
3. **Re-run** all four gates
170+
4. If the fix cannot be made to pass all gates after 2 attempts:
171+
- Revert the change: `git checkout -- <files>`
172+
- Mark the feedback point as "valid but could not apply cleanly"
173+
- Move to the next point
174+
- Report the issue in the Phase 4 summary
175+
176+
---
177+
178+
## Rules
179+
180+
- Never skip quality gates
181+
- Never bundle multiple feedback points into one commit
182+
- Never modify code that isn't related to the feedback being addressed
183+
- Always wait for user confirmation after Phase 2 validation
184+
- Always use project commit message conventions
185+
- If a feedback point requires changes in multiple files, that is still ONE commit (one logical change)

0 commit comments

Comments
 (0)