skills/engineering/pr-code-review/SKILL.md
Perform GitHub pull request code reviews using the gh CLI. Use when asked to review a PR, inspect PR diffs, leave inline review comments on specific lines, or produce a priority-based summary (P0-P3) of findings with an overall correctness verdict. Also use for "interactive review" / "manual review" flows where the user wants to discuss findings before anything is posted to GitHub.
npx skillsauth add arctuition/skills pr-code-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 PRs using the gh CLI. Post inline comments tied to specific code lines, use GitHub suggestion blocks for trivial fixes, and submit everything as a single batched review with a verdict. All gh CLI patterns — repo context, PR metadata, diff inspection, Reviews API payload, suggestion syntax, line-number mapping, fallback commands — live in references/gh-cli.md.
Pick a mode before reading code; tell the user which one in one sentence.
Interactive mode (manual / "手动挡") — draft locally, discuss, post on approval, then stay engaged so the human can surface more issues that you (when you both agree) post as follow-ups. Ends only when the user says so. Trigger phrases: "interactive", "manual / 手动 / 手动挡", "discuss / 讨论 / 商量", "don't post / 先别 post", "draft", "preview", "ask me before posting". Default to interactive whenever the user implies any preview or approval step.
Auto-post mode (default) — only when the user clearly wants a one-shot review with no preview step. When in doubt, ask one short clarifying question.
Capture repo context and the head commit SHA — referenced throughout:
OWNER_REPO=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
COMMIT_SHA=$(gh pr view <pr> --json headRefOid --jq .headRefOid)
Read PR metadata (title, body, linked issue, file list, churn) — commands in references/gh-cli.md. Capture:
*.md under docs/, plans/, specs/, adr/, ard/, or files named PLAN.md, SPEC.md, DESIGN.md)? If so, treat them as the source of truth for intent and flag drift in step 4. Read them in full before reading the code.Pre-checks:
gh pr checks <pr> — if CI is failing, focus on the failure cause rather than a full review.gh pr diff <pr> --name-only
gh pr diff <pr> --patch --color=never > /tmp/pr.diff # for large PRs
Prioritize: business logic, auth, payments, data mutations; high-churn files; new files (need full design review); config/infra/CI/permissions.
Deprioritize/skip: auto-generated files (lock files, snapshots, generated migrations); pure formatting/rename; vendor updates (unless pinning matters).
For non-trivial changes, read the full file (or surrounding function/class) — not just the diff — to understand the before-state, broader module, and any new inconsistencies with nearby code.
If already on the PR branch, use Read directly. Otherwise gh pr checkout <pr>, or fetch one file at HEAD:
gh api repos/$OWNER_REPO/contents/<path>?ref=$COMMIT_SHA --jq '.content' | base64 -d
Before flagging an issue, apply the "should I flag this?" test:
If a finding fails any test, don't post it. If there are no findings a person would definitely want to fix, output zero — an empty review is better than a noisy one.
For each changed file, systematically check:
Correctness
Security
Reliability
Performance
API design & contracts
Tests
Clarity
For each issue, record:
[P1] Add max-attempts guard to retry loop).suggestion block for concrete replacements.Priority definitions:
Comment writing rules:
suggestion blocks for concrete fixes.suggestion blocks contain ONLY replacement code, no commentary. Preserve exact leading whitespace.Also briefly note things done well — one sentence, no flattery.
Both modes build the same JSON payload as a temp file (use $COMMIT_SHA from step 1) — only the final step differs. Build the payload via the Write tool, not heredocs — backticks in suggestion blocks break shell escaping. Payload shape, gh api command, and event semantics live in references/gh-cli.md.
Review verdicts:
APPROVE — no P0/P1, patch is correct.REQUEST_CHANGES — has P0/P1 blocking merge.COMMENT — only P2/P3, or you want discussion without blocking.gh api -X POST repos/$OWNER_REPO/pulls/<pr>/reviews --input /tmp/review-payload.json
Runs in two phases. Both must happen — do not end the skill after Phase 1.
Phase 1 — initial draft cycle
/tmp/review-payload-<pr>.json) and show a preview of every comment (priority, file:line, body, suggestion) plus the proposed verdict and summary. State nothing has been posted./tmp/review-payload-<pr>.json in place via Read + Write. Do not POST between iterations.Phase 2 — ongoing discussion (follow-up comments)
$COMMIT_SHA (author may have pushed) and re-verify the target file:line at HEAD still says what you think.gh api -X POST repos/$OWNER_REPO/pulls/<pr>/comments --input <file> with {body, commit_id, path, line, side: "RIGHT"}.event: "COMMENT" (no verdict change), same payload shape as Phase 1.gh api -X POST repos/$OWNER_REPO/pulls/<pr>/comments/<comment_id>/replies -f body='...'.gh api -X PATCH repos/$OWNER_REPO/pulls/comments/<comment_id> -f body='...'.If re-invoked mid-discussion without history, list what's already posted (existing reviews/comments — see references) before drafting.
Fallback: if the Reviews API fails, post inline comments individually; last resort, post a general comment summarizing findings. Commands in references/gh-cli.md.
Render a summary for the user (not posted to GitHub) after each post. Include an overall correctness verdict — does the patch break existing code/tests or introduce bugs (ignore style/formatting/nits).
Skeleton:
## Review posted
**Verdict**: <APPROVE | REQUEST_CHANGES | COMMENT>
**Overall correctness**: <one sentence — does the patch break things, with the specific failure mode>
**Findings**: <counts by priority>
### P0 / P1 / P2 / P3
- <file:line — short title>
### Positive
- <one-sentence acknowledgments>
### Not reviewed
- <files skipped and why>
Matter-of-fact, not adversarial. Avoid flattery ("Great job...") and vague negativity ("This is wrong.").
Lead with the scenario — state the conditions under which the issue manifests so the author can assess severity. Good: "If the upstream service returns transient errors for >5s, this retries indefinitely, exhausting the connection pool." Bad: "Infinite retry."
Ask when intent is ambiguous. Frame as a question: "Is this intentionally unbounded? If a caller passes a large dataset, this could OOM."
Distinguish blocking from non-blocking. Use priority tags consistently. Prefix optional suggestions with nit:.
One comment per issue. Each must be independently addressable.
Don't comment on:
The should-I-flag-this test at step 4 already covers pre-existing issues, speculation, and pure preferences — apply it before posting anything.
When the author pushes fixes:
<old-sha>..HEAD to see what changed since your last review.CHANGES_REQUESTED review (commands in references/gh-cli.md).Classify each file by risk tier using step 2 prioritization. Review high-risk files thoroughly (full context + checklist). Scan medium-risk for high-severity issues only. Skip low-risk (generated, lock files) and list as "not reviewed." If the PR is too large to review effectively, say so and suggest splitting.
data-ai
Wrap up the work you just did and open a PR for it — branch off main/master if needed, commit only the changes you made, push, open a pull request (following .github/PULL_REQUEST_TEMPLATE.md when present), and open the PR in the browser. Targets the `upstream` remote's default branch as the base when an `upstream` remote exists, otherwise `origin`. Use when the user says "sign off", "signoff", "ship it", "open a PR for this", "commit and PR", or "wrap this up".
development
Produce a single-file HTML "thread recap" artifact that captures what was discussed in an agent / pairing / chat conversation — the questions explored, the decisions made and their tradeoffs, the dead ends we walked into, the open questions left, and the artifacts produced — so a teammate who wasn't in the room can pick up the context. Use this skill whenever the user asks to summarize a conversation/thread/session, mentions sharing a thread with colleagues, says things like "把这个对话总结一下", "share this thread with the team", "write up what we decided", "decision log for this conversation", "document the tradeoffs we made", "recap of our pairing session", or wants to hand off a Claude/ChatGPT/agent transcript as context. Trigger even when "HTML" isn't said — the artifact format is the whole point. Input can be the current session's own conversation context OR a transcript the user pastes in.
development
Produce a single-file HTML "PR writeup" artifact that explains a pull request to its reviewers — motivation, before/after behavior, file-by-file tour with the reasoning, where to focus the review, test plan, and rollout. Use this skill whenever the user is about to open a PR, has just finished a branch, mentions writing a PR description, asks for a PR write-up, says things like "explain this change to my team", "help me pitch this PR", "write the PR description", "summarize what I'm shipping", or wants to make sure reviewers understand intent and risk before they read the diff. Trigger even when they don't say "HTML" — the artifact format is the whole point and the user should not have to ask for it by name.
development
Produce a single-file HTML "code review companion" artifact that helps a reviewer get oriented in someone else's pull request — a risk-coloured map of every file, an annotated diff with margin notes and severity tags, the call-graph that shows how the changed pieces fit together, and the questions worth asking the author. Use this skill whenever the user is about to review a PR, has been assigned one, mentions reviewing code they didn't write, says things like "help me review this", "I need to review PR