skills/workflow/git-worktree-isolation/SKILL.md
Use when starting feature work that needs isolation from the current workspace, or before executing implementation plans with multiple tasks.
npx skillsauth add faysilalshareef/dotnet-ai-kit git-worktree-isolationInstall 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.
Isolated workspace + verified baseline = safe experimentation.
Git worktrees create separate working directories sharing the same repository, allowing work on features without polluting the main workspace.
/dai.go)Follow this priority order:
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.
grep -i "worktree" CLAUDE.md 2>/dev/null
If a preference is specified, use it.
If no directory exists and no configuration preference:
No worktree directory found. Where should I create worktrees?
1. .worktrees/ (project-local, hidden)
2. Custom path
Which do you prefer?
MUST verify directory is gitignored before creating worktree:
git check-ignore -q .worktrees 2>/dev/null
If NOT ignored:
.worktrees/ to .gitignoreWhy critical: Prevents accidentally committing worktree contents to the repository.
# Determine branch name from feature
branch_name="feature/$(echo "$FEATURE_NAME" | tr ' ' '-' | tr '[:upper:]' '[:lower:]')"
# Create worktree with new branch
git worktree add ".worktrees/$FEATURE_NAME" -b "$branch_name"
cd ".worktrees/$FEATURE_NAME"
Auto-detect and run appropriate setup:
# .NET Solution
if ls *.sln 1>/dev/null 2>&1; then
dotnet restore
fi
# Python (for tools like this one)
if [ -f pyproject.toml ]; then
pip install -e ".[dev]"
fi
# Node.js (for frontend projects in the solution)
if [ -f package.json ]; then
npm install
fi
Run tests to confirm the worktree starts clean:
# .NET
dotnet build
dotnet test
# Python
pytest
If tests fail: Report failures. Ask whether to proceed or investigate. If tests pass: Report ready.
Worktree ready at .worktrees/{feature-name}
Branch: feature/{feature-name}
Build: OK
Tests: {N}/{N} passing
Ready to implement.
When feature work is done (merged, PR created, or discarded):
# Return to main workspace
cd /path/to/main/repo
# Remove the worktree
git worktree remove .worktrees/{feature-name}
# If branch was merged, clean it up
git branch -d feature/{feature-name}
| Situation | Action |
|-----------|--------|
| .worktrees/ exists | Use it (verify ignored) |
| worktrees/ exists | Use it (verify ignored) |
| Neither exists | Check config, then ask user |
| Directory not ignored | Add to .gitignore + commit |
| Baseline tests fail | Report failures, ask user |
| No solution file | Skip dotnet restore |
| Mistake | Fix |
|---------|-----|
| Skipping ignore verification | Always git check-ignore first |
| Assuming directory location | Follow priority: existing > config > ask |
| Proceeding with failing baseline | Report failures, get explicit permission |
| Forgetting cleanup | Remove worktree after merge/discard |
| Hardcoding setup commands | Auto-detect from project files |
Used by:
/dotnet-ai.implement — set up workspace before executing tasks/dotnet-ai.undo — can discard entire worktree for clean rollbackPairs with:
skills/workflow/verification-gate — verify baseline before startingskills/workflow/sdd-lifecycle — worktree per SDD cycledata-ai
Use when about to claim work is complete, fixed, passing, or ready — before committing, creating PRs, or moving to the next task. Requires running verification commands and confirming output before making any success claims.
development
Use when encountering any bug, test failure, build error, or unexpected behavior — before proposing fixes or making changes.
development
Use when checkpointing, wrapping up, or handing off an AI-assisted development session.
development
Use when following the Specification-Driven Development lifecycle from plan through ship.