/codereview:retrieve-diff-from-commitfrom codereview
Retrieves code diffs from local git commits for code review pipelines. Supports single commits, commit ranges, and branch comparisons.
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 from local git commits. This is the entry point for reviewing local changes before they are pushed.
| Input | Required | Description |
|---|---|---|
commit_sha | Optional | Specific commit SHA to review (defaults to HEAD) |
commit_range | Optional | Range of commits (e.g., main..HEAD, HEAD~3..HEAD) |
base_branch | Optional | Compare current branch against base (e.g., main, develop) |
| Output | Description |
|---|---|
diff | The unified diff content |
files_changed | List of files modified with change type (added/modified/deleted) |
commit_info | Commit metadata (SHA, author, message, timestamp) |
stats | Summary statistics (lines added, deleted, files changed) |
# Get diff for specific commit
git show <commit_sha> --format="%H%n%an%n%ae%n%s%n%b" --stat
# Get unified diff
git diff <commit_sha>^..<commit_sha>
# Get diff for range
git diff <base_commit>..<head_commit>
# Get list of commits in range
git log --oneline <base_commit>..<head_commit>
# Compare feature branch to main
git diff main...HEAD
# Get merge-base
git merge-base main HEAD
Determine what to review:
| Scenario | Command | Use Case |
|---|---|---|
| Last commit | git diff HEAD~1..HEAD | Quick review of latest change |
| All uncommitted | git diff | Review before committing |
| Staged changes | git diff --cached | Review what will be committed |
| Branch diff | git diff main...HEAD | Full feature review |
| Specific commit | git show <sha> | Review single commit |
Execute the appropriate git command:
# For comprehensive diff with context
git diff --unified=5 <base>..<head>
# Include file stats
git diff --stat <base>..<head>
# Get list of changed files
git diff --name-status <base>..<head>
Collect commit information:
# Get commit details
git log --format="%H|%an|%ae|%at|%s" <base>..<head>
# Get file change summary
git diff --shortstat <base>..<head>
Structure the output for the review pipeline:
## Diff Retrieved
**Commit Range**: `<base>..<head>`
**Files Changed**: X
**Lines Added**: +Y
**Lines Deleted**: -Z
### Files
| Status | File |
|--------|------|
| M | src/auth/login.ts |
| A | src/utils/helper.ts |
| D | src/deprecated.ts |
### Diff Content
\`\`\`diff
<unified diff content>
\`\`\`
### Commit Info
| Field | Value |
|-------|-------|
| SHA | abc123... |
| Author | John Doe <[email protected]> |
| Date | 2024-01-15 10:30:00 |
| Message | feat: add login functionality |
{
"source": "local-git",
"commit_range": {
"base": "<base_sha>",
"head": "<head_sha>"
},
"stats": {
"files_changed": 5,
"insertions": 120,
"deletions": 45
},
"files": [
{
"path": "src/auth/login.ts",
"status": "modified",
"additions": 50,
"deletions": 10
}
],
"commits": [
{
"sha": "abc123",
"author": "John Doe",
"email": "[email protected]",
"timestamp": "2024-01-15T10:30:00Z",
"message": "feat: add login functionality"
}
],
"diff": "<unified diff content>"
}
After retrieving the diff, pass the output to:
□ Identify Scope
□ Single commit, range, or branch?
□ Committed or uncommitted?
□ Extract Diff
□ Run appropriate git diff command
□ Include sufficient context (--unified=5)
□ Gather Metadata
□ Commit info (SHA, author, message)
□ File statistics
□ Format Output
□ Structure for review pipeline
□ Include all necessary context
1. retrieve-diff-from-commit (this skill)
↓
2. codereview-orchestrator (triage)
↓
3. Specialist skills (review)
↓
4. Output formatted findings
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./codereview-configReview configuration, secrets, and environment handling. Checks for safe defaults, secret management, feature flags, and environment parity. Use when reviewing config files, environment variables, or feature flags./codereview-correctnessAnalyze code for logic bugs, error handling issues, and edge cases. Detects off-by-one errors, null handling, race conditions, and incorrect error paths. Use when reviewing core business logic or complex algorithms./codereview-dataReview database operations, migrations, and data persistence. Analyzes query safety, migration rollback, transaction boundaries, and data integrity. Use when reviewing migrations, models, repositories, or database queries.Other plugins' skills for the same job