git:merge-worktree

neolabhq/context-engineering-kit · updated Jun 3, 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:merge-worktree
0 commentsdiscussion
summary

Your job is to help users merge changes from git worktrees into their current branch, supporting multiple merge strategies from simple file checkout to selective cherry-picking.

skill.md

Claude Command: Merge Worktree

Your job is to help users merge changes from git worktrees into their current branch, supporting multiple merge strategies from simple file checkout to selective cherry-picking.

Instructions

CRITICAL: Perform the following steps exactly as described:

  1. Current state check: Run git worktree list to show all existing worktrees and git status to verify working directory state

  2. Parse user input: Determine what merge operation the user wants:

    • --interactive or no arguments: Guided interactive mode
    • File/directory path: Merge specific file(s) or directory from a worktree
    • Commit name: Cherry-pick a specific commit
    • Branch name: Merge from that branch's worktree
    • --from <worktree>: Specify source worktree explicitly
    • --patch or -p: Use interactive patch selection mode
  3. Determine source worktree/branch: a. If user specified --from <worktree>: Use that worktree path directly b. If user specified a branch name: Find worktree for that branch from git worktree list c. If only one other worktree exists: Ask to confirm using it as source d. If multiple worktrees exist: Present list and ask user which to merge from e. If no other worktrees exist: Explain and offer to use branch-based merge instead

  4. Determine merge strategy: Present options based on user's needs:

    Strategy A: Selective File Checkout (for specific files/directories)

    • Best for: Getting complete file(s) from another branch
    • Command: git checkout <branch> -- <path>

    Strategy B: Interactive Patch Selection (for partial file changes)

    • Best for: Selecting specific hunks/lines from a file
    • Command: git checkout -p <branch> -- <path>
    • Prompts user for each hunk: y (apply), n (skip), s (split), e (edit)

    Strategy C: Cherry-Pick with Selective Staging (for specific commits)

    • Best for: Applying a commit but excluding some changes
    • Steps:
      1. git cherry-pick --no-commit <commit>
      2. Review staged changes
      3. git reset HEAD -- <unwanted-files> to unstage
      4. git checkout -- <unwanted-files> to discard
      5. git commit -m "message"

    Strategy D: Manual Merge with Conflicts (for complex merges)

    • Best for: Full branch merge with control over resolution
    • Steps:
      1. git merge --no-commit <branch>
      2. Review all changes
      3. Selectively stage/unstage files
      4. Resolve conflicts if any
      5. git commit -m "message"

    Strategy E: Multi-Worktree Selective Merge (combining from multiple sources)

    • Best for: Taking different files from different worktrees
    • Steps:
      1. git checkout <branch1> -- <path1>
      2. git checkout <branch2> -- <path2>
      3. git commit -m "Merge selected files from multiple branches"
  5. Execute the selected strategy:

    • Run pre-merge comparison if user wants to review (suggest /git:compare-worktrees first)
    • Execute git commands for the chosen strategy
    • Handle any conflicts that arise
    • Confirm changes before final commit
  6. Post-merge summary: Display what was merged:

    • Files changed/added/removed
    • Source worktree/branch
    • Merge strategy used
  7. Cleanup prompt: After successful merge, ask:

    • "Would you like to remove any worktrees to clean up local state?"
    • If yes: List worktrees and ask which to remove
    • Execute git worktree remove <path> for selected worktrees
    • Remind about git worktree prune if needed

Merge Strategies Reference

Strategy Use When Command Pattern
Selective File Need complete file(s) from another branch git checkout <branch> -- <path>
Interactive Patch Need specific changes within a file git checkout -p <branch> -- <path>
Cherry-Pick Selective Need a commit but not all its changes git cherry-pick --no-commit + selective staging
Manual Merge Full branch merge with control git merge --no-commit + selective staging
Multi-Source Combining files from multiple branches Multiple git checkout <branch> -- <path>

Examples

Merge single file from worktree:

> /git:merge-worktree src/app.js --from ../project-feature
# Prompts for merge strategy
# Executes: git checkout feature-branch -- src/app.js

Interactive patch selection:

> /git:merge-worktree src/utils.js --patch
# Lists available worktrees to select from
# Runs: git checkout -p feature-branch -- src/utils.js
# User selects hunks interactively (y/n/s/e)

Cherry-pick specific commit:

> /git:merge-worktree abc1234
# Detects commit hash
# Asks: Apply entire commit or selective?
# If selective: git cherry-pick --no-commit abc1234
# Then guides through unstaging unwanted changes

Merge from multiple worktrees:

> /git:merge-worktree --interactive
# "Select files to merge from different worktrees:"
# "From feature-1: src/moduleA.js"
# "From feature-2: src/moduleB.js, src/moduleC.js"
# Executes selective checkouts from each

Full guided mode:

> /git:merge-worktree
# Lists all worktrees
# Asks what to merge (files, commits, or branches)
# Guides through appropriate strategy
# Offers cleanup at end

Directory merge with conflicts:

> /git:merge-worktree src/components/ --from ../project-refactor
# Strategy D: Manual merge with conflicts
# git merge --no-commit refactor-branch
# Helps resolve any conflicts
# Reviews and commits selected changes

Interactive Patch Mode Guide

When using --patch or Strategy B, the user sees prompts for each change hunk:

@@ -10,6 +10,8 @@ function processData(input) {
   const result = transform(input);
+  // Added validation
+  if (!isValid(result)) throw new Error('Invalid');
   return result;
 }
