Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计未展示

git:compare-worktreesgit 比较工作树

Agent Skill

git:compare-worktrees 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

10,845

周安装

443

GitHub Stars

891

下载量

3,473
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:git:compare-worktrees(git 比较工作树)
来源仓库:https://github.com/neolabhq/context-engineering-kit
仓库路径:skills/git:compare-worktrees
安装命令:
npx skills add https://github.com/neolabhq/context-engineering-kit --skill git:compare-worktrees
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/neolabhq/context-engineering-kit --skill git:compare-worktrees

简介

git-compare-worktrees 比较不同工作树之间的文件差异,辅助并行开发。

  • 适用于同时维护多个功能分支或实验性修改的场景。
  • 可生成统一 diff 报告,标识各工作树间的变更交集与差异。
  • 需确保所有工作树基于同一仓库,避免路径或引用错误。
  • git:compare-worktrees 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Claude Command: Compare Worktrees

Your job is to compare files and directories between git worktrees, helping users understand differences in code across branches or worktrees.

Instructions

CRITICAL: Perform the following steps exactly as described:

  1. Current state check: Run git worktree list to show all existing worktrees and their locations
  2. Parse user input: Classify each provided argument:

- No arguments: Interactive mode - ask user what to compare - --stat: Show summary statistics of differences (files changed, insertions, deletions) - Worktree path: A path that matches one of the worktree roots from git worktree list - Branch name: A name that matches a branch in one of the worktrees - File/directory path: A path within the current worktree to compare

  1. Determine comparison targets (worktrees to compare): a. If user provided worktree paths: Use those as comparison targets b. If user specified branch names: Find the worktrees for those branches from git worktree list c. If only one worktree exists besides current: Use current and that one as comparison targets d. If multiple worktrees exist and none specified: Present list and ask user which to compare e. If no other worktrees exist: Offer to compare with a branch using git diff
  2. Determine what to compare (files/directories within worktrees): a. If user specified file(s) or directory(ies) paths: Compare ALL of them b. If no specific paths given: Ask user:

- "Compare entire worktree?" or - "Compare specific files/directories? (enter paths)"

  1. Execute comparison: For specific files between worktrees: diff <worktree1>/<path> <worktree2>/<path> # Or for unified diff format: diff -u <worktree1>/<path> <worktree2>/<path> For directories between worktrees: diff -r <worktree1>/<directory> <worktree2>/<directory> # Or for summary only: diff -rq <worktree1>/<directory> <worktree2>/<directory> For branch-level comparison (using git diff): git diff <branch1>..<branch2> -- <path> # Or for stat summary: git diff --stat <branch1>..<branch2> For comparing with current working directory: diff <current-file> <other-worktree>/<file>
  2. Format and present results:

- Show clear header indicating what's being compared - For large diffs, offer to show summary first - Highlight significant changes (new files, deleted files, renamed files) - Provide context about the branches each worktree contains

Comparison Modes

ModeDescriptionCommand Pattern
File diffCompare single file between worktreesdiff -u <wt1>/file <wt2>/file
Directory diffCompare directories recursivelydiff -r <wt1>/dir <wt2>/dir
Summary onlyShow which files differ (no content)diff -rq <wt1>/ <wt2>/
Git diffUse git's diff (branch-based)git diff branch1..branch2 -- path
Stat viewShow change statisticsgit diff --stat branch1..branch2

Worktree Detection

The command finds worktrees using git worktree list:

/home/user/project           abc1234 [main]
/home/user/project-feature   def5678 [feature-x]
/home/user/project-hotfix    ghi9012 [hotfix-123]

From this output, the command extracts:

  • Path: The absolute path to the worktree directory
  • Branch: The branch name in brackets (used when user specifies branch name)

Examples

Compare specific file between worktrees:

> /git:compare-worktrees src/app.js
# Prompts to select which worktree to compare with
# Shows diff of src/app.js between current and selected worktree

Compare between two specific worktrees:

