review-github-pr
Review GitHub Pull Request
Summarize a GitHub pull request diff, highlighting key design decisions and notable code snippets.
Prerequisites
- The
ghCLI must be authenticated (gh auth status) - You must be in a git repository with a GitHub remote
Step 1: Resolve the PR
The user will provide either a PR number (e.g., #123 or 123) or a branch name. Determine which input was given and resolve it to a PR.
If a PR number is provided
Strip any leading # and use the numeric ID directly. Proceed to Step 2.
If a branch name is provided
Look up the open PR whose head branch matches:
gh pr list --head "<branch>" --state open
- If exactly one PR is found, extract its number and proceed to Step 2.
- If multiple PRs are found, list them and ask the user which one to review.
- If no PR is found, skip Step 2 (no PR description to fetch) and go directly to Step 3 using the local git diff fallback.
Step 2: Fetch PR Description
Retrieve the PR metadata:
gh pr view <number> --json title,body,state,headRefName,baseRefName,labels,author
Record the title, body, headRefName, and baseRefName for use in later steps.
Step 3: Generate the Diff
Primary: gh pr diff
Fetch the diff via the GitHub CLI:
gh pr diff <number>
If this succeeds, use this diff and proceed to Step 4.
Fallback: local git diff
If no PR exists (branch-only case) or the gh diff command fails, fall back to a local diff:
# Ensure both branches are available locally
git fetch origin <target-branch> <source-branch>
# Generate the diff
git diff origin/<target-branch>...origin/<source-branch>
If the user provided a branch name and no PR was found, diff against main:
git fetch origin main <branch>
git diff origin/main...origin/<branch>
Handling large diffs
If the diff output is very large (thousands of lines), use the Task tool to process it in chunks. Summarize each chunk independently, then merge the summaries. Do not skip or truncate parts of the diff — accuracy depends on reading all of it.
Step 4: Analyze and Summarize
Read through the full diff (and the PR description if available). Produce a summary with the following sections. Keep every section as concise as possible — brevity is a priority.
Summary format
## PR Review: <title>
**PR:** [#<number>](<url>) <- only if a PR exists
**Author:** <author>
**Branch:** `<source>` -> `<target>`
### Overview
<1-3 sentences describing what this PR does and why>
### Key Design Decisions
- <decision 1 with file:line reference>
- <decision 2 with file:line reference>
- ...
### Notable Code
<short fenced code snippets that illustrate the most important changes -- max 3 snippets>
### Potential Concerns <- omit if none
- <risk or issue worth discussing>
Guidelines for the summary:
- Overview: State what changed and why. Pull context from the PR description if available.
- Key Design Decisions: Focus on why something was done a particular way, not what changed. Include
file_path:line_numberreferences. Examples: choice of algorithm, new abstraction introduced, API contract change, migration strategy. - Notable Code: Include only the most instructive or surprising snippets. Keep each snippet under 15 lines. Always include the file path above the code block.
- Potential Concerns: Only include if there are genuine risks — missing error handling, breaking changes, performance implications, security issues. Do not fabricate concerns.
Step 5: Output
Print the summary directly in the chat as formatted markdown.
If the user requests it, also save the summary to a file:
# Default path
reviews/<number>-review.md
# Or for branch-only reviews
reviews/<branch-name>-review.md
Useful Commands Reference
| Command | Description |
|---|---|
gh pr list --head <branch> |
Find PR by head branch |
gh pr diff <number> |
Get PR diff |
gh pr view <number> --json ... |
Get full PR metadata |
git diff origin/<target>...origin/<source> |
Local diff between branches |
Example Usage
Review by PR number
User says: "Review PR #456"
- Fetch PR metadata for number 456
- Fetch diff via
gh pr diff 456 - Produce summary
Review by branch name
User says: "Review branch feature/add-pagination"
- Look up PR with
gh pr list --head "feature/add-pagination" - If found, fetch PR metadata and diff
- If not found, diff against main locally
- Produce summary
More from nvidia/openshell
openshell-cli
Guide agents through using the OpenShell CLI (openshell) for sandbox management, provider configuration, policy iteration, BYOC workflows, and inference routing. Covers basic through advanced multi-step workflows. Trigger keywords - openshell, sandbox create, sandbox connect, logs, provider create, policy set, policy get, image push, forward, port forward, BYOC, bring your own container, use openshell, run openshell, CLI usage, manage sandbox, manage provider, gateway start, gateway select.
11generate-sandbox-policy
Generate sandbox security policies from plain-language requirements and optional REST API documentation. At minimum, takes API host:port endpoints and intent to produce preset-based or L4 policies. With full API docs (OpenAPI, Swagger, markdown), generates fine-grained per-endpoint L7 rules. Trigger keywords - generate policy, create policy, update policy, change policy, sandbox policy, network policy, API policy, security policy, allow API, restrict API.
5tui-development
Guide for developing the OpenShell TUI — a ratatui-based terminal UI for the OpenShell platform. Covers architecture, navigation, data fetching, theming, UX conventions, and development workflow. Trigger keywords - term, TUI, terminal UI, ratatui, openshell-tui, tui development, tui feature, tui bug.
4sbom
Generate and manage Software Bill of Materials (SBOMs) for the OpenShell project. Covers SBOM generation with Syft, license resolution via public registries, and CSV export for compliance review. Trigger keywords - SBOM, sbom, bill of materials, license audit, license resolution, generate sbom, sbom csv, dependency license, supply chain, license scan.
3debug-inference
Debug why inference.local or external inference setup is failing. Use when the user cannot reach a local model server, has provider base URL issues, sees inference verification failures, hits protocol mismatches, or needs to diagnose inference on local vs remote gateways. Trigger keywords - debug inference, inference.local, local inference, ollama, vllm, sglang, trtllm, NIM, inference failing, model server unreachable, failed to verify inference endpoint, host.openshell.internal.
3debug-openshell-cluster
Debug why an OpenShell gateway deployment is unhealthy, unreachable, or unable to create sandboxes. Use when the user has a gateway health failure, Docker/Podman runtime issue, Helm install failure, Kubernetes scheduling issue, TLS secret issue, VM driver issue, or sandbox startup problem. Trigger keywords - debug gateway, gateway failing, deployment failing, helm install failing, cluster health, gateway health, gateway not starting, health check failed, sandbox pending, docker driver, podman driver, vm driver.
3