Loading...
Loading...
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 skill4agent add antjanus/skillbox git-worktreegit switch# List all worktrees
git worktree list
# Verbose output with branch info
git worktree list --verbose# 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../project-feature-namegit config worktree.guessRemote true
git config worktree.useRelativePaths true # Requires Git 2.45+cd ../project-feature-name
# Install dependencies, run tests, start Claude, etc.# List all worktrees
git worktree list
# Verbose output with branch and commit info
git worktree list --verbose# 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# 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# 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# 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-namegit worktree remove# List worktrees (shows "prunable" entries)
git worktree list --verbose
# Clean up stale metadata
git worktree prune
**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 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 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# 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# 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"git worktree list