Address GitHub PR review comments with commits
Addresses GitHub PR review comments by creating commits for each fix and resolving threads.
/plugin marketplace add tenzir/claude-plugins/plugin install docs@tenzir[pr-number]Work through GitHub PR review comments, creating one commit per comment (or group of related comments), then reply with the commit SHA and resolve the thread.
If a PR number was provided, use it. Otherwise, get the PR for the current branch:
gh pr view --json number --jq '.number'
If no PR exists for the current branch, report and stop.
Get all unresolved review threads using GraphQL:
gh api graphql -f query='
{
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 50) {
nodes {
id
isResolved
comments(first: 10) {
nodes {
body
path
line
startLine
}
}
}
}
}
}
}'
When startLine is present (not null), the comment applies to a range from
startLine to line (inclusive). This typically indicates the reviewer
selected multiple lines when adding the comment.
Extract owner and repo from gh repo view --json owner,name.
If all threads are resolved, report "No unresolved comments" and stop.
Analyze the unresolved comments and group them if they share a common theme:
Present the grouping to the user for confirmation before proceeding.
For each comment or group of comments:
Read the referenced file(s) and understand the requested change. If the comment
includes a suggestion code block, that's the exact change requested.
If the comment is unclear or seems incorrect, use AskUserQuestion to ask the
user how to proceed:
Apply the requested changes to the file(s).
Use the @git:committer agent to commit the fix, then push immediately:
git push
Reply to the thread with the commit SHA:
gh api graphql -f query='
mutation {
addPullRequestReviewThreadReply(input: {
pullRequestReviewThreadId: "THREAD_ID"
body: "Addressed in COMMIT_SHA."
}) { comment { id } }
}'
If the fix clearly addresses the comment, resolve the thread:
gh api graphql -f query='
mutation {
resolveReviewThread(input: {
threadId: "THREAD_ID"
}) { thread { isResolved } }
}'
If you're unsure whether the fix fully addresses the comment, ask the user whether to resolve it.
Report: