/dev-flow:worktreefrom dev-flow
Was the worktree skill (/worktree still works as a phrase). 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.
Ships in dev-flow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
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 you want to work in:
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" list # Show worktrees + branches
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" create <BRANCH> # Existing branch
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" create --new <NEW_BRANCH> # New branch from origin/develop
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" create <BRANCH> --install # Create and install dependencies
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" install <BRANCH> # Install dependencies in an existing worktree
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" remove <BRANCH> # Clean up (refused if there is uncommitted or ignored work)
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" remove --force <BRANCH> # Discards uncommitted work
"${CLAUDE_SKILL_DIR}/scripts/setup-worktree.sh" --help # Full usage
Replace <BRANCH> with a branch name such as feature/story-10.11, and <NEW_BRANCH> with a new name such as story-10.12-new-feature (the script adds the feature/ prefix).
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/). If that directory exists and is not the branch's worktree (another branch's worktree, or a plain directory), it stops with an error.create --new: fetching origin (a failed fetch prints a warning), then branching from origin/develop, else local develop, else the branch origin/HEAD names, else main. The new branch has no upstream; set one on the first push (git push -u).By default, create skips dependency installation and prints the command to run it later. Add --install to either form of create when the user requests installation. The old --no-install flag is accepted for compatibility and has no effect.
With create --install or install <BRANCH>, the script runs npm install in the worktree root and each immediate subdirectory that has a package.json and no node_modules. If any install fails, the script names the affected directories and exits 1. When installation fails during creation, the script still prints the cd command for the new worktree.
remove finds the worktree by branch. If the worktree has uncommitted or untracked work, git refuses and the script exits non-zero. Git-ignored files outside node_modules/ (such as .env or local config) also count as work to keep: the script lists up to 10 of them, says how many more there are, and exits 1. Ask the user before running remove --force: it discards all of that work.
The remove and install commands the script prints start with cd <repo> && and use the absolute path of the script, so they work when pasted from any directory.
The script outputs the exact cd + claude command, quoted so it works when pasted even if the path has a space. Relay this clearly.
The script does not set up Python virtualenvs. See Notes below before dispatching any work in a Python project.
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..git history — commits are visible across all worktreesremove command (or git worktree remove) to clean up when done. The script does not remove a worktree with uncommitted work or git-ignored files (outside node_modules/) unless forced. Plain git worktree remove refuses uncommitted work but deletes ignored files..venv is untracked, so a new worktree
starts without one. Run the project's own venv setup script, if it has one,
before anything else. If a worktree has no .venv, an editable install in the
parent checkout's venv silently resolves imports to the PARENT's source. A test
can then look like it runs against the worktree while it imports another tree.
Check with python -c "import <pkg>; print(<pkg>.__file__)" before dispatching
any work. The path should be inside the worktree, not the main checkout.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub abhattacherjee/claude-code-skills --plugin dev-flow2 skills in this plugin