| name | using-git-worktrees |
| description | Use when starting feature work that needs isolation from current workspace or before executing implementation plans |
Using Git Worktrees
Overview
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.
Core principle: Detect existing isolation first. Then use native tools. Then fall back to git.
Step 0: Detect Existing Isolation
Check if already in an isolated workspace using git rev-parse --git-dir and git rev-parse --git-common-dir.
If GIT_DIR != GIT_COMMON, you are already in a linked worktree. Skip to project setup.
Step 1: Create Isolated Workspace
Prefer native worktree tools. Fall back to git worktree add.
Step 3: Project Setup
Auto-detect and run appropriate setup (npm install, cargo build, pip install, etc.).
Step 4: Verify Clean Baseline
Run tests to ensure workspace starts clean.
Quick Reference
| Situation | Action |
|---|
| Already in linked worktree | Skip creation |
| Native worktree tool available | Use it |
| No native tool | Git worktree fallback |