|
| 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