/worktree-ops:merge-worktree [--into <branch>] [--no-merge] [--keep-branch]from worktree-ops
Finish a worktree — commit any remaining work, push, open or update its pull request, optionally merge into a target branch once checks are green, run an optional teardown script, then remove the worktree and switch this session back to the main checkout. Use when the user says a task is "done", wants to "finish", "wrap up", "ship", "merge", "merge and clean up", or "tear down" a worktree, or to close out parallel work and reclaim the checkout. The merge target is configurable; pairs with create-worktree.
Ships in worktree-ops. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Take a worktree from "work is done" to "merged, cleaned up, and back on main" — with as few manual steps as possible. Run it from inside the worktree.
At any step, if a required input is missing or the safe path is ambiguous, stop and use AskUserQuestion before acting — don't assume a default that pushes, merges, or deletes. Confirm when unclear:
--no-merge;--into), when not obvious;git rev-parse --abbrev-ref HEAD
git status --porcelain
Confirm this is the worktree/branch to finish, and whether to merge now or only open/update the PR and stop (--no-merge). The merge target is --into <branch> if given, else the PR's base (default main). Ask with AskUserQuestion if anything is unclear.
/commit-commands:commit-push-pr), defer to it for steps 2–3.git push -u origin HEAD.Author the PR from the actual work — don't lean on --fill, which copies commit messages verbatim (weak title, often an empty body on multi-commit branches). Ground in the diff first:
git log <into>..HEAD --oneline
git diff --stat <into>...HEAD
--title indicative of the change and a --body summarizing what changed and why, then gh pr create --title "<title>" --body "<body>" --base <into>. Fall back to --fill only when the diff is too trivial to summarize.gh pr view --json number,url,title,body,state,isDraft,statusCheckRollup); if new commits changed the scope, update them (gh pr edit --title/--body) so the description still matches what's merging, and gh pr ready if it's a review-ready draft. Then show URL + status.--no-merge)Check readiness first if needed (gh pr view --json number,url,state,statusCheckRollup; if checks are still running, ask whether to wait). Then use the deterministic merge helper — it refuses to squash, sets the target base, merges (merge commit by default; --rebase for linear history), and confirms the PR actually reached MERGED, exiting non-zero otherwise:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/wt-merge.sh" [--into <branch>] [--rebase] [--keep-branch]
Act on the exit code:
/worktree-ops:pull-worktree --from <into> to integrate + resolve (it asks you about anything ambiguous), push, then retry.(--squash is also blocked by this skill's PreToolUse guard, so it can't slip in by hand either.)
Before removing the worktree, run the archive helper. It deterministically runs .claude/worktree-archive.sh if the project has one (tear down external resources: local DBs, Docker, caches) and is a no-op otherwise:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/wt-run-optin.sh" archive
Only run teardown if §4 confirmed the merge (wt-merge.sh exited 0), or the user is deliberately abandoning the worktree. Never tear down after a failed/blocked merge.
If this session created/entered the worktree via EnterWorktree, finish with the ExitWorktree tool: it removes the worktree + branch and switches the session back to the main checkout in one step.
MERGED from §4), pass action: "remove" with discard_changes: true. The merge happened on the remote, so the local branch can still look "unmerged" until you fetch — the guard would otherwise refuse, but the work is safely on the remote.action: "remove" without discard_changes; if it lists uncommitted/unmerged work, relay that and confirm before retrying with discard_changes: true. Never discard silently.--keep-branch or "I might come back" → action: "keep" (returns to main, leaves the worktree on disk).ExitWorktree only touches worktrees this session entered. Otherwise use the helper (it refuses on dirty/unpushed work unless --force); run it from the main checkout:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/wt-teardown.sh" "<path-or-slug>" --delete-branch # unmerged: guards apply
bash "${CLAUDE_PLUGIN_ROOT}/scripts/wt-teardown.sh" "<path-or-slug>" --force --delete-branch # after a confirmed merge
Summarize: commits pushed, PR URL + state, whether it merged into <into>, whether the teardown script ran, and that the worktree + branch were removed and the session is back on the main checkout (or why anything was kept).
What SKILL.md sets; muted values are Claude Code's defaults
sonnethighBash${CLAUDE_PLUGIN_ROOT}/hooks/guard.shnpx claudepluginhub zakattack9/agentic-coding --plugin worktree-ops4 skills in this plugin
/create-worktreeCreate an isolated git worktree for a new task and switch this session straight into it — no restart, no manual cd. Branches fresh from the latest origin base, copies gitignored env files (.worktreeinclude), runs an optional per-project setup script, and can seed from a GitHub issue or PR. Use when the user wants to "create/start/spin up a worktree", "work on this in a separate branch/checkout", kick off isolated/parallel work for a feature or bugfix, or start a task from an issue or PR without disturbing the current checkout./list-worktreesShow a dashboard of every git worktree in this repo — branch, commits ahead/behind the base branch, uncommitted (dirty) file count, and open-PR status — with the current session's worktree marked, so all parallel sessions are visible at a glance. Use when the user asks to "list worktrees", "worktree status", "what worktrees do I have", "show my parallel sessions", "which branches am I working on", or wants an overview of in-flight worktree work before pulling, switching, or merging./pull-worktreePull the latest changes from a base branch into the current worktree — fetch, then rebase (or merge) this worktree's branch onto the newest origin/main (or any branch you name), guiding conflict resolution. Use when the user says a worktree/branch is "behind", wants to "pull in the latest", "catch up", "update", "sync", or "rebase onto main/develop" a worktree before continuing or opening a PR. The base to pull from is configurable, unlike anything native.