> /git:compare-worktrees ../project-main ../project-feature src/module.js
# Compares src/module.js between the two specified worktrees

Compare multiple files/directories:

> /git:compare-worktrees src/app.js src/utils/ package.json
# Shows diffs for all three paths between worktrees

Compare entire directories:

> /git:compare-worktrees src/
# Shows all differences in src/ directory between worktrees

Get summary statistics:

> /git:compare-worktrees --stat
# Shows which files differ and line counts

Interactive mode:

> /git:compare-worktrees
# Lists available worktrees
# Asks which to compare
# Asks for specific paths or entire worktree

Compare with branch worktree by branch name:

> /git:compare-worktrees feature-x
# Finds worktree for feature-x branch and compares

Compare specific paths between branch worktrees:

> /git:compare-worktrees main feature-x src/ tests/
# Compares src/ and tests/ directories between main and feature-x worktrees

Output Format

File Comparison Header:

Comparing: src/app.js
  From: /home/user/project (main)
  To:   /home/user/project-feature (feature-x)
---
[diff output]

Summary Output:

Worktree Comparison Summary
===========================
From: /home/user/project (main)
To:   /home/user/project-feature (feature-x)

Files only in main:
  - src/deprecated.js

Files only in feature-x:
  + src/new-feature.js
  + src/new-feature.test.js

Files that differ:
  ~ src/app.js
  ~ src/utils/helpers.js
  ~ package.json

Statistics:
  3 files changed
  2 files added
  1 file removed

Common Workflows

Review Feature Changes

# See what changed in a feature branch
> /git:compare-worktrees --stat
> /git:compare-worktrees src/components/

Compare Implementations

# Compare how two features implemented similar functionality
> /git:compare-worktrees ../project-feature-1 ../project-feature-2 src/auth/

Quick File Check

# Check if a specific file differs
> /git:compare-worktrees package.json

Pre-Merge Review

# Review all changes before merging (compare src and tests together)
> /git:compare-worktrees --stat
> /git:compare-worktrees src/ tests/
# Both src/ and tests/ directories will be compared

Important Notes

  • Argument detection: The command auto-detects argument types by comparing them against git worktree list output:

- Paths matching worktree roots → treated as worktrees to compare - Names matching branches in worktrees → treated as worktrees to compare - Other paths → treated as files/directories to compare within worktrees

  • Multiple paths: When multiple file/directory paths are provided, ALL of them are compared between the selected worktrees (not just the first one).
  • Worktree paths: When specifying worktrees, use the full path or relative path from current directory (e.g., ../project-feature)
  • Branch vs Worktree: If you specify a branch name, the command looks for a worktree with that branch checked out. If no worktree exists for that branch, it suggests using git diff instead.
  • Large diffs: For large directories, the command will offer to show a summary first before displaying full diff output.
  • Binary files: Binary files are detected and reported as "Binary files differ" without showing actual diff.
  • File permissions: The diff will also show changes in file permissions if they differ.
  • No worktrees: If no other worktrees exist, the command will explain how to create one and offer to use git diff for branch comparison instead.

Integration with Create Worktree

Use /git:create-worktree first to set up worktrees for comparison:

# Create worktrees for comparison
> /git:create-worktree feature-x, main
# Created: ../project-feature-x and ../project-main

# Now compare
> /git:compare-worktrees src/

Troubleshooting

"No other worktrees found"

  • Create a worktree first with /git:create-worktree <branch>
  • Or use git diff for branch-only comparison without worktrees

"Worktree for branch not found"

  • The branch may not have a worktree created
  • Run git worktree list to see available worktrees
  • Create the worktree with /git:create-worktree <branch>

"Path does not exist in worktree"

  • The specified file/directory may not exist in one of the worktrees
  • This could indicate the file was added/deleted in one branch
  • The command will report this in the comparison output

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.62%
按下载量换算1,237

Claude

27.23%
按下载量换算946

Cursor

18.82%
按下载量换算654

Gemini CLI

8.99%
按下载量换算312

安全审计

暂无安全审计结果可展示。

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills