skills/git-worktree/SKILL.md
Use when you need to work on multiple branches simultaneously, run parallel Claude Code sessions, handle emergency hotfixes during feature work, review PRs without switching branches, or test across branches without losing current work. Use when asked to "work on two branches at once", "parallel development", "switch without losing work", "create a worktree", or "hotfix while working on a feature".
npx skillsauth add antjanus/skillbox git-worktreeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Git worktrees enable multiple working directories from a single repository. Each worktree has its own branch while sharing the same Git object database.
Core principle: Check worktree status, create worktree for parallel work, reference cleanup commands as needed.
Use worktrees when:
Avoid when:
git switch instead)Before creating a worktree, check what already exists:
# List all worktrees
git worktree list
# Verbose output with branch info
git worktree list --verbose
Basic creation:
# Create worktree with new branch from HEAD
git worktree add ../project-feature-name -b feature-name
# Create from specific base branch
git worktree add ../project-hotfix -b hotfix-critical origin/main
# Create from existing remote branch
git worktree add ../project-review pr-123
Tip: Place worktrees outside the repo directory (e.g., ../project-feature-name) so they aren't tracked by Git.
Recommended configuration (run once):
git config worktree.guessRemote true
git config worktree.useRelativePaths true # Requires Git 2.45+
Navigate to the worktree and work normally:
cd ../project-feature-name
# Install dependencies, run tests, start Claude, etc.
These commands are available for managing worktrees. Surface these to the user when relevant:
List worktrees:
# List all worktrees
git worktree list
# Verbose output with branch and commit info
git worktree list --verbose
Remove worktrees:
# Remove a worktree (must have no uncommitted changes)
git worktree remove ../project-feature-name
# Force remove (discards uncommitted changes)
git worktree remove -f ../project-feature-name
Prune stale worktrees:
# Clean up metadata for manually deleted worktrees
git worktree prune
# Dry run to see what would be pruned
git worktree prune -n
# Repair a disconnected worktree
git worktree repair ../project-feature-name
Cause: Can't checkout same branch in multiple worktrees.
Solution:
# Check which worktree has it
git worktree list | grep branch-name
# Create new branch from same base instead
git worktree add ../new-path -b branch-copy origin/branch-name
Cause: Can't remove worktree with uncommitted changes.
Solution:
# Commit or stash changes first
cd ../project-feature-name
git add . && git commit -m "Final changes"
# Or force remove (discards changes)
git worktree remove -f ../project-feature-name
Cause: Manually deleted worktree directory without git worktree remove.
Solution:
# List worktrees (shows "prunable" entries)
git worktree list --verbose
# Clean up stale metadata
git worktree prune
git worktree add ../myproject-auth -b feature/auth cd ../myproject-auth
npm install npm test
**Why this is good:** Checks existing worktrees, uses descriptive naming, verifies setup before work.
</Good>
<Bad>
```bash
# Create worktree without checking existing ones
git worktree add ../temp -b temp
cd ../temp
Why this is bad: No verification of existing worktrees, vague naming makes tracking difficult, no setup verification. </Bad>
npm test git add . git commit -m "Fix payment processor race condition" git push -u origin hotfix/payment-bug
cd ../myproject git worktree remove ../myproject-hotfix
**Why this is good:** Branches from correct base (main), tests before committing, cleans up after.
</Good>
<Bad>
```bash
# Create hotfix from current feature branch
git worktree add ../fix -b fix
cd ../fix
# Make changes, forget to clean up
Why this is bad: Wrong base branch (includes feature work), vague naming, no cleanup. </Bad>
npm install npm test
cd ../myproject git worktree remove ../myproject-pr-123
**Why this is good:** Fetches PR properly, uses PR number in path, cleans up after review.
</Good>
<Bad>
```bash
# Try to checkout PR in main worktree
git checkout pr-123 # Loses current work
Why this is bad: Switches branch in main worktree, loses current state, forces stashing. </Bad>
This skill enables:
Pairs with:
Integration pattern with track-session:
# Create worktree
git worktree add ../myproject-feature -b feature/new-api
cd ../myproject-feature
# Create independent progress tracking
echo "# Session Progress - New API Feature" > SESSION_PROGRESS.md
# Start Claude session named "myproject - New API Feature"
# Work proceeds with independent progress tracking
Multi-worktree workflow:
# Terminal 1: Feature work in main worktree
cd ~/myproject
# Claude session: "myproject - main"
# Terminal 2: Hotfix in separate worktree
cd ~/myproject-hotfix
# Claude session: "myproject - hotfix"
# Terminal 3: PR review in separate worktree
cd ~/myproject-pr-123
# Claude session: "myproject - PR review"
Best practices:
git worktree list to see all active workdevelopment
EXPERIMENTAL. Mine recent Claude Code transcripts for friction events, cluster them by active skill, propose patches for skills with 3+ friction events, validate each patch via headless replay, scrub the report through /publish-check, and present an EVOLUTION_REPORT.md for human review on a branch (never auto-merge). Use when asked to "evolve my skills", "audit skills against recent friction", "propose skill improvements from transcripts", "run the skill evolution pipeline", or as part of a weekly skill-quality cadence.
testing
Manual QA tracking — things tests can't verify. Use when asked to "create a QA list", "set up QA for this project", "what should I QA", "track manual QA", "audit the QA list", or "start manual QA".
development
Multi-source web research with cited synthesis in chat. Use when asked to "research X", "deep research on Y", "deep dive on Z", "investigate this topic", "compare X and Y", "pros and cons of X", or "survey the landscape of Y".
development
Use this skill whenever the user wants a multi-agent review of local changes — triggers include "review my code", "review these changes", "do a code review", or "check my changes before I commit". Writes REVIEW.md. Do NOT use for an open PR by number (use /review) or a security-specific pass (use /security-review).