git:compare-worktrees

neolabhq/context-engineering-kit · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/neolabhq/context-engineering-kit --skill git:compare-worktrees
0 commentsdiscussion
summary

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

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

  4. 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)"
  5. 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>
    
  6. 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 <wt1>/file <wt2>/file
Directory diff Compare directories recursively diff -r <wt1>/dir <wt2>/dir
Summary only Show which files differ (no content) diff -rq <wt1>/ <wt2>/
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 <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
how to use git:compare-worktrees

How to use git:compare-worktrees on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add git:compare-worktrees
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

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

The skills CLI fetches git:compare-worktrees from GitHub repository neolabhq/context-engineering-kit and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/git:compare-worktrees

Reload or restart Cursor to activate git:compare-worktrees. Access the skill through slash commands (e.g., /git:compare-worktrees) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.870 reviews
  • Liam Ndlovu· Dec 28, 2024

    git:compare-worktrees reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Liam Lopez· Dec 24, 2024

    Keeps context tight: git:compare-worktrees is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Mei Zhang· Dec 24, 2024

    We added git:compare-worktrees from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Dhruvi Jain· Dec 4, 2024

    We added git:compare-worktrees from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Liam Diallo· Dec 4, 2024

    git:compare-worktrees fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Oshnikdeep· Nov 23, 2024

    git:compare-worktrees reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ama Thomas· Nov 23, 2024

    I recommend git:compare-worktrees for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Henry Nasser· Nov 19, 2024

    We added git:compare-worktrees from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Liam Haddad· Nov 15, 2024

    git:compare-worktrees is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • James Verma· Nov 15, 2024

    git:compare-worktrees reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 70

1 / 7