gitdataai/libs/agent/skills/templates/git-diff.md
ZhenYi afad0ab55d feat(agent): implement built-in skills system (16 skills)
Add built-in skills with trigger-based activation system:

Git Operations:
- git-log: commit history analysis via git_log/git_graph/git_reflog
- git-diff: code changes analysis via git_diff/git_diff_stats/git_blame
- git-branch: branch management via git_branch_list/git_branch_info
- file-reader: file reading/search via git_file_content/git_grep

Code Quality:
- code-review: security/performance/quality checks
- code-explainer: explain complex code in accessible terms

Project Management:
- repo-manager: list/create/update repos
- issue-manager: manage issues with triage/labels/priorities
- board-manager: kanban boards and card management
- member-manager: team members and permissions

Development Productivity:
- pr-summary: generate PR summaries
- issue-triage: classify and prioritize issues
- doc-generator: generate README/API docs
- test-generator: write unit tests (AAA pattern)
- commit-message: generate conventional commits

Utilities:
- http-requester: HTTP requests and API testing

Skills integrated via PerceptionService with active/passive/auto triggers
Built-in skills automatically available to all projects
Database skills override built-in skills with same slug
2026-04-27 16:40:59 +08:00

118 lines
2.9 KiB
Markdown

# 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
```