using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans. Creates isolated git worktrees with smart directory selection and safety verification.
When & Why to Use This Skill
The Git Worktrees skill empowers Claude to manage multiple isolated development environments within a single repository. It automates the creation and organization of git worktrees, allowing for seamless context switching between branches without the need for stashing or losing progress. By incorporating safety checks like .gitignore verification and smart directory selection, it optimizes developer productivity and ensures a clean, conflict-free workspace for complex feature implementation.
Use Cases
- Context Switching: Quickly pivot from a long-term feature branch to an urgent bug fix by creating a separate worktree, avoiding the risk of uncommitted change conflicts.
- Parallel Development: Run and test different versions of a codebase simultaneously in separate directories to compare performance or verify fixes across branches.
- Isolated Implementation: Set up a dedicated workspace for executing complex AI-generated implementation plans, ensuring the primary development environment remains stable and untouched.
- Safe Workspace Management: Automatically verify that worktree directories are excluded from version control via .gitignore to prevent accidental commits of environment-specific files.
| name | using-git-worktrees |
|---|---|
| description | Use when starting feature work that needs isolation from current workspace or before executing implementation plans. Creates isolated git worktrees with smart directory selection and safety verification. |
| allowed-tools | Read, Bash, Grep, Glob |
Git Worktrees
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously.
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Quick Start
# Create worktree with new branch
git worktree add .worktrees/feature-auth -b feature/auth
# Create worktree from existing branch
git worktree add .worktrees/bugfix bugfix/issue-123
# List worktrees
git worktree list
# Remove worktree
git worktree remove .worktrees/feature-auth
Directory Selection
- Check existing:
.worktrees/orworktrees/ - Check CLAUDE.md for preference
- Ask user if neither exists
Safety Requirements
Before creating project-local worktree:
# Verify directory is in .gitignore
grep -q "^\.worktrees/$" .gitignore || grep -q "^worktrees/$" .gitignore
If NOT in .gitignore: Add it immediately and commit.
References
- WORKFLOW.md - Detailed workflow steps
- scripts/ - Helper scripts