/flow:wt-mergefrom flow
Squash-merge the current branch's PR, clean up the worktree, return to main, and report remaining worktree status
Ships in flow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Announce at start: "I'm using the wt-merge skill to squash-merge and clean up."
pwdgit branch --show-currentgit worktree list --porcelaingit status --porcelaingit rev-list '@{u}..HEAD' 2>/dev/null || echo NO_UPSTREAMgh pr view --json number,url,state,title 2>&1 || echo NO_PRflowchart TD
A[Preconditions] -- fail --> STOP
A -- pass --> B[Merge PR]
B --> C[Cleanup + update main]
C --> D[Report]
Only two checks before proceeding — everything else fails naturally with clear
errors from gh pr merge.
| Check | How to detect | Action |
|---|---|---|
| Uncommitted changes | Working tree status is non-empty | STOP — tell user to commit or stash |
| Unpushed commits | Output shows commit SHAs or NO_UPSTREAM | Run git push -u origin HEAD, then continue |
Extract from context above:
| Variable | Source |
|---|---|
{NUMBER} | PR number from PR info |
{MAIN_WORKTREE} | Path of the first entry in the worktree list (the main worktree) |
{WORKTREE_PATH} | Current directory (the feature worktree being removed) |
{BRANCH} | Current branch name |
gh pr merge {NUMBER} --squash
Use the PR number from context. Do NOT use --delete-branch (it tries to switch
branches locally, which fails when the default branch is already checked out in
the main worktree). Branch cleanup is handled in Step 2.
If this fails, STOP and show the error to the user.
CRITICAL: This MUST be a single Bash invocation. After worktree remove
deletes {WORKTREE_PATH}, the shell's CWD no longer exists and ALL subsequent
Bash tool calls will fail. Every command uses git -C to operate from
{MAIN_WORKTREE} regardless of the shell's CWD state.
Do NOT split these into separate Bash calls. Do NOT remove or reorder commands.
git -C {MAIN_WORKTREE} worktree remove --force {WORKTREE_PATH}; git -C {MAIN_WORKTREE} worktree prune; git -C {MAIN_WORKTREE} branch -D {BRANCH} 2>/dev/null; git -C {MAIN_WORKTREE} fetch --prune && git -C {MAIN_WORKTREE} pull --ff-only; echo "===REMAINING WORKTREES==="; git -C {MAIN_WORKTREE} worktree list
Commands are joined with ; (continue regardless of errors) except fetch && pull
which are dependent. Individual failures are tolerated — the branch or worktree
directory may already be gone.
Parse the output from Step 2. Everything after ===REMAINING WORKTREES=== is
the current worktree list.
Summarize:
Then tell the user: "The current directory has been deleted. Please close this session and open a new one from a valid directory."
Do NOT run any further Bash commands or offer follow-up actions — the shell is broken because the CWD was deleted with the worktree.
Never:
Always:
git -C {MAIN_WORKTREE} for all git commands (never cd)What SKILL.md sets; muted values are Claude Code's defaults
4 skills in this plugin
/wt-createUse when starting feature work that needs isolation from current workspace or before executing implementation plans - creates an isolated git worktree with smart directory selection and safety verification/wt-destroyDestroy a worktree — close any PR, delete local and remote branches, and remove the worktree, discarding all uncommitted changes. Optionally takes a branch name argument; defaults to the current worktree./wt-initGenerate a .worktreerc.yml config file for the current project by scanning for environment files, lock files, and dev tooling - use when setting up worktree workflows for a new projectnpx claudepluginhub salimhamed/claude-code-flow --plugin flowOther plugins' skills for the same job