Overview
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
Core principle: Systematic directory selection + safety verification = reliable isolation.
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Directory Selection Process
Follow this priority order:
1. Check Existing Directories
ls -d .worktrees 2>/dev/null # Preferred (hidden)
ls -d worktrees 2>/dev/null # Alternative
If found: Use that directory. If both exist, .worktrees wins.
2. Check CLAUDE.md
grep -i "worktree.*director" CLAUDE.md 2>/dev/null
If preference specified: Use it without asking.
3. Ask User
If no directory exists and no CLAUDE.md preference, ask where to create worktrees.
Safety Verification
MUST verify directory is ignored before creating worktree:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
If NOT ignored: Add to .gitignore and commit first.
Why critical: Prevents accidentally committing worktree contents to repository.
Creation Steps
# Create worktree with new branch
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
# Auto-detect and run project setup
if [ -f package.json ]; then npm install; fi
if [ -f Cargo.toml ]; then cargo build; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Verify clean baseline
npm test # or appropriate test command
If tests fail: Report failures, ask whether to proceed or investigate.
Quick Reference
| Situation | Action |
|---|---|
.worktrees/ exists |
Use it (verify ignored) |
worktrees/ exists |
Use it (verify ignored) |
| Both exist | Use .worktrees/ |
| Neither exists | Check CLAUDE.md → Ask user |
| Directory not ignored | Add to .gitignore + commit |
Red Flags
Never:
- Create worktree without verifying it's ignored (project-local)
- Skip baseline test verification
- Proceed with failing tests without asking
- Assume directory location when ambiguous
Integration
Called by:
- brainstorming — REQUIRED when design is approved
- subagent-driven-development — REQUIRED before executing any tasks
- executing-plans — REQUIRED before executing any tasks
Pairs with:
- finishing-a-development-branch — REQUIRED for cleanup after work complete
Mirrored from https://github.com/obra/superpowers — original author: obra, license: MIT. This is an unclaimed mirror. Content and ownership transfer to the author when they claim this account.