name: pr-pending-feedback description: Evaluate pending (unsubmitted) review comments on the current branch's PR and, after user confirmation, address each in a separate sub-agent and separate commit. user-invocable-only: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write, Agent
pr-pending-feedback — Triage and address pending PR review comments
The goal: look at every comment on the pending (unsubmitted) review the current user has drafted on the PR for the current branch, evaluate each one independently, split them into ones that can simply be addressed and ones that need discussion, work through the discussion comments one at a time, and — only after all discussions are resolved and the user confirms — dispatch a sub-agent per comment to fix it, one commit per comment.
These comments are the user's own. Never recommend skipping a comment. Every comment either gets addressed directly, or — if there's any ambiguity, subjectivity, design call, or doubt about applicability — gets opened up for discussion so the user can decide. "Skip" is only ever an outcome the user explicitly chooses during discussion, never something this skill proposes on its own.
Pending reviews are private to their author until submitted, so this skill only sees comments authored by the currently authenticated gh user.
Step 1: Find the PR for the current branch
pr_number=$(gh pr view --json number --jq .number)
pr_url=$(gh pr view --json url --jq .url)
repo=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
base_branch=$(gh pr view --json baseRefName --jq .baseRefName)
me=$(gh api user --jq .login)
If gh pr view fails, stop and tell the user there is no open PR for the current branch.
Step 2: Find the pending review
List reviews on the PR and find one in PENDING state authored by the current user:
gh api "repos/$repo/pulls/$pr_number/reviews" --jq \
".[] | select(.state==\"PENDING\" and .user.login==\"$me\") | {id, body, submitted_at, html_url}"
If there is no pending review, stop and tell the user there is no pending review on this PR for them. If there are multiple pending reviews (rare), list them and ask which to use.
Capture the id as review_id.
Step 3: Fetch the pending review's comments
gh api "repos/$repo/pulls/$pr_number/reviews/$review_id/comments"
Each comment includes path, line (or original_line), body, diff_hunk, and html_url. Also note the pending review's top-level body from Step 2 — it may contain general feedback worth addressing too.
Step 4: Evaluate each comment independently
For each pending comment, read the referenced file(s) at the relevant lines to understand the current code. Then classify it as exactly one of:
address— clearly actionable, unambiguous, and you're confident how to do it. It can be acted on without further input.discuss— anything else. If the comment is ambiguous, subjective, a design call, possibly stale/already-done, out of scope, or you have any doubt about whether or how to act on it, it needs the user's input first.
Never classify a comment as skip. These are the user's own comments — if you think one might not be worth doing, that is itself a reason to discuss it, not to skip it. Skipping is only ever a decision the user makes during the discussion in Step 5.
For every address comment (and any discuss comment the user resolves into an action in Step 5), also tag how it will be handled:
simple— a localized, mechanical, single-location change with no branch-wide pattern implications and no test reasoning needed (e.g. a typo, a rename at one site, a small wording tweak, an obvious guard clause). These are handled inline in the main loop withEdit(Step 7), no sub-agent.involved— anything that articulates a general rule to apply branch-wide, touches multiple files, needs judgment, or requires running/reasoning about tests. These get a dedicated sub-agent (Step 7).
When in doubt between simple and involved, treat it as involved.
Evaluate each comment on its own merits; do not let one comment's classification influence another's.
Do not present any triage table or list at this stage. Do not show the user the full set of comments yet. Move straight on to working through the discussion comments.
Step 5: Work through discussion comments one at a time
For each comment classified as discuss, ask the user about it one question at a time — present a single comment, wait for the reply, then move to the next. Do not batch them.
For each discussion comment, present:
- The comment body (quoted) and a clickable link to it.
- The file:line and the relevant code snippet for context (the lines the comment refers to — pull from the actual file, falling back to the
diff_hunkif needed). Always include this so the user has the context in front of them. - A short framing of what needs deciding.
- A numbered list of plain-text options for how to proceed (e.g.
1.address it a particular way,2.address it a different way,3.skip it, etc.). Always include skipping as one of the numbered options when it's a sensible choice. - Explicitly state which option you recommend and why, in one sentence.
Per the user's global preference, present the options as a numbered plain-text list. Do not use the AskUserQuestion tool — print the question as normal output and end your turn so the user can reply in their own words.
Stop and wait for the user's reply after each discussion comment before moving to the next one. Record the resolution for each (address in a specific way, or skip).
If there are no discussion comments, skip straight to Step 6.
Step 6: Present the consolidated plan
Only after every discussion comment has been resolved, present a single consolidated list/table of all comments and how each will be handled:
- A short label (e.g.
#1,#2). - The file:line (or "general" for the review body).
- A 1-line summary of the ask.
- How it will be handled: address (with any specifics decided during discussion) or skip (per the user's decision in Step 5). For each address comment, note whether it'll be done inline (simple) or via a sub-agent (involved).
- A clickable link to the comment.
End with a plain-text prompt like:
This is the plan. Reply to confirm and I'll address each comment — simple ones inline, involved ones via a sub-agent — committing each fix separately. Let me know if you want to change anything.
Stop and wait for the user's reply. Do not proceed to Step 7 without explicit confirmation. Do not use the AskUserQuestion tool for this — just print the prompt as normal output and end your turn so the user can reply in their own words.
Step 7: Address each confirmed comment
Work through the comments the user confirmed to address (skipped comments are left alone) sequentially, not in parallel — each creates a commit on the same branch, and parallel edits would conflict. Handle each according to its simple/involved tag from Step 4:
- Simple comments — handle inline in the main loop with
Edit. Make the smallest change that addresses the comment, then create exactly one git commit for it (same commit discipline as a sub-agent: one commit per comment, concise message, no ticket prefix, do not push). The same comment-discipline rule applies: do not add code comments explaining the change or that it was made in response to the review. If, once you look closely, a "simple" comment turns out to imply a branch-wide pattern or otherwise isn't trivial after all, escalate it to a sub-agent instead. - Involved comments — dispatch a separate sub-agent via the Agent tool (see below).
Either way, the result is one commit per addressed comment, so the final report (Step 8) is the same regardless of how each was handled.
For involved comments, the prompt for each sub-agent should include:
- The current working directory (per project convention).
- The PR URL and comment URL.
- The file path and line.
- The comment body.
- The diff hunk showing the code in question.
- A clear instruction: "Make the smallest change that addresses this comment. Run the relevant tests. Then create a single git commit with a message summarizing the fix. Do not push. Do not address other feedback."
- An instruction to apply the feedback branch-wide, not only at the commented location: if the comment articulates a general rule or pattern (e.g. "always use
order.sc_idinstead oforder.id", "preferFoo.baroverFoo.baz", "rename X to Y"), search the entire diff on the current branch for other instances of the same pattern and apply the same change there too. Pass the PR's actual base branch ($base_branchfrom Step 1 — may not bemain, e.g. for stacked PRs) and tell the sub-agent to usegit diff <base_branch>...HEADto scope the search to lines this branch introduced or touched. Do not modify code outside the branch's diff. - An instruction on comment discipline: do not add code comments that explain the change itself or why it was made in response to this review. Only add a comment if it clarifies confusing code, a non-obvious edge case, or genuinely complex behavior for a future reader who has no knowledge of this PR. Do not comment obvious code.
Example skeleton:
Agent({
subagent_type: "general-purpose",
description: "Address pending comment #<n>",
prompt: "Working directory: <cwd>.\n\nAddress this pending PR review comment (drafted by the user themself, not yet submitted):\n\n<comment body>\n\nFile: <path>:<line>\nComment URL: <url>\nPR: <pr_url>\n\nDiff hunk for context:\n<diffHunk>\n\nMake the smallest change that resolves the feedback. If the comment expresses a general rule or pattern (not just a one-off fix at this line), also apply it to any other matching instances within this branch's diff against its base branch (use `git diff <base_branch>...HEAD` with the PR's actual base branch substituted in to find the touched code). Do not modify code outside this branch's diff. Do not add code comments that explain this change or why it was made in response to the review. Only add a comment if it clarifies confusing code, a non-obvious edge case, or complex behavior for a reader unaware of this PR; never comment obvious code. Run the relevant tests for the changed files. Create exactly one git commit with a concise message (no ticket prefix — this isn't the first commit of the branch, per the repo's git conventions). Do not push. Do not address any other feedback. Report back with the commit SHA and a one-line summary."
})
After each comment is addressed — inline or by a sub-agent — verify with git log --oneline -1 that a new commit landed, then proceed to the next.
If a comment can't be addressed (e.g. tests failed, or a sub-agent reports unclear intent), stop and surface the problem to the user before continuing with remaining comments.
Step 8: Final report
After all comments are addressed, output a summary:
- List of commits created (SHA + subject), one per addressed comment.
- Any comments skipped per the user's decisions during discussion.
- Any comments that failed and need the user's attention.
- A reminder that the pending review is still pending on GitHub — addressing the comments locally does not submit or delete the draft.
- Reminder to push commits when ready (do not push automatically).
Step 9: Offer to update the PR description (author only)
Addressing feedback often changes what the PR does, leaving its description out of date. Offer to fix that — but only if both of these hold:
- The current user is the PR author. Compare the PR author to the authenticated user:
Ifpr_author=$(gh pr view --json author --jq .author.login)$pr_author!=$me, skip this step entirely — do not offer, do not mention it. - The description is actually out of date. Read the current description (
gh pr view --json body --jq .body) and compare it against the changes just made in Step 7. If everything the description says still holds and nothing it should mention is now missing, the description is up to date — skip this step silently. Only proceed if a confirmed fix made a concrete claim in the description wrong, incomplete, or misleading.
If both hold, propose a minimal edit: the smallest set of changes that brings the description back in line with the code — fix the specific sentences/bullets that the addressed comments invalidated, and add anything now missing. Do not rewrite, restructure, or restyle the description; leave everything still-accurate untouched.
Show the user the proposed new description (or a diff of just the changed lines) and ask a single plain-text yes/no question, e.g.:
Addressing the feedback made the PR description out of date. Here's a minimal update — apply it? (yes/no)
Wait for explicit confirmation. Do not use the AskUserQuestion tool — print the prompt as normal output and end your turn. If the user confirms, apply it:
gh pr edit "$pr_number" --body "<updated description>"
Screenshots: if the description embeds screenshots (e.g.  images, or an attachments/screenshots section) and any addressed comment changed UI or other visible output those screenshots likely depict, you cannot regenerate them — so just remind the user to re-capture and re-upload them, naming the specific screenshots that are probably now stale. Skip this reminder when the addressed comments didn't change anything the screenshots would show.
Step 10: Offer to delete the pending comments
Ask the user a single yes/no question, choosing the wording based on whether the whole review can be deleted cleanly. The review can be deleted cleanly only if every comment in the pending review was addressed — i.e. nothing was skipped during discussion, and no un-addressed comments exist (e.g. comments added since, or the review body left un-actioned).
If all comments were addressed, offer to delete the whole review:
All comments were addressed. Do you want to delete the pending review? (yes/no)
If some comments were skipped or otherwise left un-addressed, offer to delete only the addressed ones (leaving the rest pending):
Do you want to delete the addressed comments? (yes/no — the skipped/un-addressed ones will stay pending.)
Wait for explicit confirmation. Do not delete anything without the user saying so. Do not use the AskUserQuestion tool for this — print the prompt as normal output and end your turn so the user can reply in their own words.
If the user confirms, delete accordingly:
- If all comments were addressed and the user said yes, delete the entire pending review:
gh api -X DELETE "repos/$repo/pulls/$pr_number/reviews/$review_id" - If only the addressed comments should go (some were skipped/un-addressed) and the user said yes, delete those individual comments and leave the rest pending:
gh api -X DELETE "repos/$repo/pulls/comments/<comment_id>"
Never delete a comment the user chose not to address — those must remain pending. Only delete the whole review when every comment in it was addressed.
After deletion, report which comments/reviews were deleted.
Notes
- This skill only operates on pending reviews authored by the current
gh-authenticated user. Pending reviews by others are not visible via the API. - Never submit the pending review from this skill — leave submission to the user.
- Only delete pending comments or the pending review after explicit user confirmation in Step 10.
- Never push or force-push.
- Respect the project's git conventions from
CLAUDE.md(e.g.Chore:prefix for non-user-facing changes, no ticket code on subsequent commits, one thing per commit).