| name | git-worktree |
| description | This skill manages Git worktrees for isolated parallel development. It handles creating, listing, switching, and cleaning up worktrees with a simple interactive interface, following KISS principles. |
Git Worktree Manager
This skill provides a unified interface for managing Git worktrees across your development workflow. Whether you're reviewing PRs in isolation or working on features in parallel, this skill handles all the complexity.
What This Skill Does
- Create worktrees from main branch with clear branch names
- List worktrees with current status
- Switch between worktrees for parallel work
- Clean up completed worktrees automatically
- Interactive confirmations at each step
- Automatic .gitignore management for worktree directory
- Automatic .env file copying from main repo to new worktrees
CRITICAL: Always Use the Manager Script
NEVER call git worktree add directly. Always use the worktree-manager.sh script.
The script handles critical setup that raw git commands don't:
- Copies
.env, .env.local, .env.test, etc. from main repo
- Ensures
.worktrees is in .gitignore
- Creates consistent directory structure
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-name
git worktree add .worktrees/feature-name -b feature-name main
When to Use This Skill
Use this skill in these scenarios:
- Code Review (
/workflows:review): If NOT already on the target branch (PR branch or requested branch), offer worktree for isolated review
- Feature Work (
/workflows:work): Always ask if user wants parallel worktree or live branch work
- Parallel Development: When working on multiple features simultaneously
- Cleanup: After completing work in a worktree
How to Use
In Claude Code Workflows
The skill is automatically called from /workflows:review and /workflows:work commands:
# For review: offers worktree if not on PR branch
# For work: always asks - new branch or worktree?
Manual Usage
You can also invoke the skill directly from bash:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh switch feature-login
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh copy-env feature-login
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup
Commands
create <branch-name> [from-branch]
Creates a new worktree with the given branch name.
Options:
branch-name (required): The name for the new branch and worktree
from-branch (optional): Base branch to create from (defaults to main)
Example:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login
What happens:
- Checks if worktree already exists
- Updates the base branch from remote
- Creates new worktree and branch
- Copies all .env files from main repo (.env, .env.local, .env.test, etc.)
- Shows path for cd-ing to the worktree
list or ls
Lists all available worktrees with their branches and current status.
Example:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list
Output shows:
- Worktree name
- Branch name
- Which is current (marked with ✓)
- Main repo status
switch <name> or go <name>
Switches to an existing worktree and cd's into it.
Example:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh switch feature-login
Optional:
- If name not provided, lists available worktrees and prompts for selection
cleanup or clean
Interactively cleans up inactive worktrees with confirmation.
Example:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup
What happens:
- Lists all inactive worktrees
- Asks for confirmation
- Removes selected worktrees
- Cleans up empty directories
For workflow examples, see workflow-examples.md.
Key Design Principles
KISS (Keep It Simple, Stupid)
- One manager script handles all worktree operations
- Simple commands with sensible defaults
- Interactive prompts prevent accidental operations
- Clear naming using branch names directly
Opinionated Defaults
- Worktrees always created from main (unless specified)
- Worktrees stored in .worktrees/ directory
- Branch name becomes worktree name
- .gitignore automatically managed
Safety First
- Confirms before creating worktrees
- Confirms before cleanup to prevent accidental removal
- Won't remove current worktree
- Clear error messages for issues
For workflow integration details, see workflow-integration.md.
For troubleshooting, see troubleshooting.md.
For technical details, see technical-details.md.