/codereview:retrieve-diff-from-github-prfrom codereview
Retrieves code diffs and metadata from GitHub Pull Requests via the GitHub API. Designed as the first step in a code review pipeline, it parses PR references, fetches details, and extracts changed files with patches.
Ships in codereview. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
An input skill that retrieves code diff and PR metadata from GitHub via the API. This is the entry point for reviewing GitHub Pull Requests.
| Input | Required | Description |
|---|---|---|
owner | Yes | Repository owner (username or organization) |
repo | Yes | Repository name |
pull_number | Yes | Pull Request number |
| Output | Description |
|---|---|
pr_info | PR metadata (title, description, author, state, labels) |
files | List of changed files with patches |
commits | List of commits in the PR |
base_ref | Base branch reference |
head_ref | Head branch reference |
diff | Full unified diff content |
This skill uses the GitHub MCP server with the following tools:
| Tool | Purpose |
|---|---|
get_pull_request | Get PR details (title, body, state, author) |
get_pull_request_files | Get list of changed files with patches |
Accept PR reference in various formats:
| Format | Example | Parsing |
|---|---|---|
| Full URL | https://github.com/owner/repo/pull/123 | Extract owner, repo, pull_number |
| Short reference | owner/repo#123 | Split on / and # |
| Number only | 123 | Requires owner/repo from context |
Regex for URL: github\.com/([^/]+)/([^/]+)/pull/(\d+)
Regex for short: ([^/]+)/([^#]+)#(\d+)
Use the GitHub MCP tool to get PR information:
{
"tool": "get_pull_request",
"server": "user-github",
"arguments": {
"owner": "<owner>",
"repo": "<repo>",
"pull_number": <number>
}
}
This returns:
Use the GitHub MCP tool to get file changes:
{
"tool": "get_pull_request_files",
"server": "user-github",
"arguments": {
"owner": "<owner>",
"repo": "<repo>",
"pull_number": <number>
}
}
This returns for each file:
filename: Path to the filestatus: added, removed, modified, renamedadditions: Lines addeddeletions: Lines deletedpatch: Unified diff patch for the fileStructure the output for the review pipeline:
## PR Retrieved
**Repository**: owner/repo
**PR #**: 123
**Title**: feat: add user authentication
### PR Info
| Field | Value |
|-------|-------|
| Author | @username |
| State | open |
| Base | main |
| Head | feature/auth |
| Commits | 3 |
| Changed Files | 5 |
### Description
<PR description content>
### Files Changed
| Status | File | +/- |
|--------|------|-----|
| modified | src/auth/login.ts | +50/-10 |
| added | src/utils/helper.ts | +30/-0 |
| deleted | src/deprecated.ts | +0/-25 |
### Diff Content
<unified diff for each file>
{
"source": "github-pr",
"repository": {
"owner": "owner",
"repo": "repo"
},
"pull_request": {
"number": 123,
"title": "feat: add user authentication",
"body": "PR description...",
"author": "username",
"state": "open",
"base": {
"ref": "main",
"sha": "abc123"
},
"head": {
"ref": "feature/auth",
"sha": "def456"
},
"labels": ["enhancement"],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T12:00:00Z"
},
"stats": {
"files_changed": 5,
"additions": 120,
"deletions": 45,
"commits": 3
},
"files": [
{
"path": "src/auth/login.ts",
"status": "modified",
"additions": 50,
"deletions": 10,
"patch": "@@ -1,10 +1,50 @@\n..."
}
],
"diff": "<combined unified diff>"
}
After retrieving the PR diff, pass the output to:
□ Parse PR Reference
□ Extract owner, repo, pull_number
□ Handle URL or short format
□ Fetch PR Details
□ Call get_pull_request MCP tool
□ Extract metadata and head SHA
□ Fetch Changed Files
□ Call get_pull_request_files MCP tool
□ Get patches for all files
□ Format Output
□ Structure for review pipeline
□ Include commit SHA for review submission
1. retrieve-diff-from-github-pr (this skill)
↓
2. codereview-orchestrator (triage)
↓
3. Specialist skills (review)
↓
4. submit-github-review (post review)
| Error | Cause | Resolution |
|---|---|---|
| 404 Not Found | PR doesn't exist or no access | Verify PR number and permissions |
| 403 Forbidden | Rate limited or no auth | Check GitHub token |
| Invalid format | Can't parse PR reference | Use format: owner/repo#number |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub xinbenlv/codereview-skills --plugin codereview16 skills in this plugin
/codereview-apiReview API contracts, breaking changes, and interface consistency. Analyzes REST/RPC endpoints, event schemas, versioning, and backward compatibility. Use when reviewing public interfaces, API routes, or service contracts./codereview-architectDeep codebase context analysis like Greptile. Analyzes blast radius of changes, dependency graphs, and architectural consistency. Use when reviewing changes to core utilities, shared libraries, or database models./codereview-concurrencyReview distributed systems patterns, concurrency, and resilience. Analyzes retry policies, idempotency, timeouts, circuit breakers, and race conditions. Use when reviewing async code, workers, queues, or distributed transactions.Other plugins' skills for the same job