ワンクリックで
close-worktree
Use when done working in a git worktree and ready to merge it back to the main branch — asks whether to merge or squash
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when done working in a git worktree and ready to merge it back to the main branch — asks whether to merge or squash
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when the user wants to do a QA session or report multiple bugs — interactive session where bugs are reported conversationally and agents fix them in parallel
Use when executing implementation plans with independent tasks — orchestration pattern for worktree isolation, TDD discipline, and two-stage review. Referenced by execute-plan, fixit, and bugbash.
Use when the user reports a bug or issue that can be fixed without blocking their current work — backgrounds an agent in a worktree to fix and merge back without breaking stride
Use after implementing changes in an OpenSpec project to review implementation against the active change's deltas — auto-fixes confident issues, parks questions for the user
Install the anutron (claude-skills) kit into the current project — symlinks or copies skills, registers hooks, compiles CLAUDE.md from snippets.
Uninstall the anutron (claude-skills) kit from the current project — reverses everything /anutron-install did.
| name | close-worktree |
| allowed-tools | Bash(git *), Bash(ls *), Bash(~/.claude/bin/close-worktree-context.sh:*), AskUserQuestion |
| description | Use when done working in a git worktree and ready to merge it back to the main branch — asks whether to merge or squash |
| tags | ["personal"] |
!~/.claude/bin/close-worktree-context.sh
You must be inside a git worktree (not the main working tree). If not, report: "Not in a worktree. Run this from inside a git worktree." and stop.
Capture these variables (you'll need them for every subsequent step):
WORKTREE_PATH=$(pwd)
WORKTREE_DIR=$(basename "$WORKTREE_PATH")
WORKTREE_BRANCH=$(git branch --show-current)
MAIN_REPO=$(git worktree list | head -1 | awk '{print $1}')
MAIN_BRANCH=$(git -C "$MAIN_REPO" symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||')
if [ -z "$MAIN_BRANCH" ]; then
MAIN_BRANCH=$(git -C "$MAIN_REPO" branch --show-current)
fi
If there are uncommitted changes, stage and commit them with an appropriate message.
Use AskUserQuestion:
Question: "How do you want to merge <WORKTREE_BRANCH> (<N> commits) into <MAIN_BRANCH>?"
Options:
- "Merge (preserve history)"
- "Squash (single commit)"
CRITICAL: Run the merge command targeting the main repo with git -C. Do NOT cd to the main repo — the Bash tool's cwd is pinned to the worktree, and removing the worktree later would brick all subsequent commands.
Stash any uncommitted changes on main:
git -C "$MAIN_REPO" stash 2>/dev/null
Then merge:
If merge mode:
git -C "$MAIN_REPO" merge "$WORKTREE_BRANCH" --no-edit
If squash mode:
git -C "$MAIN_REPO" merge --squash "$WORKTREE_BRANCH"
Then craft a commit message from the branch's overall changes and commit with a Co-Authored-By line:
git -C "$MAIN_REPO" commit -m "..."
If the merge has conflicts:
git -C "$MAIN_REPO" merge --abort, stopVerify the merge landed:
git -C "$MAIN_REPO" log -1 --oneline
If the commit is not there, STOP. Report the failure. Do not proceed.
If successful, restore any stashed changes:
git -C "$MAIN_REPO" stash pop 2>/dev/null
Then report:
Merged <WORKTREE_BRANCH> into <MAIN_BRANCH> (<mode>).
CRITICAL: Do NOT run git worktree remove or git branch -d from this session. The Bash tool's cwd is still inside the worktree directory. Removing it makes the cwd invalid, bricking all further shell commands in this session.
The merge is the critical step — once that succeeds, the work is safe on main. Cleanup is cosmetic and can happen from anywhere.
Tell the user:
Cleanup (run from another terminal):
cd <MAIN_REPO>
git worktree remove .claude/worktrees/<WORKTREE_DIR>
git worktree prune
git branch -d <WORKTREE_BRANCH>