using-git-worktreeslisted
Install: claude install-skill petermcalister/shared-skills
# Using Git Worktrees
Create isolated workspaces sharing the same repository — work on multiple branches
simultaneously without switching.
## Directory Selection
Follow this priority:
1. **Check existing directories:** `.worktrees/` (preferred) or `worktrees/`
2. **Check CLAUDE.md** for a worktree directory preference
3. **Ask the user** — suggest `.worktrees/` (project-local, hidden) or a global location
## Safety Verification
For project-local directories, verify the worktree directory is gitignored before
creating anything — unignored worktree contents pollute git status and risk accidental commits.
```bash
git check-ignore -q .worktrees 2>/dev/null
```
If not ignored: add to `.gitignore` and commit before proceeding.
Global directories (outside the project) don't need this check.
## Creation Steps
### 1. Create the worktree
```bash
project=$(basename "$(git rev-parse --show-toplevel)")
git worktree add .worktrees/$BRANCH_NAME -b $BRANCH_NAME
cd .worktrees/$BRANCH_NAME
```
### 2. Run project setup
Auto-detect from project files:
```bash
[ -f package.json ] && npm install
[ -f pyproject.toml ] && uv sync
[ -f Cargo.toml ] && cargo build
[ -f go.mod ] && go mod download
[ -f requirements.txt ] && pip install -r requirements.txt
```
### 3. Verify clean baseline
Run the project's test suite to confirm the worktree starts clean:
```bash
# Use the project-appropriate test command
npm test / pytest / cargo test / go test ./...
```
If tests fail: report the fail