git-diff
使用彩色终端输出以 GitHub 风格的统一 diff 格式显示 git 更改。使用两列行号、红色/绿色突出显示和块标记显示已暂存(--cached)和未暂存的更改。在检查代码更改、准备提交或比较文件修改时使用。在“git diff”、“显示更改”、“更改内容”或“查看差异”上触发。
📖 中文导读:使用彩色终端输出以 GitHub 风格的统一 diff 格式显示 git 更改。使用两列行号、红色/绿色突出显示和块标记显示已暂存(--cached)和未暂存的更改。在检查代码更改、准备提交或比较文件修改时使用。在“git diff”、“显示更改”、“更改内容”或“查看差异”上触发。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: git-diff description: Display git changes in GitHub-style unified diff format with colored terminal output. Shows both staged (--cached) and unstaged changes with two-column line numbers, red/green highlighting, and chunk markers. Use when reviewing code changes, preparing commits, or comparing file modifications. Triggers on "git diff", "show changes", "what changed", or "review diff". allowed-tools: Bash, Read
git-diff
Display git changes in GitHub-style unified diff format.
Execution
Run the Python script to display formatted diff:
python3 scripts/github_diff.py [optional-path]
Output Format
- File headers: Dark background with filepath
- Line numbers: Two columns (old | new)
- Deletions: Red background with
-marker - Additions: Green background with
+marker - Context: Neutral with both line numbers
- Chunk markers: Cyan
@@ -n,m +n,m @@headers
Sections
- Staged Changes (
git diff --cached) - shown first if present - Unstaged Changes (
git diff) - working directory modifications
Examples
# Show all changes
python3 scripts/github_diff.py
# Filter by path
python3 scripts/github_diff.py src/components/
Requirements
- Python 3.6+
- Git installed and in PATH
- Terminal with ANSI color support