AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Git:compare Worktrees

skill-antifragiletech-antifragile-claude-code-compare-worktrees · by AntifragileTech

Compare files and directories between git worktrees or worktree and current branch

No reviews yet
0 installs
24 views
0.0% view→install

Install

$ agentstack add skill-antifragiletech-antifragile-claude-code-compare-worktrees

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-antifragiletech-antifragile-claude-code-compare-worktrees)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
4mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Git:compare Worktrees? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

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
  1. 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

  1. 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:

``bash diff / / # Or for unified diff format: diff -u / / ``

For directories between worktrees:

``bash diff -r / / # Or for summary only: diff -rq / / ``

For branch-level comparison (using git diff):

``bash git diff .. -- # Or for stat summary: git diff --stat .. ``

For comparing with current working directory:

``bash diff / ``

  1. 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

| Mode | Description | Command Pattern | |------|-------------|-----------------| | File diff | Compare single file between worktrees | diff -u /file /file | | Directory diff | Compare directories recursively | diff -r /dir /dir | | Summary only | Show which files differ (no content) | diff -rq / / | | Git diff | Use git's diff (branch-based) | git diff branch1..branch2 -- path | | Stat view | Show change statistics | git 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
  • 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

"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

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.