wt-switch-create
max-sixty/worktrunk
Create and switch to a new worktrunk worktree, optionally in another repo.
What is wt-switch-create?
Creates a new git worktree using the worktrunk (`wt`) CLI and switches the session's working directory into it. Use this when starting a session that should operate in its own isolated worktree, with optional support for specifying a branch name, target repository, and an initial task to run.
- Create a new worktree with an optional branch name or auto-pick one from the task context
- Switch the session's working directory into the new worktree in a single operation
- Support creating worktrees in a different repository than the current one
- Carry uncommitted work across worktrees using git stash
- Execute an optional task immediately after entering the worktree
- Handle recovery scenarios when entry is denied or the worktree is unreachable
How to install wt-switch-create
npx skills add https://github.com/max-sixty/worktrunk --skill wt-switch-create- The `wt` CLI must be installed (https://worktrunk.dev)
- Git repository initialized in the current or target directory
- Worktrunk configured with appropriate permissions for the target directories
How to use wt-switch-create
- 1.Call the skill with optional branch name, repo path, and task: `/wt-switch-create [<branch>] [<repo>] [-- <task>]`
- 2.If no branch name is provided, the skill will pick one based on the task or ask you
- 3.The skill creates the worktree and enters it automatically
- 4.If a task is provided after `--`, it executes in the new worktree; otherwise the session waits in the worktree
- 5.Use `wt list` to see all worktrees, and `wt merge` or `wt remove` to clean up when done
Use cases
- Start a feature-branch session with `wt-switch-create my-feature -- implement auth fix`
- Create a worktree in a sibling repo with `wt-switch-create ~/workspace/other-repo -- review docs`
- Launch a session with auto-picked branch name when the task clearly indicates the work
- Move mid-session work to a new worktree by stashing changes and re-rooting
- Create read-only research worktrees that are cleaned up automatically if untouched
- Developers using worktrunk for multi-branch workflows
- Teams managing multiple related repositories
- Engineers who need isolated worktrees for parallel feature work
- Users of Claude Code or Cursor with the worktrunk integration
wt-switch-create FAQ
The skill picks a short, descriptive branch name based on the task you provide, or asks you if there's no clear context.
Yes, pass the repo path or name as an argument (e.g., `wt-switch-create ~/workspace/other-repo`), and the worktree will be created there.
If you named the branch explicitly, the skill will enter the existing branch; if it auto-picked the name, it will choose a different one and retry.
No, the skill uses `git stash` to preserve uncommitted work before switching worktrees, then restores it with `git stash pop` in the new worktree.
The skill provides recovery guidance: you can add the worktree directory to permissions, use `cd` with explicit paths for commands, or ask the user how to proceed.
Full instructions (SKILL.md)
Source of truth, from max-sixty/worktrunk.
name: wt-switch-create
description: Create a new worktrunk worktree (optionally in another repo) and switch this session's working directory into it. Use when launching a session that should work in its own worktree.
argument-hint: "[<branch>] [<repo>] [-- <task>]"
license: MIT OR Apache-2.0
compatibility: Requires the wt CLI (https://worktrunk.dev)
Arguments: $ARGUMENTS. Grammar: [<branch>] [<repo>] [-- <task>].
- branch — optional; the branch name for the new worktree. When omitted, pick one (step 1 below).
- repo — optional path or name; create the worktree in this repo instead of the session's current one.
- task — optional; what to do inside the new worktree. No task means enter the worktree and wait.
Tokens before the -- are the branch and/or repo. A path-shaped token
(starting with /, ~, ./, or ../) is the repo. A bare name can be
either, so make an informed guess. It is the branch when the current repo
already has a branch by that name, as it is for wt switch itself. Otherwise
it is the repo when a git repository by that name exists where the user keeps
repos (beside the current repo, or in a workspace directory like
~/workspace), and the branch when none does (docs is a branch, not the
current repo's docs/ directory). A name read as the repo carries its absolute
path forward: that path, not the bare token, is the <repo> in step 3. Two
tokens that both read as branches don't fit the grammar — ask. Without a --,
judge where the task starts: leading tokens that read as a branch name
(fix-auth) or a repo are consumed as such, and the rest is the task;
otherwise the whole input is the task (fix the parser bug has no
branch-shaped lead — all task).
/wt-switch-create my-feature -- fix the parser bug
/wt-switch-create -- fix the parser bug
/wt-switch-create my-feature ~/workspace/other-repo -- fix the parser bug
/wt-switch-create my-feature
What to do
Creating the worktree comes first on every invocation, before any other work. The invocation is itself the explicit request to create it; a research or read-only task gets one all the same.
<!-- Maintainers: rationale.md (same directory) covers the harness rules and design choices behind this — read it before re-adding guards or routes. -->-
Pick the branch name if none was given: short, from the task and consistent with existing worktree names, or, mid-session, from the work being moved; with nothing to derive from, ask.
-
With no repo argument, create and enter in one call:
EnterWorktree({name: "<branch>"}). Worktrunk'sWorktreeCreatehook runswt switch --create, so the result is an ordinarywtworktree in the default layout, and the user sees no confirmation prompt. On success, do the task (or, with no task text, confirm it's ready and wait).Mid-session, carry uncommitted work across:
git stash push -ubefore theEnterWorktreecall, thengit stash popafter — the call re-roots the session into the new worktree, and the stash is shared across worktrees. -
Otherwise create it with
wtand enter by path. Two cases reach here: a repo argument, which step 2 can't target, and a failed step 2, whose error says which —✗ Branch <branch> already exists, orAlready in a worktree session. Create with aBashcall (omit-C <repo>for this repo):wt -C <repo> switch --create <branch> --no-cd --format=jsonStdout is JSON whose
pathfield is the worktree's absolute path (status lines go to stderr). OnBranch <branch> already exists: if the user named the branch, rerun without--create(it enters the branch, creating its worktree if missing); if step 1 picked the name, pick another and rerun. Any other failure (not a git repo, invalid name): report it and stop.With a repo argument,
cd <repo>next, in its ownBashcall.EnterWorktreere-roots only within the repository the cwd is in, and worktrunk'sPermissionRequesthook answers the confirmation that call asks for only for awtworktree of that same repository. If thecdreportsShell cwd was reset, the repo is unreachable: skip the entry and hand back as in Unreachable below.Then call
EnterWorktree({path: "<path from the JSON>"}).- Accepted → the session is re-rooted in the worktree. Do the task (or, with no task text, confirm it's ready and wait).
- Tool error — the tool ran and returned an error (
Cannot enter worktree: …) → graceful; nothing moved, and one recovery covers them all. The common cause is a session already rooted in a worktree (or a pinned agent), which limits entry to the current repo's.claude/worktrees/and excludes even a same-repowtsibling. The recovery test is whether you cancdinto the worktree, which works when it's inside an allowed directory. Socd <path>and read the result:- no
Shell cwd was resetnotice → it stuck; the worktree is reachable. Work there, but a barecdis not a tracked re-root, so the cwd can revert to the session's launch worktree across turns (and in spawned subagents); pin commands withgit -C <path>/wt -C <path>rather than trusting thecdto persist. Shell cwd was reset→ Unreachable. Stop and ask the user to make the directory whosecdreset reachable: add a parent that holds both the repo and its worktrees, like~/workspace, topermissions.additionalDirectories(durable, every session), or run/add-diron it (this session). Then continue from thatcd. Don't grind through absolute paths withcdresetting on every command.
- no
- Denied — the call itself was refused, with no tool error → however
the denial is worded, it is the user's answer to the confirmation Claude
Code shows for entering a worktree outside
.claude/worktrees/, unless there was no user to ask (the denial says the session couldn't prompt), which decides nothing — take the recovery above. On the user's answer: the worktreewtjust created still exists; only the entry didn't happen.cdback out of the repo you moved into, if any, then report the worktree's path and ask how to proceed, since reaching it throughcdwould override that answer.
Cleanup
The worktree is a normal worktrunk worktree: it shows up in wt list and is
merged or removed with wt merge / wt remove <branch> like any other. Don't
remove it unprompted.
A worktree from step 2 that the session never touched — no changed files, no
commits — is cleaned up when the session ends, branch included; anything
written into it keeps it. A worktree from step 3 always stays. If the user asks
to leave mid-session, ExitWorktree({action: "keep"}) returns the session to
its original directory;
ExitWorktree cannot remove a worktree entered by path, so removing one of
those is always wt remove <branch>.
Scope
The command's mandate is ONE worktree (in the named repo, if one was given) and the requested task inside it. Commits, pushes, and merges still each require explicit user permission.
Related skills
More from max-sixty/worktrunk and the wider catalog.

worktrunk
Guidance for Worktrunk (wt CLI) — git worktree management, hooks, and configuration.

ad-account-diagnostic
Diagnose why paid ads underperform—tracking, targeting, creative, bidding, or external forces—before changing anything.

ad-attribution-gap
Reconcile ad platform, analytics, and CRM/order system reporting gaps by classifying every discrepancy as timing, definitional, or unexplained.

ad-audience-targeting
Turn ICP and buying signals into a layered ad audience targeting plan with exclusion rules and budget allocation.

ad-bidding-strategy
Define bidding policy per platform and goal—manual vs automated, cost vs value targets, with evaluation windows and rollback triggers.

ad-budget-pacing
Track ad spend against budget and flag under/over-pacing with corrective daily spend recommendations.