Development v1.0.0

commit-diff-analyzer

Analyzes code changes between two git commits. Use when user provides two commit IDs and wants to understand what...

afine907 更新于 2026-05-15 1 浏览
下载 SKILL

技能说明

Analyzes code changes between two git commits. Use when user provides two commit IDs and wants to understand what changed between them, including file modifications, additions, deletions, and commit context.

使用场景

Analyzes code changes between two git commits. Use when user provides two commit IDs and wants to understand what changed between them, including file modifications, additions, deletions, and commit context.

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

帮我下载并安装这个SKILL:https://skillhub.cstcloud.cn/download/commit-diff-analyzer
  1. 点击上方「下载 SKILL」按钮,获取技能压缩包。
  2. 将压缩包解压到你的 Agent 技能目录。
  3. 重启客户端后即可在技能列表中选择该技能。

技能文件内容

4 个文件 · 15 kB
SKILL.md text/markdown
---
name: commit-diff-analyzer
description: Analyzes code changes between two git commits. Use when user provides two commit IDs and wants to understand what changed between them, including file modifications, additions, deletions, and commit context.
---

# Commit Diff Analyzer

## Usage Pattern

When user provides two commit IDs (in any order or format), analyze the changes between them:

1. **Validate commits exist**: Run `git cat-file -t <commit>` for each commit ID
2. **Get commit info**: Run `git log -1 --format=fuller <commit>` for both commits
3. **Show diff**: Run `git diff <older-commit>..<newer-commit>` (chronological order)
4. **Show stats**: Run `git diff --stat <older-commit>..<newer-commit>`

## Output Organization

Present the analysis with:

1. **Commit metadata** - Author, date, commit message for both commits
2. **Change summary** - Files changed, insertions, deletions
3. **Detailed diff** - Line-by-line changes with context
4. **File breakdown** - Group by: Modified, Added, Deleted files

## Key Commands

```bash
# Validate commits exist
git cat-file -t <commit-id>

# Get full commit info
git log -1 --format="Hash: %H%nAuthor: %an%nDate: %ad%nMessage: %s%n" <commit-id>

# Chronological diff (older..newer)
git diff <older-commit>..<newer-commit>

# Diff stat
git diff --stat <older-commit>..<newer-commit>

# Show files changed
git diff --name-only <older-commit>..<newer-commit>
```

## Handling Edge Cases

- **Invalid commit IDs**: Report error and suggest running `git log` to see recent commits
- **Same commit**: Notify user both IDs point to the same commit
- **Non-git directory**: Error - skill only works in git repositories
- **Reverse order**: Detect which commit is older and adjust command accordingly

## Commit ID Formats

Accept various formats:
- Full SHA: `abc123def456...`
- Short SHA: `abc123d` (at least 7 chars)
- Branch names (if they point to commits)
- HEAD references like `HEAD~5`

## Example Output Structure

```
=== Commit A ===
Hash: abc123...
Author: John Doe
Date: 2024-01-15 10:30:00
Message: feat: add user login

=== Commit B ===
Hash: def456...
Author: Jane Smith
Date: 2024-01-20 14:45:00
Message: fix: resolve auth bug

=== Changes Summary ===
5 files changed, 120 insertions(+), 35 deletions(-)

=== File Breakdown ===
Modified: src/auth.js, src/login.html
Added: src/auth-utils.ts
Deleted: src/old-auth.php

=== Diff ===
... (detailed diff output)
```

文件内容直接读取自技能仓库,仅供安装前审阅;以实际下载的压缩包为准。