Creates isolated git worktrees for parallel Claude Code sessions, each on its own branch. Use when: (1) /worktree command, (2) user wants to work on multiple branches simultaneously, (3) user has multiple Claude Code sessions conflicting on the same branch, (4) user asks to set up parallel development.
Multiple Claude Code sessions sharing one working directory fight over the same branch. Git worktrees give each session its own directory and branch while sharing the same repo.
# From the repo root:
~/.claude/skills/worktree/scripts/setup-worktree.sh list # Show worktrees + branches
~/.claude/skills/worktree/scripts/setup-worktree.sh create feature/story-10.11 # Existing branch
~/.claude/skills/worktree/scripts/setup-worktree.sh create --new story-10.12-new-feature # New branch from develop
~/.claude/skills/worktree/scripts/setup-worktree.sh remove feature/story-10.11 # Clean up
~/.claude/skills/worktree/scripts/setup-worktree.sh --help # Full usage
When invoked, follow these steps:
Run the list command to show existing worktrees and available branches.
Use AskUserQuestion with options based on what list returned:
Run the appropriate script command. The script handles:
../repo-name--branch-suffix/)npm install in backend/frontend/mcp-events-server if node_modules is missingThe script outputs the exact cd + claude command. Relay this clearly.
Worktree directories are created as siblings of the repo root:
parent-dir/
repo-name/ # Main working directory
repo-name--story-10.11-view/ # Worktree for feature/story-10.11-view
repo-name--story-10.12-new/ # Worktree for feature/story-10.12-new
node_modules — the script installs them automatically.git history — commits are visible across all worktreesgit worktree remove (or the script's remove command) to clean up when done