Resolve pr comments

From benmatselby/dotfiles · View interactive version

Resolve pr comments is an AI agent skill from the GitHub repository benmatselby/dotfiles. Review open review comments on a GitHub PR, agree a fix with the user, apply the change, commit, push, and mark the thread resolved.

How to use this skill

Skill file

Resolve PR Review Comments

Review open review comments on a GitHub PR one at a time, agree a fix with the user, apply the change to the branch, commit, push to GitHub, and mark the comment thread as resolved.

Arguments

If no PR URL is provided, prompt the user to provide one.

Prerequisites

Workflow

1. Fetch open review comments

Use the gh CLI to fetch all review comments for the PR:

gh api repos/<owner>/<repo>/pulls/<number>/reviews/<review-id>/comments

Or fetch all review comments across all reviews:

gh api repos/<owner>/<repo>/pulls/<number>/comments

Only surface comments that are not yet resolved. To check resolution status, fetch the review threads via GraphQL:

gh api graphql -f query='
{
  repository(owner: "<owner>", name: "<repo>") {
    pullRequest(number: <number>) {
      reviewThreads(first: 20) {
        nodes {
          id
          isResolved
          comments(first: 1) {
            nodes {
              databaseId
              body
            }
          }
        }
      }
    }
  }
}'

Filter to threads where isResolved: false.

If no unresolved comments are found, report "No open review comments" and exit.

2. Present comments to the user

Summarise each unresolved comment clearly:

Ask the user to confirm the approach before making any changes. Work through comments one at a time unless the user asks to handle multiple at once.

3. Check out the PR branch

gh pr checkout <PR-URL>

Note: gh pr checkout may leave you in a detached HEAD state if the branch is from a fork. Check with git status and identify the correct remote and branch name for pushing later.

4. Apply the fix

Make the agreed code change. Do not commit yet — let the user verify if needed.

5. Commit and push

git add <changed files>
git commit -m "<message>"

After committing, check git status for the push target. If in detached HEAD state, push explicitly:

git push <remote> HEAD:refs/heads/<branch-name>

Identify the correct remote by running git remote -v — push to the upstream org remote (not a personal fork) unless the PR originates from a fork.

6. Resolve the thread

Use the GraphQL resolveReviewThread mutation with the thread's node ID (obtained in step 1):

gh api graphql -f query='
mutation {
  resolveReviewThread(input: {threadId: "<thread-node-id>"}) {
    thread {
      isResolved
    }
  }
}'

Confirm the response shows "isResolved": true. Prefix any replies with [AI generated response] to indicate the comment was addressed by the AI.

7. Report back

Tell the user:

Then move on to the next unresolved comment (if any), repeating from step 2.

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.