# Git Diff Analysis Skill

## Overview
You are an expert at analyzing code differences. Use this skill when users want to understand what changed between commits, branches, or the working directory.

## Available Tools

### Primary Tools
- `git_diff` - Show file changes between two commits or working directory
- `git_diff_stats` - Get aggregated statistics (files changed, insertions, deletions)
- `git_blame` - Show what revision and author last modified each line

### Supporting Tools
- `git_file_content` - Read file content at specific revision
- `git_commit_info` - Get commit metadata for context

## When to Use

### Active Triggers (User Explicitly Asks)
- "看看改动" / "show me the changes"
- "diff 是什么" / "what changed"
- "比较两个分支" / "compare branches"
- "这个 PR 改了什么" / "what does this PR change"
- "谁改了这行代码" / "who changed this line"
- "文件有什么变化" / "what changed in this file"
- "和 main 分支对比" / "diff against main"

### Passive Triggers (Tool Names)
- Tool `git_diff` called → activate this skill
- Tool `git_diff_stats` called → activate this skill
- Tool `git_blame` called → activate this skill

### Auto Triggers (Keywords)
- "diff", "change", "修改", "变更"
- "compare", "对比", "比较"
- "patch", "delta"
- "insert", "delete", "新增", "删除"

## Analysis Guidelines

### 1. Diff Interpretation
For understanding code changes:
```
1. Get git_diff_stats first for overview
2. Then git_diff for detailed changes
3. Categorize: additions, deletions, modifications
4. Identify file types affected
```

### 2. Change Classification
Categorize changes for better understanding:
```
- Feature changes: New functionality
- Bug fixes: Corrections to existing behavior
- Refactoring: Code restructuring without behavior change
- Documentation: Comments, docs, README
- Tests: Test additions/modifications
- Config: Build, CI/CD, dependencies
```

### 3. Blame Analysis
For understanding code authorship:
```
1. git_blame on the target file
2. Identify who last touched each section
3. Note patterns: some lines untouched for years
4. Flag recently modified lines for attention
```

### 4. Impact Assessment
Assess the scope of changes:
```
1. How many files affected?
2. How many lines added/removed?
3. Are critical paths modified?
4. Any potential breaking changes?
```

## Output Format

When analyzing diffs:

```
## Diff Analysis

### Overview
- Files changed: [N]
- Insertions: [+] [N] lines
- Deletions: [-] [N] lines

### Changes by Category
**New Files:**
- [file1]
- [file2]

**Modified Files:**
- [file3] ([+/-] [N] lines)
- [file4] ([+/-] [N] lines)

**Deleted Files:**
- [file5]

### Key Changes
1. **[file]** - [Summary of change]
   - Lines: [+/-]
   - Purpose: [Why this was changed]

### Potential Issues
- [Issue 1 with file and line]
- [Issue 2]

### Review Checklist
- [ ] Changes align with stated purpose
- [ ] No unintended side effects
- [ ] Tests updated
- [ ] Documentation updated
```
