| name | github-pr-review |
|---|---|
| description | GitHub Pull Request review operations skill. Retrieve PR info, view diffs, get/post comments, add inline comments, submit reviews (approve/request-changes/comment), check CI status, and reply to comments using gh CLI. Use for PR review, code review, and PR operations. |
Source: Based on Claude CodeでPRレビュー操作を行うスキルを作った by shibayu36
This skill provides comprehensive PR review capabilities using GitHub CLI (gh).
Retrieve PR metadata including title, description, author, and branch info:
gh pr view NUMBER --repo OWNER/REPO --json title,body,author,state,baseRefName,headRefName,url,filesCheck the status of CI/CD checks on a PR before reviewing:
gh pr checks NUMBER --repo OWNER/REPO # status of all checks
gh pr status # PRs related to current userGet diff with both LEFT (base) and RIGHT (head) line numbers for precise inline commenting.
Preferred: use the bundled helper script (POSIX awk, works on macOS BSD awk):
bash $CLAUDE_PLUGIN_ROOT/scripts/diff-with-line-numbers.sh PR_NUMBER REPOIf $CLAUDE_PLUGIN_ROOT is not set, use the absolute path:
~/.claude/skills/github-pr-review/scripts/diff-with-line-numbers.sh
Filter to specific file(s):
# List changed files only
gh pr diff NUMBER --repo OWNER/REPO --name-only
# Diff for a single file
bash .../diff-with-line-numbers.sh NUMBER REPO -- path/to/file.pyInline (one-shot) equivalent, in case the helper isn't available:
gh pr diff NUMBER --repo OWNER/REPO | awk '
/^diff --git/ { print "\n=== " $0 " ==="; next }
/^@@/ {
# Parse "@@ -OLD_START,OLD_COUNT +NEW_START,NEW_COUNT @@"
# POSIX awk — no gawk match() capture groups, works on macOS BSD awk.
old_str = $2; sub(/^-/, "", old_str); sub(/,.*/, "", old_str)
new_str = $3; sub(/^\+/, "", new_str); sub(/,.*/, "", new_str)
old_line = old_str + 0
new_line = new_str + 0
print $0
next
}
/^-/ { printf "L%-4d | %s\n", old_line++, $0; next }
/^\+/ { printf " R%-4d| %s\n", new_line++, $0; next }
/^ / { printf "L%-4d R%-4d| %s\n", old_line++, new_line++, $0; next }
{ print }
'Output format:
L[num]: Line number on base branch (LEFT side) — for deleted/unchanged linesR[num]: Line number on head branch (RIGHT side) — for added/unchanged lines
Important: GitHub API paginates at 30 items by default. Use --paginate to fetch all comments on PRs with many reviews — otherwise you'll silently miss content.
Get issue-level comments (general PR comments):
gh api --paginate repos/OWNER/REPO/issues/NUMBER/comments \
--jq '.[] | {id, user: .user.login, created_at, body}'Get review comments (inline code comments):
gh api --paginate repos/OWNER/REPO/pulls/NUMBER/comments \
--jq '.[] | {id, user: .user.login, path, line, created_at, body, in_reply_to_id}'Add a general comment to the PR:
gh pr comment NUMBER --repo OWNER/REPO --body "Your comment here"First, get the head commit SHA:
gh api repos/OWNER/REPO/pulls/NUMBER --jq '.head.sha'Single-line inline comment:
gh api repos/OWNER/REPO/pulls/NUMBER/comments \
--method POST \
-f body="Your comment here" \
-f commit_id="COMMIT_SHA" \
-f path="path/to/file.py" \
-F line=15 \
-f side=RIGHTMulti-line inline comment (e.g., lines 10-15):
gh api repos/OWNER/REPO/pulls/NUMBER/comments \
--method POST \
-f body="Your comment here" \
-f commit_id="COMMIT_SHA" \
-f path="path/to/file.py" \
-F line=15 \
-f side=RIGHT \
-F start_line=10 \
-f start_side=RIGHTFile-level comment (whole file, no specific line):
Use subject_type=file and omit line/side. Useful for comments like "delete this file" or "split this module":
gh api repos/OWNER/REPO/pulls/NUMBER/comments \
--method POST \
-f body="Consider splitting this file into smaller modules." \
-f commit_id="COMMIT_SHA" \
-f path="path/to/file.py" \
-f subject_type=fileReply to a specific existing comment:
gh api repos/OWNER/REPO/pulls/NUMBER/comments/COMMENT_ID/replies \
--method POST \
-f body="Your reply here"After leaving inline comments, submit a PR-level review verdict:
# Approve
gh pr review NUMBER --repo OWNER/REPO --approve --body "LGTM"
# Request changes (use sparingly — prefer inline comments + comment review)
gh pr review NUMBER --repo OWNER/REPO --request-changes --body "See inline comments"
# Comment review (neutral — no approval, no block)
gh pr review NUMBER --repo OWNER/REPO --comment --body "A few questions inline"Confirm the review state:
gh pr view NUMBER --repo OWNER/REPO --json reviewDecision,latestReviewsAdd an emoji reaction (👍, 🚀, 👀, etc.) instead of a text reply:
# React to an issue-level comment
gh api repos/OWNER/REPO/issues/comments/COMMENT_ID/reactions \
--method POST \
-f content=+1 # +1, -1, laugh, confused, heart, hooray, rocket, eyes
# React to an inline review comment
gh api repos/OWNER/REPO/pulls/comments/COMMENT_ID/reactions \
--method POST \
-f content=rocketThe GitHub API rejects POST .../pulls/NUMBER/comments with 422 line could not be resolved when the target line is not present in the PR diff — i.e., it's neither a changed line nor a context line shown inside an @@ hunk. If you hit this:
- Verify the line number using the helper script in §3 — only
L[num](deleted/context) andR[num](added/context) rows are commentable. - Pick the closest related changed/context line and reference the actual location in the body, or
- Use a file-level comment (
subject_type=file, see §6) when no nearby diff line exists, or - Fall back to a general PR comment (§5).
-F(uppercase): Use for numeric/boolean values (line,start_line).-f(lowercase): Use for string values (body,commit_id,path,side,subject_type,content).
Using -f for line numbers will cause errors because it treats values as strings.
side=LEFT: Comment on base branch (deleted or unchanged lines, useL[num]).side=RIGHT: Comment on head branch (added or unchanged lines, useR[num]).
Inside a checked-out repo, --repo OWNER/REPO is optional — gh reads the remote. Specify it explicitly when working across multiple repos or when running from outside a checkout.
| Variable | Description |
|---|---|
OWNER |
Repository owner (e.g., octocat) |
REPO |
Repository name (e.g., Hello-World) |
NUMBER |
PR number |
COMMIT_SHA |
Head commit SHA (get via API) |
COMMENT_ID |
ID of comment to reply to or react to |
gh pr view NUMBER --json title,body,url,files— read PR overview.gh pr checks NUMBER— confirm CI is green before deep review.bash scripts/diff-with-line-numbers.sh NUMBER REPO— read diff with line numbers.gh api --paginate .../pulls/NUMBER/comments— read existing review comments.- Post inline comments on diff lines (§6) or file-level comments where appropriate.
gh pr review NUMBER --approve|--request-changes|--comment— submit the review verdict.