merge-worktreelisted
Install: claude install-skill HyperAITeam/CLITrigger
# Merge Worktree
Squash-merge the current worktree branch back into the target branch with a comprehensive, structured commit message.
## Current context
- Git dir: `!git rev-parse --git-dir`
- Current branch: `!git branch --show-current`
- Recent commits: `!git log --oneline -20`
- Working tree status: `!git status --short`
## Instructions
Follow these phases exactly, in order. Do NOT skip phases.
---
### Phase 1: Validation
1. **Verify worktree**: Check if the current git directory is a worktree. The output of `git rev-parse --git-dir` must contain `/worktrees/`. If it does not, **stop immediately** and tell the user:
> "This skill must be run from inside a git worktree. Use `/worktree` to create one first."
2. **Identify current branch**: Get the worktree branch name from `git branch --show-current`.
3. **Resolve target branch**:
- If `$ARGUMENTS` is provided and non-empty, use it as the target branch.
- Otherwise, detect the default branch: check if `main` exists, else check `master`. If neither exists, stop and ask the user.
4. **Identify the original repo path**: Parse the original repo root from the git-dir path. The worktree's `.git` file points back to the main repo — use `git rev-parse --git-common-dir` to find it, then derive the original repo working directory (its parent).
5. **Clean working tree**: Run `git status --porcelain`. If there are uncommitted changes, stop and tell the user to commit or stash them first.
---
### Phase 2: Research