with one click
merge-worktree
// Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message.
// Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message.
세션 변경사항을 분석하여 검증 스킬 누락을 탐지합니다. 기존 스킬을 동적으로 탐색하고, 새 스킬을 생성하거나 기존 스킬을 업데이트한 뒤 CLAUDE.md를 관리합니다.
프로젝트의 모든 verify 스킬을 순차 실행하여 통합 검증 보고서를 생성합니다. 기능 구현 후, PR 전, 코드 리뷰 시 사용.
| name | merge-worktree |
| description | Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message. |
| argument-hint | [target-branch] |
| disable-model-invocation | true |
Squash-merge the current worktree branch back into the target branch with a comprehensive, structured commit message.
!git rev-parse --git-dir!git branch --show-current!git log --oneline -20!git status --shortFollow these phases exactly, in order. Do NOT skip phases.
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
/worktreeto create one first."
Identify current branch: Get the worktree branch name from git branch --show-current.
Resolve target branch:
$ARGUMENTS is provided and non-empty, use it as the target branch.main exists, else check master. If neither exists, stop and ask the user.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).
Clean working tree: Run git status --porcelain. If there are uncommitted changes, stop and tell the user to commit or stash them first.
This is the most critical phase. You must deeply understand what was done before writing any commit message.
Commit history: Run git log --oneline <target>..HEAD to see all commits on this worktree branch.
File change summary: Run git diff <target>...HEAD --stat to get an overview of what files changed and how much.
Full diff: Run git diff <target>...HEAD to read the complete diff. Study it carefully.
Read key files: For the most significantly changed files (largest diffs, new files, deleted files), use the Read tool to understand the full context — not just the diff lines.
Categorize changes: Mentally group all changes into categories:
Identify the dominant type: Determine which conventional commit type (feat, fix, refactor, docs, chore, test) best represents the overall body of work.
Get the original repo path (from Phase 1 step 4).
Check target branch state: Run git -C <original-repo-path> log --oneline -10 <target> to see recent commits on the target branch.
Detect stray WIP commits: If the target branch has commits that look like auto-generated WIP commits (e.g., messages starting with wip:, auto-commit, WIP), warn the user and ask if they want to reset to the last clean commit before merging.
Fetch latest (if remote exists): Run git -C <original-repo-path> fetch origin <target> 2>/dev/null to ensure target is up to date with remote. Do not fail if no remote.
Ensure target branch is checked out in the original repo:
git -C <original-repo-path> checkout <target>
Perform the squash merge:
git -C <original-repo-path> merge --squash <worktree-branch>
Handle conflicts: If the merge reports conflicts:
If the merge succeeds (no conflicts), proceed to Phase 5.
Based on your Phase 2 research, write the commit message following this exact structure:
<type>: <concise summary in imperative mood, under 72 chars, no period>
<2-4 sentence paragraph explaining what was done and WHY. Focus on the
motivation and high-level approach, not implementation details.>
Changes:
- <grouped bullet points of what changed>
- <use sub-bullets for details within a group>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rules:
<type> must be one of: feat, fix, refactor, docs, chore, testCo-Authored-ByCreate the commit in the original repo using a heredoc:
git -C <original-repo-path> commit -m "$(cat <<'EOF'
<your commit message here>
EOF
)"
Confirm the commit: Run git -C <original-repo-path> log --oneline -3 and show the result to the user.
Report summary: Tell the user:
git worktree remove <path> if no longer neededgit push if they want to push to the remote--no-verify).