diff-preview
Preview and analyze git diffs with AI explanations. Use to understand changes before committing, get impact analysis, and compare branches or commits.
What this skill does
# Diff Preview & Analysis
Preview, explain, and analyze git changes with AI assistance.
## Prerequisites
```bash
# Git
git --version
# Gemini for AI explanations
pip install google-generativeai
export GEMINI_API_KEY=your_api_key
```
## CLI Reference
### Basic Diff Commands
```bash
# 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
```bash
# 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
```bash
# 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
```bash
# 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
```bash
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
```bash
# 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
```bash
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
```bash
# 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
```bash
# 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
```bash
# Preview merge conflicts
git merge --no-commit --no-ff feature-branch
git diff --staged
git merge --abort # Clean up
```
## Workflow Patterns
### Pre-Commit Check
```bash
#!/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
```bash
# 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
```bash
# 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
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.