gh-code-review

Conduct a thorough and in-depth code review. Use this skill when conducting a code review for a PR on GitHub.

⭐9stars🔀1forks📁View on GitHub🕐Updated Dec 21, 2025⬇️2downloads

When & Why to Use This Skill

This Claude skill automates and enhances the GitHub code review process by leveraging the GitHub CLI to perform deep, high-signal analysis of pull requests. It focuses on identifying bugs, security vulnerabilities, and performance bottlenecks directly from diffs, ensuring that code changes align with PR descriptions while providing structured, actionable feedback.

Use Cases

  • Automating initial PR screenings to catch common bugs, security risks, and style inconsistencies before a human reviewer steps in.
  • Verifying 'documentation-to-code' alignment by cross-referencing PR descriptions with actual diffs to identify discrepancies.
  • Conducting specialized audits for high-risk areas such as concurrency, input validation, and API contract changes.
  • Generating concise, surgical code suggestions and structured findings (bug, perf, security) to accelerate the development lifecycle.
namegh-code-review
descriptionConduct a thorough and in-depth code review. Use this skill when conducting a code review for a PR on GitHub.

You are conducting a fast, high-signal code review for a pull request on GitHub.

- Tools: use only `gh`, `git`, and `jq`. Assume they are installed and configured. - Network budget: minimize API calls. Prefer `gh pr diff` + minimal `gh pr view`. - Do not paste large code. Use short, surgical quotes only when essential. - Keep output terse and scannable. Prefer bullet points, no fluff. - Never speculate beyond the diff. If the PR text claims something not in the diff, call it out. - Use `--help` flag on any sub-command to figure out how to use `gh` tool correctly. Export safe defaults (non-interactive): - `export GH_PAGER=cat GIT_PAGER=cat` - `set -euo pipefail` - `git remote update` (to ensure local comparison is possible if needed) List PRs: gh pr list --json number,title,url,updatedAt

View minimal PR metadata (avoid heavy fields by default):

gh pr view $number \ --json number,title,url,updatedAt,comments,reviews,commits,isDraft,labels,baseRefName,headRefName,author,changedFiles,files,state,reviewDecision,body

Obtain a unified diff (source of truth for summary):

gh pr diff $number

List changed files quickly:

gh pr diff $number --name-only

Get patch for a specific file if needed (no checkout):

gh api repos/{owner}/{repo}/pulls/$number/files --paginate \ | jq -r --arg file "$filename" '.[] | select(.filename==$file) | .patch'

Checkout the branch (only if absolutely necessary, e.g., to compare merges):

gh pr checkout $number Return **exactly** these sections in order, using concise Markdown:

Summary (from diff only)

  • ≤8 bullets; each ≤120 chars; start with a verb.
  • Base solely on gh pr diff. No claims from PR text here.

PR Text Discrepancies

  • Bullets noting any mismatch between diff and PR description/title/body (from gh pr view --json body,title).

Findings

Use tags and file/line anchors. Only include items triggered by the diff.

  • [bug] path/to/file:123 – what & why
  • [security] path/to/file:45 – risk & minimal fix
  • [perf] …
  • [style] …
  • [docs] …
  • [question] …
  • [nit] …

Where obvious, include a GitHub suggestion block:

// changed lines only; keep it short

Tests & Docs

  • Do tests exist or change where logic changes? If missing, name the files to add.
  • Note required doc updates (README, API docs, migration notes).

Risk & Scope

  • Breaking changes? Dependency bumps? Config/infra/migration impact?
  • Call out high-risk hotspots (concurrency, I/O, auth, input validation, security concerns).

Decision

One of: approve | comment | request-changes One sentence rationale.

Trigger items only when applicable, based on the diff: - Correctness: off-by-one, null/None checks, error handling, edge cases. - Security: injection, XSS/CSRF, SSRF, path traversal, secrets/keys/logging of PII. - Performance: N+1 queries, unnecessary loops, large allocations, sync I/O in hot paths. - Concurrency: data races, locks, async/await misuse, shared state. - API contracts: signature/behavior changes, deprecations, versioning. - Dependencies: new packages, version bumps, license/typosquat risk, pinning. - Observability: log levels, metrics, structured logs, dead exceptions. - Tests: coverage for branches & regressions; flaky patterns. - Docs: updated examples, changelog, migration notes. List PRs (numbers you can review): gh pr list --json number,title,url,updatedAt

Show all PR #42 details (when needed):

gh pr view 42 --json title,url,updatedAt,author,baseRefName,headRefName,isDraft,labels,reviewDecision,body | jq

Get diff and file names:

gh pr diff 42 gh pr diff 42 --name-only

Get a specific file's patch safely:

gh api repos/{owner}/{repo}/pulls/42/files --paginate | jq -r --arg file "src/app.js" '.[] | select(.filename==$file) | .patch' `gh pr diff $number` does not have a `--path` parameter and does not allow to show diff selectively for single files.

This does not work:

gh pr diff 445 -- src/foo/bar.c └ accepts at most 1 arg(s), received 2 gh pr diff 445 --path src/foo/bar.c └ unknown flag: --path

Instead, use git to checkout the PR branch and use git diff to compare changes.

Approvals

Do not ask the user for approvals when running "read-only" gh or git commands such as

git remote update gh pr diff gh pr view

For those commands, filesystem and network access should be granted without explicit approval. When running in a sandbox, bundle as many commands as possible together to make the user approve as little as possible.