Enhanced git worktree for Claude Code with custom branch prefix, remote branch tracking, and selective copy for gitignored files.
Claude Code's built-in worktree (claude -w) has three limitations:
- Gitignored files are missing -
.env, config files, etc. are not copied to the worktree - Fixed branch prefix - Branch names always start with
worktree - No remote branch tracking - Always creates a new branch from HEAD, ignoring existing remote branches
This plugin replaces the default WorktreeCreate hook to add:
.worktreeincludefile for specifying which gitignored files/directories to copyWORKTREE_BRANCH_PREFIXenv var for custom branch naming- Remote branch tracking — controlled by
git config worktree.guessRemote(default:true)
claude plugin add ./plugins/worktree-plus# Copy these files to worktrees
.env
.env.local
config/secrets.yaml
# Copy directories
docs/
references/Rules:
- Default behavior: copy with directory structure preserved
- Trailing
/: directory pattern #comments and empty lines are ignored- CRLF line endings are handled automatically
# In your shell profile
export WORKTREE_BRANCH_PREFIX="feat" # Creates feat-<name> branches
export WORKTREE_BRANCH_PREFIX="" # No prefix, just <name>
# Unset = default "worktree-<name>"# Disable automatic remote branch tracking (default: true)
git config worktree.guessRemote falseclaude -w # Creates worktree with gitignored files included
claude --worktree # Same thingWhen creating a worktree, branches are resolved in order:
- Local branch exists → reuse it
guessRemote=true+ remote branch exists onorigin→ fetch and create a tracking branch- No branch found → create a new branch from HEAD
This means claude -w my-feature will automatically track origin/my-feature if it exists remotely, even if there's no local branch yet.
- jq - JSON parsing (
brew install jq) - git - Worktree management