| name | merge-worktree |
| description | Merge current worktree branch into the original branch, resolve conflicts with AI, then mark worktree for cleanup. Use when the user says "merge this worktree", "merge my branch back", or "finish this worktree." |
Merge Worktree
Merge the current worktree's branch into the original (parent) branch. Resolves merge conflicts intelligently. Marks the worktree for cleanup after successful merge.
Instructions
1. Detect Context
Run these commands to understand the current state:
git rev-parse --git-common-dir
git rev-parse --git-dir
git rev-parse --show-toplevel
git rev-parse --abbrev-ref HEAD
git worktree list --porcelain
Determine:
WORKTREE_NAME: extracted from current branch (strip worktree- prefix) or directory name
WORKTREE_BRANCH: current branch (e.g., worktree-bold-fox-gjac)
MAIN_TREE_PATH: path of the main worktree (first entry in git worktree list)
PARENT_BRANCH: branch checked out in the main worktree
If NOT in a worktree, tell the user and exit. This skill is designed to run from inside a worktree session.
2. Pre-merge Check
git status --porcelain
If there are uncommitted changes:
.claude/settings.json: This file is auto-managed by Claude Code at runtime. Deep-compare (parse JSON, compare key-value pairs ignoring order) against the committed version. If semantically equivalent, it. If there are real value differences, it anyway — runtime settings changes are ephemeral and should not be merged.