MCPInstall

diff-preview

Preview and analyze git diffs with AI explanations. Use to understand changes before committing, get impact analysis, and compare branches or commits.

Installs
70
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/johnlindquist/claude --skill diff-preview
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads diff-preview automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Diff Preview & Analysis

Preview, explain, and analyze git changes with AI assistance.

Prerequisites

# Git
git --version

# Gemini for AI explanations
pip install google-generativeai
export GEMINI_API_KEY=your_api_key

CLI Reference

Basic Diff Commands

# Working directory changes
git diff

# Staged changes
git diff --staged
git diff --cached

# Specific file
git diff path/to/file.ts

# Between commits
git diff abc123 def456

# Between branches
git diff main feature-branch
git diff main...feature-branch  # Since branch diverged

# Show stat summary
git diff --stat
git diff --shortstat

# Name only
git diff --name-only
git diff --name-status  # With status (M/A/D)

Diff Output Options

# Word diff (better for prose)
git diff --word-diff

# Color words
git diff --color-words

# Ignore whitespace
git diff -w
git diff --ignore-all-space

# Context lines
git diff -U10  # 10 lines of context (default 3)

# Show function names
git diff --function-context

Commit Comparison

# Last commit
git diff HEAD~1

# Last N commits
git diff HEAD~5

# Specific commit range
git diff abc123..def456

# What changed in a specific commit
git show abc123

AI-Powered Analysis

Explain Changes

# Get diff and explain
DIFF=$(git diff --staged)
gemini -m pro -o text -e "" "Explain these code changes in plain English:

$DIFF

Summarize:
1. What was changed
2. Why it might have been changed
3. Any potential issues"

Impact Analysis

DIFF=$(git diff main...feature-branch)
gemini -m pro -o text -e "" "Analyze the impact of these changes:

$DIFF

Consider:
1. Breaking changes
2. Performance implications
3. Security considerations
4. Files/systems affected
5. Testing recommendations"

Pre-Commit Review

# Review staged changes before commit
git diff --staged | gemini -m pro -o text -e "" "Review this code diff for:
1. Bugs or issues
2. Code style problems
3. Missing error handling
4. Security concerns

Provide specific line references if issues found."

Generate Commit Message

DIFF=$(git diff --staged)
gemini -m pro -o text -e "" "Based on this diff, suggest a commit message:

$DIFF

Use conventional commit format (feat/fix/chore/etc).
First line under 50 chars, then details."

Comparison Patterns

Compare Branches

# Summary
git diff main feature-branch --stat

# Full diff
git diff main feature-branch

# Since branch point
git diff main...feature-branch

# Commits unique to feature branch
git log main..feature-branch --oneline

Find What Changed

# What files changed between commits
git diff --name-only abc123 def456

# What changed in a file
git log -p -- path/to/file.ts

# When was a line added
git blame path/to/file.ts

Merge Preview

# Preview merge conflicts
git merge --no-commit --no-ff feature-branch
git diff --staged
git merge --abort  # Clean up

Workflow Patterns

Pre-Commit Check

#!/bin/bash
# Check staged changes before commit

echo "=== Changes to commit ==="
git diff --staged --stat

echo ""
echo "=== Detailed diff ==="
git diff --staged

echo ""
read -p "Proceed with commit? (y/n) " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
  git commit
fi

PR Review Prep

# Get full PR diff for review
BASE=${1:-main}
BRANCH=$(git branch --show-current)

echo "=== Files changed ==="
git diff $BASE...$BRANCH --name-status

echo ""
echo "=== Stats ==="
git diff $BASE...$BRANCH --shortstat

echo ""
echo "=== AI Summary ==="
git diff $BASE...$BRANCH | gemini -m pro -o text -e "" "Summarize this PR's changes for a code reviewer. Focus on the intent and key changes."

Track Specific Changes

# Find all changes to a function
git log -p -S "functionName" -- "*.ts"

# Find changes mentioning something
git log -p --grep="JIRA-123"

Best Practices

  1. Review before commit - Always check git diff --staged
  2. Use stat first - Get overview before full diff
  3. Compare with base - Use main...branch for PR context
  4. Ignore whitespace - Use -w for meaningful changes
  5. Request AI review - For complex changes
  6. Save important diffs - Redirect to file for reference

FAQ

What does the diff-preview skill do?

Preview and analyze git diffs with AI explanations. Use to understand changes before committing, get impact analysis, and compare branches or commits.

How do I install diff-preview?

Run npx skills add https://github.com/johnlindquist/claude --skill diff-preview in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/diff-preview/ (personal) or .claude/skills/diff-preview/ (project).

Which AI agents can use diff-preview?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is diff-preview safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains diff-preview?

It is published by johnlindquist in johnlindquist/claude. It has 70 recorded installs.

More from johnlindquist/claude

View all →

gemini-image

johnlindquist/claude

Analyze images using Gemini's vision capabilities. Use for image analysis, text extraction from screenshots, and visual content understanding.

Media & Creative1.2K installs

memory

johnlindquist/claude

Open the skill to read its SKILL.md instructions.

362 installs

raycast-extension

johnlindquist/claude

Open the skill to read its SKILL.md instructions.

321 installs

brainstorm

johnlindquist/claude

Open the skill to read its SKILL.md instructions.

deepwiki

johnlindquist/claude

Query DeepWiki for repository documentation and structure. Use to understand open source projects, find API docs, and explore codebases.

Docs & Writing269 installs

think

johnlindquist/claude

Open the skill to read its SKILL.md instructions.

258 installs

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.