Quickly spin up isolated Claude Code sessions using git worktrees.
- Creates a git worktree for your feature branch
- Opens Claude Code with
--dangerously-skip-permissionsin that worktree - Tab completion for existing worktrees and branches
-
Download the script to your PATH:
mkdir -p ~/bin curl -o ~/bin/claude-work-tree https://gist.githubusercontent.com/TheBaconWizard/9883ce7255ae6c972b7be73016d27c8a/raw/claude-work-tree chmod +x ~/bin/claude-work-tree
-
Add to your
.zshrc:export PATH="$HOME/bin:$PATH" alias cwt="claude-work-tree" eval "$(claude-work-tree --completions)"
-
Reload your shell:
source ~/.zshrc
# Create new branch + worktree and open Claude
cwt feature-branch
# Open existing worktree
cwt existing-branch
# Tab completion shows available worktrees and branches
cwt <tab>Worktrees are created at ../repo-name-worktrees/branch-name relative to your repo.
This script enables --dangerously-skip-permissions for faster workflows. For protection against destructive commands, install claude-code-safety-net:
/plugin marketplace add kenryu42/cc-marketplace
/plugin install safety-net@cc-marketplace
The script will warn you if this plugin isn't installed.