retrieve-diff-from-commit
Retrieve code diff from a local git commit. Use this as the first step in a code review pipeline when reviewing local commits.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Retrieve code diff from a local git commit. Use this as the first step in a code review pipeline when reviewing local commits.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
| name | retrieve-diff-from-commit |
| description | Retrieve code diff from a local git commit. Use this as the first step in a code review pipeline when reviewing local commits. |
| metadata | {"author":"Zainan Victor Zhou","version":"1.0","type":"input","requires":"git"} |
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 <john@example.com> |
| 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": "john@example.com",
"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
基于 SOC 职业分类
Triage and orchestrate code reviews. Analyzes PR intent, identifies touched surfaces, assesses risk, and routes to specialist skills. Does NOT perform detailed review - delegates to specialists. Supports full pipeline with "Review PR <number>" command.
Retrieve code diff from a GitHub Pull Request via GitHub API. Use this as the first step in a code review pipeline when reviewing GitHub PRs.
Submit a code review to GitHub via the GitHub API. Use this as the final step in a code review pipeline to post review findings to a PR.
Review 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.
Deep 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.
Review 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.