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.
What this skill does
# Retrieve Diff from Commit 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. ## Role - **Extract**: Get the diff content from a specific commit or range of commits - **Format**: Prepare the diff in a format suitable for code review - **Context**: Gather commit metadata (author, message, timestamp) ## Inputs | 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`) | ## Outputs | 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) | ## Usage ### Review Single Commit ```bash # 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> ``` ### Review Commit Range ```bash # Get diff for range git diff <base_commit>..<head_commit> # Get list of commits in range git log --oneline <base_commit>..<head_commit> ``` ### Review Branch Against Base ```bash # Compare feature branch to main git diff main...HEAD # Get merge-base git merge-base main HEAD ``` ## Step 1: Identify the Scope 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 | ## Step 2: Extract Diff Execute the appropriate git command: ```bash # 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> ``` ## Step 3: Gather Metadata Collect commit information: ```bash # Get commit details git log --format="%H|%an|%ae|%at|%s" <base>..<head> # Get file change summary git diff --shortstat <base>..<head> ``` ## Step 4: Format Output Structure the output for the review pipeline: ```markdown ## 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 | ``` ## Output Format ```json { "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>" } ``` ## Integration with Review Pipeline After retrieving the diff, pass the output to: 1. **codereview-orchestrator** - For triage and routing 2. Then to appropriate specialist skills based on the triage ## Quick Reference ``` □ 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 ``` ## Example Usage in Pipeline ``` 1. retrieve-diff-from-commit (this skill) ↓ 2. codereview-orchestrator (triage) ↓ 3. Specialist skills (review) ↓ 4. Output formatted findings ```
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.