/address-pr-comments:address-pr-comments [PR number or owner/repo#N] [more PRs...]from address-pr-comments
Automates end-to-end closeout of unresolved GitHub PR review feedback: checks out branches, fetches blocking feedback, verifies against current code, fixes findings with signed-off commits, posts replies, and moves to the next PR.
Ships in address-pr-comments. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
CRITICAL: This skill makes PUBLIC changes — commits pushed to the PR branch and replies visible to the PR author, reviewers, and all watchers. Every commit must follow project conventions (signed off, GPG-signed where configured, conventional message). Every reply must be accurate, justified, and in English.
Parse $ARGUMENTS as a space-separated list of PR refs.
2395, uses the repo from gh repo view --json owner,name) OR owner/repo#N (e.g. cozystack/cozystack#2395).gh pr view --json number,headRepositoryOwner,headRepository --jq '.headRepositoryOwner.login + "/" + .headRepository.name + "#" + (.number|tostring)' — single-PR mode.Normalize each ref into OWNER, REPO, PR_NUMBER.
Before touching any PR branch:
ORIGINAL_REF=$(git symbolic-ref --quiet --short HEAD || git rev-parse HEAD)
if [ -z "$(git status --porcelain)" ]; then CLEAN_START=1; else CLEAN_START=0; fi
ORIGINAL_REF is the branch to return to at the end.CLEAN_START == 1 means the working tree was clean — safe to restore later.git checkout.For each PR ref in the parsed list, execute Steps 2–10 in order. Between PRs, print a visible separator (e.g. ────── PR #N ──────) so progress is easy to follow.
On a per-PR unrecoverable error (PR not found, branch push rejected and user chose not to force, etc.): print the error, skip the remaining steps for that PR, continue with the next ref. Do not abort the whole run.
PR_BRANCH=$(gh pr view $PR_NUMBER --repo $OWNER/$REPO --json headRefName --jq .headRefName)
git fetch origin "$PR_BRANCH"
git checkout "$PR_BRANCH"
git log --oneline -5
Worktree guard: if git checkout fails with fatal: '<branch>' is already used by worktree at <path>, parse the path, cd into that worktree, and run the rest of the PR's steps there. Do not delete or force anything.
Scan the repo for agent-facing contribution rules and follow them exactly. Common locations:
AGENTS.md, docs/agents/contributing.md, docs/agents/*.mdCONTRIBUTING.md (look for "review comments" / "AI bot" / "commit format" sections)Project rules OVERRIDE this skill's defaults — e.g. commit message format, reply etiquette, threads to ignore, whether a separate commit per thread is required.
Three GitHub objects can carry blocking feedback on a PR. The skill must read all three:
reviewThreads) — comments attached to a file/line, repliable via addPullRequestReviewThreadReply.reviews[].body) — the freeform text a reviewer types when they click Approve / Request changes / Comment. They have no threadId and are not part of reviewThreads. A CHANGES_REQUESTED review with only a body and zero inline comments is the most-common cause of a PR being blocked without any thread to reply to. Missing this source = silently ignoring the reviewer.Also pull reviewDecision so the skill knows when the PR is blocked but no findings remain after filtering — that almost always means a finding was missed.
SELF_LOGIN=$(gh api user --jq .login)
gh api graphql -F owner="$OWNER" -F repo="$REPO" -F pr=$PR_NUMBER -f query='
query($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviewDecision
reviewThreads(first: 100) {
pageInfo { hasNextPage endCursor }
nodes {
id
isResolved
isOutdated
comments(first: 100) {
pageInfo { hasNextPage }
nodes {
id
path
line
originalLine
author { login }
bodyText
url
createdAt
}
}
latestComment: comments(last: 1) {
nodes {
author { login }
createdAt
}
}
}
}
reviews(first: 100, states: [CHANGES_REQUESTED, COMMENTED]) {
pageInfo { hasNextPage endCursor }
nodes {
id
state
body
author { login }
submittedAt
url
commit { oid }
comments(first: 1) { totalCount }
}
}
}
}
}'
Filter:
isResolved == false.latestComment.nodes[0].author.login == $SELF_LOGIN. This prevents duplicate replies on re-runs against PRs with reviewers that do not auto-resolve threads after a fix lands (e.g. Gemini Code Assist). Empty latestComment.nodes is treated as "not me" and the thread is kept. To genuinely re-engage a previously-replied thread, the operator posts the reply manually outside the skill flow.state == "CHANGES_REQUESTED" (always, even with empty body — surface as ASK so the user explains the block). For state == "COMMENTED", keep only if body != "" AND comments.totalCount == 0 (a COMMENTED review with inline comments is already covered by the threads query; its body is usually a meta-summary).gh api "repos/$OWNER/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | {id, author: .user.login, body, url}'
If reviewDecision == "CHANGES_REQUESTED" but no surviving threads or review-submission bodies remain after filtering, stop and ask the user — the PR is blocked but the skill found nothing actionable. Most likely a thread was missed (pagination, an unusual state, dismissed review) and proceeding would close out the PR while ignoring the actual blocker.
Treat each surviving thread AND each surviving review-submission body as a separate finding. For each finding, record:
kind ("thread" or "review_body"), author.login, body text, url, timestamp.threadId, path, line (or originalLine when line is null), isOutdated.reviewId, state, commit.oid (the commit the review was filed against — useful for diffing what changed since).Pagination guard: if any of the three queries returns exactly 100 nodes, or any thread has exactly 100 comments, the data was truncated. Either paginate via pageInfo.hasNextPage/endCursor or warn the user and ask whether to proceed on partial data.
MANDATORY — do not skip. Reviewer bots hallucinate. Code often evolved after a comment was posted. Blindly applying suggestions or replying "fixed" without checking damages trust.
For each finding:
line is null (outdated), use originalLine as a starting point and locate the code by context.commit.oid to see what changed since the review was filed).Assign one verdict per thread:
For every ASK finding: pause before Step 6 and ask the user via AskUserQuestion — present the finding (author + quote + kind), your evidence, and the candidate verdicts. Let the user decide. Proceed only after the user's answer.
Keep an internal table of (findingId, kind, verdict, evidence) where findingId is threadId for thread findings or reviewId for review-body findings — the user will see it during the approval step.
For each FIX verdict, in the order threads were fetched:
Edit the file(s) needed to address THIS one thread only.
Fast checks: if the project has a fast command (go build ./..., tsc --noEmit, cargo check, markdownlint, etc.), run it. Run relevant tests if they are cheap.
Stage only the files touched for this thread: git add <paths>.
Commit with project conventions discovered in Step 3. Default template when the project uses Conventional Commits:
<type>(<scope>): <short summary tied to the thread>
Address review feedback from <author.login> on <path>:<line>:
<one-sentence description of the fix>
Use git commit --signoff with full-flag form. If the repository has GPG signing configured, respect it — NEVER pass --no-gpg-sign or otherwise bypass signing. If signing prompts for a PIN, WAIT for the user rather than working around it.
Push immediately: git push origin <branch>. If the push is rejected (branch diverged, non-fast-forward), stop this PR, report the error, and ask the user how to proceed (rebase, force-push, or skip). Do not force-push without explicit approval.
Record the commit SHA returned by git rev-parse HEAD — the reply draft will reference it.
For ALREADY FIXED, WONTFIX, DEFER: no commit, no push — only a reply draft.
If commit or push fails in a way that cannot be recovered (signing timeout, conflict, rejected push with user declining a fix): print a clear error and skip to the next PR.
One reply per thread. Rules:
ConvertHelmReleaseToApplicationWithMonitor, not "the conversion function").90a9d6e9). One short paragraph.Show the user, in a single message:
git log <base>..HEAD --oneline showing the commits just pushed.Ask explicitly: "Post all replies for PR #N?". Wait for confirmation. If the user asks for changes to specific drafts, edit only those and re-present before posting.
Commits have already been pushed by this point — the approval gate is specifically for the public reply text.
Branch on the finding kind. Write each reply body to a temp file first to avoid shell-escaping issues.
Thread findings — reply attached to the correct thread via addPullRequestReviewThreadReply:
cat > /tmp/reply.txt << 'EOF'
<reply body — EOF-quoted so no interpolation>
EOF
gh api graphql \
-f threadId="<PRRT_…>" \
-F body="@/tmp/reply.txt" \
-f query='
mutation($threadId: ID!, $body: String!) {
addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: $threadId, body: $body}) {
comment { url }
}
}' --jq '.data.addPullRequestReviewThreadReply.comment.url'
rm -f /tmp/reply.txt
Review-body findings — there is no threadId to reply on. Post a top-level PR comment that opens with an @<reviewer> mention so the reviewer is notified:
cat > /tmp/reply.txt << 'EOF'
@<reviewer> <reply body referencing the addressing commit SHA(s)>
EOF
gh pr comment "$PR_NUMBER" --repo "$OWNER/$REPO" --body-file /tmp/reply.txt
rm -f /tmp/reply.txt
Post replies sequentially (not in parallel — parallel posts can race and hit rate limits). Collect the returned URLs for the final report.
Print for this PR:
Then proceed to the next PR ref (back to Step 2).
After the final PR:
if [ "$CLEAN_START" = "1" ]; then
git checkout "$ORIGINAL_REF"
else
echo "Staying on current branch — working tree was dirty at start."
fi
Print the multi-PR final summary: one block per PR with its counts, pushed commits, and reply URLs. Close with a reminder of the current branch.
Do not resolve threads automatically. The reviewer (human or bot) decides whether a thread is resolved based on the reply and pushed commits.
CHANGES_REQUESTED review with only a freeform body and no inline comments is still a blocker. Step 4 reads inline threads, review-submission bodies, AND issue comments, and verifies reviewDecision. Skipping any source means silently ignoring the reviewer.--no-gpg-sign or disable commit.gpgsign. If signing prompts for a PIN, WAIT — do not work around it.AskUserQuestion before committing anything. Do not guess on contested threads.resolveReviewThread. That is the reviewer's prerogative.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pr-review, code-review, github-automation, feedback-resolution
npx claudepluginhub lexfrei/ccc --plugin address-pr-commentsOther plugins' skills for the same job