Skip to content

Commit 12bd916

Browse files
authored
Merge pull request #76 from cblecker/feat/address-pr-feedback
feat(pr-review-toolkit): add address-pr-feedback skill
2 parents 93262ed + cf13fee commit 12bd916

3 files changed

Lines changed: 280 additions & 2 deletions

File tree

pr-review-toolkit/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pr-review-toolkit",
3-
"version": "1.11.1",
3+
"version": "1.12.0",
44
"description": "Comprehensive PR review board using shared workflow context",
55
"author": {
66
"name": "cblecker",

pr-review-toolkit/README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,36 @@ as a single Workflow-based skill. The workflow collects shared PR context,
66
runs specialist reviewers, and returns an interactive review board for the
77
human reviewer.
88

9-
## Usage
9+
## Skills
10+
11+
### review-pr
1012

1113
```text
1214
/pr-review-toolkit:review-pr <github-pr-url>
1315
```
1416

17+
Conduct a comprehensive PR review and return an interactive review board.
18+
See [Review Flow](#review-flow) below.
19+
20+
### address-pr-feedback
21+
22+
```text
23+
/pr-review-toolkit:address-pr-feedback [--interactive]
24+
```
25+
26+
Systematically collect, analyze, score, and address pull request review
27+
feedback from the current branch's PR. After implementing changes, drafts
28+
reply comments and posts them to GitHub with per-reply user approval.
29+
30+
By default, the skill auto-detects the open PR for the current branch and
31+
fetches all review comments via GitHub MCP. Use `--interactive` to manually
32+
paste feedback items instead.
33+
34+
**Flow:** branch validation &rarr; feedback collection &rarr; parallel
35+
analysis and scoring (Sonnet + Haiku agents) &rarr; per-item action
36+
confirmation &rarr; plan generation &rarr; implementation &rarr; reply
37+
posting.
38+
1539
## Review Flow
1640

1741
The skill parses a GitHub PR URL and launches the bundled workflow. The skill
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
---
2+
name: address-pr-feedback
3+
description: >-
4+
Systematically collect, analyze, score, and address pull request review
5+
feedback, then post reply comments
6+
disable-model-invocation: true
7+
user-invocable: true
8+
arguments: [--interactive]
9+
argument-hint: [--interactive]
10+
---
11+
12+
# Address PR Feedback
13+
14+
Systematically collect, analyze, score, and plan execution for pull request
15+
review feedback, then post reply comments to GitHub.
16+
17+
## Phase 0: Branch Validation
18+
19+
**Validate branch first:**
20+
21+
- Run `git branch --show-current` to get the current branch
22+
- Run `git ls-remote --symref origin HEAD 2>/dev/null | grep "^ref:" | awk '{print $2}' | sed 's|refs/heads/||'` to get the mainline branch
23+
- If the current branch matches the mainline branch:
24+
- Display: "Error: You're on the mainline branch. Please checkout a feature branch and retry this skill."
25+
- Stop execution
26+
27+
**Then ensure plan mode is active:**
28+
29+
- If plan mode is not already active, call `EnterPlanMode` and wait for user
30+
approval
31+
- If plan mode is already active (check for "Plan mode is active" in system
32+
context), proceed directly
33+
34+
## Phase 1: Feedback Collection
35+
36+
Check if the argument contains `--interactive`. If it does, use the
37+
**interactive collection** path. Otherwise, use the **auto-fetch** path.
38+
39+
### Auto-Fetch Path (Default)
40+
41+
1. **Detect PR from current branch:**
42+
- Run `git remote get-url origin` and extract owner/repo
43+
(strip protocol prefix, `.git` suffix, and hosting domain)
44+
- Run `git branch --show-current` to get the branch name
45+
- Determine if this is a fork workflow:
46+
- Run `git remote get-url upstream 2>/dev/null` — if it succeeds, this is
47+
a fork workflow; extract the upstream owner/repo
48+
- Find the open PR:
49+
- Fork workflow: use `list_pull_requests` with `state: "open"` and
50+
`head: "<fork-owner>:<branch>"`, scoped to the upstream owner/repo
51+
- Non-fork workflow: use `list_pull_requests` with `state: "open"` and
52+
`head: "<owner>:<branch>"`, scoped to the owner/repo
53+
- If no PR found, display:
54+
"Error: No open PR found for branch `<branch>`. Push and open a PR first,
55+
or use `--interactive` to paste feedback manually."
56+
- Stop execution if no PR found
57+
58+
2. **Fetch all comments** using `pull_request_read` on the found PR:
59+
- `get_reviews` — review bodies and review events
60+
- `get_review_comments` — inline review comments with threads
61+
- `get_comments` — issue-style conversation comments
62+
63+
Include all comments — no bot filtering, no trust filtering. The scoring
64+
phase handles relevance naturally.
65+
66+
3. **Normalize** each comment into a structured item:
67+
- `text` — comment body
68+
- `author` — GitHub username
69+
- `file` / `line` — file path and line number (inline comments only; null
70+
for others)
71+
- `commentId` — numeric comment ID (for reply posting)
72+
- `threadId` — thread node ID (inline comments) or null
73+
- `type``"review"` | `"inline"` | `"conversation"`
74+
75+
### Interactive Collection Path (`--interactive`)
76+
77+
Display: "Ready to accept feedback items. Say 'done' when finished."
78+
79+
Loop until user says "done":
80+
81+
1. Receive user input
82+
2. Launch Haiku agent to parse:
83+
- Fetch any GitHub comment URLs (use GitHub MCP tools)
84+
- Extract feedback text
85+
- Extract author (if available)
86+
- Extract file/line location (if available)
87+
- Normalize into structured format with `commentId`, `threadId`, and `type`
88+
fields (set to null if not available from pasted content)
89+
3. Acknowledge: "Recorded item [N]: [brief summary]"
90+
4. Continue loop
91+
92+
Store all items in conversation context.
93+
94+
## Phase 2: Analysis & Scoring
95+
96+
Before analyzing, **deduplicate related items.** Multiple comments often
97+
address the same underlying concern (e.g., two reviewers flag the same issue,
98+
or one reviewer comments on both the declaration and usage of the same
99+
problem). Group these into a single logical item — track all associated
100+
`commentId`/`threadId` values so replies can be posted to each thread in
101+
Phase 6.
102+
103+
**For 5 or fewer items**, analyze and score inline — the context is small
104+
enough that agents add latency without improving quality.
105+
106+
**For 6+ items, launch parallel Sonnet agents** (one per feedback item, or
107+
batched 3-5 items if many):
108+
109+
Each agent prompt:
110+
111+
```text
112+
Analyze this PR feedback item:
113+
[item details]
114+
115+
Read relevant code context (minimal - only affected files/lines).
116+
Check CLAUDE.md for applicable guidance.
117+
118+
Return:
119+
- Validity: Is this feedback correct and still applicable?
120+
- Impact: What's the practical effect? (bug/enhancement/style)
121+
- Effort: Implementation cost (S/M/L)
122+
- Guidance: Is it backed by CLAUDE.md or project standards?
123+
- Recommended action: Implement/modify/reject/discuss
124+
- Draft reply: Brief explanation for reviewer (e.g., "Addressed in
125+
[commit/location]" or "Fixed by [change description]")
126+
127+
Flag false positives:
128+
- Code no longer present
129+
- Already addressed in subsequent commits
130+
- Conflicts with other feedback items
131+
- Based on outdated PR state
132+
```
133+
134+
**Launch parallel Haiku agents** for scoring (one per item):
135+
136+
Each scoring agent receives the analysis and applies this rubric (0-100
137+
scale):
138+
139+
| Score | Interpretation |
140+
|-------|----------------|
141+
| 0-25 | Invalid: feedback doesn't apply, code doesn't have this issue, or already fixed; may be misunderstanding or based on outdated PR state |
142+
| 26-50 | Valid but minor: real issue but stylistic preference, nitpick, or low practical impact; not backed by project standards |
143+
| 51-75 | Important: verified real issue with practical impact; affects functionality or code quality meaningfully |
144+
| 76-100 | Critical: definitely correct, high impact, affects users or core functionality, or explicitly violates CLAUDE.md/standards |
145+
146+
**Scoring factors:**
147+
148+
- Validity (40%): Is feedback correct and still applicable to current code
149+
state?
150+
- Impact (30%): Practical effect on functionality, users, or code quality
151+
- Effort (20%): Implementation cost (inverse — lower effort = higher score
152+
contribution)
153+
- Guidance backing (10%): Explicitly mentioned in CLAUDE.md or project
154+
standards
155+
156+
Return score with rationale.
157+
158+
## Phase 3: Action Confirmation
159+
160+
Order items by score (highest first).
161+
162+
For each item, use `AskUserQuestion`:
163+
164+
```text
165+
Question: "Item [N]: [summary] - Score: [X] - Recommended: [action]. Confirm course of action?"
166+
Header: "Item [N]"
167+
Options:
168+
- "Implement as suggested" (description: Apply the feedback exactly as stated)
169+
- "Implement differently" (description: Address the concern but with a different approach - will specify)
170+
- "Reject" (description: Do not address this feedback - will provide reason)
171+
- "Discuss with reviewer" (description: Need clarification before deciding)
172+
```
173+
174+
Record confirmed action for each item.
175+
176+
## Phase 4: Plan Generation
177+
178+
Use Haiku agent to write plan file with this structure:
179+
180+
```markdown
181+
# PR Feedback Execution Plan
182+
183+
Total items: [count]
184+
185+
## Execution Instructions
186+
187+
**IMPORTANT:** Use TaskCreate to create a task for each item below FIRST before
188+
implementing any changes.
189+
190+
1. Create tasks for all items
191+
2. Implement in order (highest score first)
192+
3. Mark tasks complete as you go
193+
4. Verify all changes before re-requesting review
194+
195+
## Feedback Items
196+
197+
### Item 1: [summary]
198+
- **Score:** [X]
199+
- **Action:** [confirmed action]
200+
- **Files:** [affected files with paths]
201+
- **Implementation:**
202+
- [Step 1]
203+
- [Step 2]
204+
- [...]
205+
- **Draft reply:** [Brief comment explaining how this was addressed]
206+
207+
### Item 2: [summary]
208+
...
209+
210+
## Verification Checklist
211+
212+
- [ ] All tasks created via TaskCreate
213+
- [ ] All implementations complete
214+
- [ ] Tests pass
215+
- [ ] Code follows project standards
216+
- [ ] Ready for re-review
217+
```
218+
219+
## Phase 5: Exit Plan Mode
220+
221+
Call `ExitPlanMode` to signal planning is complete and request user approval.
222+
223+
After user approval, execution begins:
224+
225+
1. Tasks are created using TaskCreate
226+
2. Each item is implemented following the plan
227+
3. Tasks are marked complete as work progresses
228+
229+
## Phase 6: Reply Posting
230+
231+
After all implementation tasks are complete, iterate over each implemented
232+
item that has a draft reply.
233+
234+
For each item:
235+
236+
1. Present the draft reply text (generated in Phase 2, refined in Phase 4)
237+
2. Use `AskUserQuestion`:
238+
239+
```text
240+
Question: "Post this reply for Item [N]?"
241+
Header: "Reply [N]"
242+
Options:
243+
- "Post as-is" (description: Post the draft reply to the PR comment)
244+
- "Edit then post" (description: Modify the reply text before posting)
245+
- "Skip" (description: Do not post a reply for this item)
246+
```
247+
248+
3. If "Edit then post" is selected, receive the edited text from the user
249+
4. For approved replies, post via GitHub MCP:
250+
- Inline review comments (type `"inline"`, has `commentId`):
251+
use `add_reply_to_pull_request_comment` with the original `commentId`
252+
and `pullNumber`
253+
- Conversation comments (type `"conversation"` or `"review"`):
254+
use `add_issue_comment` on the PR number

0 commit comments

Comments
 (0)