# Claude skill to address PR comments

> Source: <https://gist.github.com/samuel1992/65de47a7bf34e7f04dd6a08fcf93beb7>
> Published: 2026-05-28 22:36:43+00:00

| 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 be`main`

or`master`

.`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** add`Co-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 batch`AskUserQuestion`

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
*integer*comment ID (`comment_database_id`

); the resolve mutation uses the`PRRT_...`

*node*ID (`thread_id`

). Mixing them up will 404 / fail GraphQL validation.
