
Worktree Switch Create
FreeEasily create and switch to a new worktree.
Free · Opens the source repo
What Worktree Switch Create does
The Worktree Switch Create skill enables developers to efficiently manage their Git worktrees by creating a new worktree and switching the current session's working directory to it. This skill is particularly useful for developers who need to isolate their work on different branches or projects without affecting their main working directory. By using this skill, you can streamline your workflow and ensure that your changes are organized and contained within specific worktrees.
When invoked, the skill allows you to specify an optional branch name and repository path. If no branch name is provided, the skill intelligently selects one based on your current task or prompts you for a name. This flexibility ensures that you can quickly set up a worktree tailored to your current development needs. The skill also handles the transition between worktrees seamlessly, allowing you to carry over uncommitted changes by stashing them before switching.
This skill is ideal for developers who frequently work with multiple branches or repositories and need a straightforward way to create and switch worktrees. It simplifies the process of managing workspaces in Git, making it easier to focus on specific tasks without the overhead of manual directory management. Whether you're fixing bugs, developing features, or conducting experiments, this skill enhances your productivity by keeping your work organized and easily accessible.
However, it is important to note that this skill is not suited for users who do not use Git or those who require extensive project management features beyond worktree handling. It is specifically designed for Git workflows and may not be beneficial for other version control systems or for users looking for a comprehensive project management tool.
When to use it
Use this skill when you need to create a new worktree for a specific task or branch in your Git workflow.
When not to use it
Avoid using this skill if you're not working with Git or if you need advanced project management capabilities beyond worktree management.
What you can build with it
Creating a Feature Worktree
When starting development on a new feature, use this skill to create a dedicated worktree for that feature branch, keeping your main branch clean.
Fixing Bugs in Isolation
Use this skill to create a worktree for bug fixes, allowing you to work on the fix without impacting other ongoing developments.
Experimenting with New Ideas
Quickly create a worktree to experiment with new ideas or changes without affecting your current working directory.
How to install Worktree Switch Create
View source1. Install with the skills CLI
npx skills add max-sixty/worktrunk/wt-switch-create --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by max-sixtyArguments: $ARGUMENTS. Grammar: [<branch>] [<repo>] [-- <task>].
- branch — optional; the branch name for the new worktree. When omitted, pick one (step 1 below).
- repo — optional path; 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; any other token is the
branch (docs is a branch name, never the docs/ directory). More than one
branch-shaped token before a -- doesn'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 path 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.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. Common causes: the cwd resolves to no git repo (e.g. a non-git parent like~/workspacethat only holds repos, as in a background job) or to a different repo than the target; or the session is already rooted in a worktree (or is 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→ not reachable. Stop and ask the user to make it reachable: add the repo, or a parent like~/workspace, topermissions.additionalDirectories(durable, every session), or run/add-dir <path>(this session). Then continue. 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. Report its 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.
Frequently asked questions about Worktree Switch Create
Similar skills
Release Candidate Preparation
Streamline your OpenAI Agents release process.
Gitmoji
Generate expressive commit messages with emojis.
GitHub Release
Automate your GitHub library release process effortlessly.
Commit Message Storyteller
Generate meaningful commit messages from your git diffs.
Author Contributions
Trace author contributions across branches in Git.
Implementation Kickoff
Streamline your code implementation process with ease.