Apply this hunk? [y,n,q,a,d,s,e,?]
Key Action
y Apply this hunk
n Skip this hunk
q Quit (don't apply this or remaining hunks)
a Apply this and all remaining hunks
d Don't apply this or remaining hunks in this file
s Split into smaller hunks
e Manually edit the hunk
? Show help

Cherry-Pick Selective Workflow

For Strategy C (cherry-picking with selective staging):

# 1. Apply commit without committing
git cherry-pick --no-commit abc1234

# 2. Check what was staged
git status

# 3. Unstage files you don't want
git reset HEAD -- path/to/unwanted.js

# 4. Discard changes to those files
git checkout -- path/to/unwanted.js

# 5. Commit the remaining changes
git commit -m "Cherry-pick selected changes from abc1234"

Multi-Worktree Merge Workflow

For Strategy E (merging from multiple worktrees):

# Get files from different branches
git checkout feature-auth -- src/auth/login.js src/auth/session.js
git checkout feature-api -- src/api/endpoints.js
git checkout feature-ui -- src/components/Header.js

# Review all changes
git status
git diff --cached

# Commit combined changes
git commit -m "feat: combine auth, API, and UI improvements from feature branches"

Common Workflows

Take a Feature File Without Full Merge

> /git:merge-worktree src/new-feature.js --from ../project-feature
# Gets just the file, not the entire branch

Partial Bugfix from Hotfix Branch

> /git:merge-worktree --patch src/utils.js --from ../project-hotfix
# Select only the specific bug fix hunks, not all changes

Combine Multiple PRs' Changes

> /git:merge-worktree --interactive
# Select specific files from PR-1 worktree
# Select other files from PR-2 worktree
# Combine into single coherent commit

Pre-Merge Review

# First review what will be merged
> /git:compare-worktrees src/module.js
# Then merge with confidence
> /git:merge-worktree src/module.js --from ../project-feature

Important Notes

  • Working directory state: Always ensure your working directory is clean before merging. Uncommitted changes can cause conflicts.

  • Pre-merge review: Consider using /git:compare-worktrees before merging to understand what changes will be applied.

  • Conflict resolution: If conflicts occur during merge, the command will help identify and resolve them before committing.

  • No-commit flag: Most strategies use --no-commit to give you control over the final commit message and what gets included.

  • Shared repository: All worktrees share the same Git object database, so commits made in any worktree are immediately visible to cherry-pick from any other.

  • Branch locks: Remember that branches can only be checked out in one worktree at a time. Use branch names for merge operations rather than creating duplicate worktrees.

Cleanup After Merge

After merging, consider cleaning up worktrees that are no longer needed:

# List worktrees
git worktree list

# Remove specific worktree (clean state required)
git worktree remove ../project-feature

# Force remove (discards uncommitted changes)
git worktree remove --force ../project-feature

# Clean up stale worktree references
git worktree prune

The command will prompt you about cleanup after each successful merge to help maintain a tidy workspace.

Troubleshooting

"Cannot merge: working directory has uncommitted changes"

  • Commit or stash your current changes first
  • Or use git stash before merge, git stash pop after

"Merge conflict in "

  • The command will show conflicted files
  • Open files and resolve conflicts (look for <<<<<<< markers)
  • Stage resolved files with git add <file>
  • Continue with git commit

"Commit not found" when cherry-picking

  • Ensure the commit hash is correct
  • Run git log <branch> in any worktree to find commits
  • Commits are shared across all worktrees

"Cannot checkout: file exists in working tree"

  • File has local modifications
  • Either commit, stash, or discard local changes first
  • Then retry the merge operation

"Branch not found for worktree"

  • The specified worktree may have been removed
  • Run git worktree list to see current worktrees
  • Use git worktree prune to clean up stale references

Integration with Other Commands

Pre-merge review:

> /git:compare-worktrees src/
> /git:merge-worktree src/specific-file.js

Create worktree, merge, cleanup:

> /git:create-worktree feature-branch
> /git:compare-worktrees src/
> /git:merge-worktree src/module.js --from ../project-feature-branch
# After merge, cleanup is offered automatically
how to use git:merge-worktree

How to use git:merge-worktree 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:merge-worktree
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:merge-worktree

The skills CLI fetches git:merge-worktree 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:merge-worktree

Reload or restart Cursor to activate git:merge-worktree. Access the skill through slash commands (e.g., /git:merge-worktree) 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.566 reviews
  • Emma Tandon· Dec 28, 2024

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

  • Kaira Reddy· Dec 24, 2024

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

  • Isabella Liu· Dec 4, 2024

    Useful defaults in git:merge-worktree — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Ira Abebe· Dec 4, 2024

    Solid pick for teams standardizing on skills: git:merge-worktree is focused, and the summary matches what you get after install.

  • Isabella Farah· Nov 23, 2024

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

  • Emma Martinez· Nov 23, 2024

    Registry listing for git:merge-worktree matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Olivia Shah· Nov 19, 2024

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

  • Chen Srinivasan· Nov 15, 2024

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

  • Aanya Park· Nov 11, 2024

    Solid pick for teams standardizing on skills: git:merge-worktree is focused, and the summary matches what you get after install.

  • Yash Thakker· Nov 7, 2024

    git:merge-worktree has been reliable in day-to-day use. Documentation quality is above average for community skills.

showing 1-10 of 66

1 / 7