skills/github-pr-review/SKILL.md
Agent-neutral workflow for reviewing GitHub pull requests with gh CLI, local git, tests, and GitHub REST or GraphQL APIs, then posting summary or inline review comments as the user's authenticated GitHub account. Use when asked to set up PR review authentication, review a PR URL, review owner/repo#123, review the current branch PR, post PR review comments, review public or private repo PRs, use gh to inspect a PR diff, or leave feedback from the user's GitHub account.
npx skillsauth add 17-sss/agent-skills github-pr-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Review GitHub pull requests through general tools rather than agent-specific connectors. Prefer gh, local git, project test commands, and GitHub REST or GraphQL APIs. Browser automation is a last fallback only when CLI and API paths are blocked.
The workflow supports public and private repositories. Reading a public PR may be possible without authentication, but posting any review always requires an authenticated GitHub account. Private repositories require that the authenticated account has repo access, any required organization SSO authorization, and sufficient OAuth scopes or token permissions.
gh auth login OAuth.approve or request changes only when the user explicitly asks for that event. Default to a non-approving comment review.gh api --input for multi-comment inline reviews. Avoid shell-expanded nested comments[] flags unless the payload is trivial.Diff 범위에 inline 코멘트를 남겼습니다.Reviewed the diff and left inline comments.If the user asks to set up PR review access, use OAuth posting, or review as their account, check authentication before asking for a PR:
gh auth status
If not logged in, guide or run:
gh auth login
After login, confirm the account without exposing tokens:
gh api user --jq .login
PATs or API tokens are acceptable when the environment already provides them, but do not echo token values, write them into files, or include them in review artifacts.
If the user provided a PR URL up front, identify the PR first, then run the same authentication check before collecting or posting review context.
Resolve the target in this order:
https://github.com/owner/repo/pull/123.owner/repo#123.gh pr view when no PR identifier was given.Useful commands:
gh pr view <number-or-url> --json number,title,url,author,baseRefName,headRefName
gh pr view --json number,title,url,author,baseRefName,headRefName
Use -R owner/repo when reviewing outside the current checkout.
Separate read access from posting access:
gh configuration and rate limits.When access fails, classify the likely cause:
gh auth login.Use the bundled script when available:
skills/github-pr-review/scripts/collect_pr_context.sh <pr-url-or-owner/repo#number>
Or collect manually:
gh pr view <pr> --json title,body,author,labels,baseRefName,headRefName,additions,deletions,changedFiles,files,reviews,reviewRequests,statusCheckRollup
gh pr diff <pr> --name-only
gh pr diff <pr>
gh pr checks <pr>
If a local checkout is available, inspect related code beyond the diff before making strong claims. Search for call sites, schema consumers, feature flags, migrations, generated files, and tests. Run the repository's relevant checks when feasible, such as lint, typecheck, unit tests, or focused tests for changed areas.
Files outside the PR diff are context only. Use them to understand impact and verify risk, but do not use them as the primary location for a posted finding.
Use a code-review stance. Prioritize:
Deprioritize style preferences, naming nits, and broad refactors unless they hide real risk. Do not report speculative issues as facts; label uncertainty and include what would verify it.
For every finding, the file reference must point to a file changed in the PR diff, and preferably to a line present in the diff hunk. Do not use non-diff files as the primary finding location. If a problem is visible only in supporting context, anchor it to the changed diff line that introduced or exposed the risk; if no reliable diff anchor exists, do not publish it as a finding.
For every finding, include:
blocking, important, minor, or question.If there are no material issues, say so plainly and mention any remaining test gaps or unverified areas.
Use a compact review draft:
Findings:
1. blocking: <title>
File: path/to/file.ext:123
Risk: <what can break and when>
Recommendation: <specific change or test>
2. important: <title>
File: path/to/other.ext:45
Risk: <risk>
Recommendation: <fix>
Summary:
<short overall assessment, checks run, and remaining risk>
If there are no findings:
Findings:
No material issues found.
Summary:
Reviewed the diff and relevant context. Checks run: <commands or "not run">. Remaining risk: <short note>.
For inline reviews, the posted GitHub review body should not duplicate the final assistant report. Keep checks run, unrelated test failures, PR check status, and remaining-risk notes out of the PR review body unless they are material to the review finding. Report routine validation evidence in the user-facing final response instead.
Default path: show the draft to the user first. Post only after confirmation.
For a summary review:
gh pr review <pr> --comment --body-file review.md
Summary reviews must follow the same PR Scope Rule. Do not use a summary review to publish findings anchored to files outside the PR diff, and do not use summary comments to bypass inline diff-line requirements. If a finding has no reliable diff-file or diff-line anchor, keep it as an internal note or omit it from the posted review.
The bundled helper wraps this:
skills/github-pr-review/scripts/post_review.sh <pr> review.md
Only use these when explicitly requested:
gh pr review <pr> --approve --body-file review.md
gh pr review <pr> --request-changes --body-file review.md
For inline comments, prefer the GitHub API only when line mapping is reliable. REST review comments should target diff lines with line and side, plus optional start_line and start_side for multi-line comments. Avoid deprecated position-based mapping unless the environment requires it. If inline mapping is uncertain but a reliable diff-file or diff-line anchor exists, keep the finding in the summary review; if no reliable diff anchor exists, do not post it as a finding.
GraphQL can be used for review-thread operations such as adding review threads or replies. The gh pr-review extension from agynio/gh-pr-review is an optional convenience when installed, but this skill must still work with plain gh pr review and gh api.
Inline comments must point to lines that are present in the PR diff, not merely to any line in the base branch. For new or modified code, use side: RIGHT and the target line number from the PR's head-side file. Use side: LEFT only for removed lines.
When a finding can be mapped reliably to a changed diff line or range, prefer an inline review comment over a broad summary comment. Use summary comments for findings only when the PR Scope Rule is still satisfied and inline mapping is not reliable enough.
Before posting inline comments:
Inspect the patch:
gh pr diff <pr>
Confirm the local file line when the checkout is available:
nl -ba path/to/file.ext | sed -n '120,140p'
Confirm the file's PR patch from the API when possible:
gh api repos/OWNER/REPO/pulls/NUMBER/files --paginate \
--jq '.[] | select(.filename == "path/to/file.ext") | .patch'
Verify the target line is inside a diff hunk as an added line or context line for side: RIGHT.
If any mapping is uncertain, do not post inline comments. Use a summary review only when the finding still has a reliable PR diff file or line anchor; otherwise keep it as an internal note or omit it from the posted review.
For one or more inline comments, prefer one review payload and gh api --input. This is more reliable than composing nested comments[] parameters in shell flags.
Create a temporary payload file. Use a sanitized repo slug and PR number, for example /tmp/owner-repo-pr123-review.json. Do not include tokens, secrets, raw auth headers, or unrelated private logs in this file.
{
"event": "COMMENT",
"body": "Reviewed the diff and left inline comments.",
"comments": [
{
"path": "src/example.ts",
"line": 42,
"side": "RIGHT",
"body": "This condition now allows an empty value through. Please add a guard or a regression test for that case."
},
{
"path": "src/other.ts",
"line": 87,
"side": "RIGHT",
"body": "This call can now run before the token is initialized. Consider keeping the previous ordering or handling the missing-token branch."
}
]
}
Post it:
gh api repos/OWNER/REPO/pulls/NUMBER/reviews \
--method POST \
--input /tmp/owner-repo-pr123-review.json \
--jq '{id, state, html_url}'
Expected state for a comment-only review is COMMENTED. Give the html_url to the user. Delete the payload after posting when it is no longer needed:
rm /tmp/owner-repo-pr123-review.json
Only set "event": "APPROVE" or "event": "REQUEST_CHANGES" when the user explicitly asked for that review action. For multi-line comments, add start_line and start_side after verifying both ends of the range in the diff.
After posting, verify the response and optionally confirm through the PR reviews list:
review_id=123456789
gh api repos/OWNER/REPO/pulls/NUMBER/reviews --paginate \
--jq ".[] | select(.id == $review_id) | {id, state, html_url, user: .user.login}"
Check that:
state is COMMENTED for normal review comments.html_url is present and opens the submitted review.user.login matches the authenticated account.html_url or a concise summary of where the review was posted.gh is missing, ask the user to install GitHub CLI before continuing.gh auth login; do not switch to browser automation for normal login.gh pr review cannot express needed inline comments, use gh api with REST or GraphQL.gh api returns a validation error for inline comments, re-check path, line, side, and whether the line is present in the diff. Fall back to a summary review only when the finding still has a reliable PR diff anchor; otherwise omit it from the posted review.scripts/collect_pr_context.shCollects PR metadata, changed files, diff, checks, and sanitized auth/account information into an output directory. It accepts a PR URL, owner/repo#123, a PR number, a branch, or no PR identifier for the current branch.
scripts/post_review.shPosts a summary PR review from a body file. It confirms the authenticated account before posting. The default event is --comment; --approve and --request-changes require explicit options.
For Codex, Claude Code, Cursor, and generic agent placement notes, read references/agent-adapters.md only when installing or adapting the package to another agent environment.
tools
Agent-neutral workflow for safely publishing GitHub pull requests with gh CLI, local git, and constrained GitHub REST fallback. Use when asked to create, open, publish, draft, or preflight a GitHub PR from a local branch; push a branch for PR creation; create a PR in a public or private repo; diagnose PR creation auth, SSO, permission, or not-found failures; or avoid unsafe gh pr create prompting, fork creation, or accidental pushes.
tools
Inspect explicit repo-local commit rules, recent history, and staged changes to draft commit messages in the right style family. Use when the user asks for a commit message, asks to commit staged changes, or wants help choosing between conventional, gitmoji, plain imperative, or repo-custom commit formats.
testing
Create, refresh, validate, and resume shared HANDOFF and memory documents for a repository, a workspace-wide cross-repo context, or a workstream inside a larger workspace. Use when asked to write a handoff, checkpoint progress, resume prior work, or standardize project-state notes in Git-trackable files such as `docs/HANDOFF.md`, `_memory/HANDOFF.md`, or `_memory/workstreams/checkout-flow/HANDOFF.md`.
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.