| description | Walk through unresolved PR review comments one at a time for the PR on the current branch β evaluate, optionally fix, draft a reply, then prompt the user for the final reply text and whether to resolve before posting both to GitHub. | |---|
$ARGUMENTS
Consider the user input before proceeding (if not empty). It may name a specific comment author, file, or thread to focus on β narrow the loop accordingly.
Run in parallel:
git branch --show-current
β must not bemain
ormaster
.gh auth status
β must be authenticated.
If either fails, stop and tell the user what to fix.
Run the helper script:
.claude/skills/address-pr-comments/scripts/fetch-pr-comments.sh
It auto-detects the repo + PR for the current branch and emits JSON of the shape:
{
"pr_number": 123,
"repo": "owner/name",
"threads": [
{
"thread_id": "PRRT_...",
"comment_database_id": 1234567,
"path": "app/foo.py",
"line": 42,
"author": "reviewer",
"body": "...",
"diff_hunk": "...",
"url": "https://github.com/..."
}
]
}
If threads
is empty, report "No unresolved review comments on PR #N" and stop β do not invent work.
Print Found N unresolved thread(s) on PR #X
and a one-line preview per thread (@author at path:line β first line of body
) so the user knows what's coming.
For each thread in order:
Print a header and the comment verbatim:
βββ Comment N/M βββ @author at path:line βββ
<quoted body>
<url>
Use Read
on the file at path
around line
(Β±10 lines) so the evaluation reflects the code as it is now, not as it was when the review was written.
In 1β3 sentences, state whether a code change is needed and why, referencing the current file state. Be explicit when the comment is already addressed by a later commit ("already fixed in 8c3ca9e β no further change needed").
Propose the edit in one sentence (e.g. "Apply: extract the URL-encoding into a helper in app/lib/s3.py
?"). On confirmation, use Edit
to apply it.
One short sentence. If a fix was applied, reference what changed in plain language ("Good catch β extracted the validator into helpers.py
."). If no fix, explain why ("Intentional β the upstream service guarantees non-null here.").
Invoke AskUserQuestion with two questions in a single call:
"Reply text?"β options:Use drafted reply
,Custom
(user selects "Other" and types)."Resolve this thread?"β options:Yes
,No
.
gh api -X POST "repos/$REPO/pulls/$PR_NUMBER/comments/$COMMENT_DATABASE_ID/replies" \
-f body="$REPLY"
$COMMENT_DATABASE_ID
is the integer comment_database_id
from the JSON β not the GraphQL node ID.
gh api graphql \
-f query='mutation($id: ID!) { resolveReviewThread(input: {threadId: $id}) { thread { id isResolved } } }' \
-f id="$THREAD_ID"
$THREAD_ID
is the PRRT_...
thread_id
from the JSON.
Draft a one-line commit message (conventional-commit style β e.g. fix: extract URL-encoding helper for S3 paths
). Show it to the user verbatim and ask via AskUserQuestion
:
"Commit and push this fix?"β options:Use drafted message
,Custom
(user selects "Other" and types),Skip
.
On approval, run:
git add <edited files>
git commit -m "$MESSAGE"
git push
Do not append Co-Authored-By
or any signature β the commit body is the approved message text only, nothing else. Never use --no-verify
or --amend
.
Report:
- Threads replied to: N
- Threads resolved: M
- Commits pushed: list short SHAs + messages
- Files edited but not committed (skipped at 4i): list them
If any edits were skipped at 4i, remind the user to commit them (/commit
skill is available in this repo).
Never commit or push without explicit per-thread approval in step 4i. Never--amend
.Never addCo-Authored-By
or any signature line to commit messages β body is the approved text only.Never use--no-verify
or bypass hooks.Always show the proposed code edit before applying it.One thread at a time. Do not batchAskUserQuestion
prompts across threads β the user wants to see and decide per comment.- If the script returns zero threads, exit cleanly. Do not search for other comment sources.
- The reply uses the
integercomment ID (
comment_database_id
); the resolve mutation uses thePRRT_...
nodeID (thread_id
). Mixing them up will 404 / fail GraphQL validation.