plugins/coordinator/skills/using-git-worktrees/SKILL.md
Use when starting feature work that needs true branch-level isolation (separate PRs, different base branches, long-lived parallel features) - NOT for avoiding file conflicts during parallel agent dispatch (use sequential execution instead)
npx skillsauth add oduffy-delphi/coordinator-claude using-git-worktreesInstall 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.
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 coordinator:using-git-worktrees skill to set up an isolated workspace."
Follow this priority order:
# Check in 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.*director" CLAUDE.md 2>/dev/null
If preference specified: Use it without asking.
If no directory exists and no CLAUDE.md preference:
No worktree directory found. Where should I create worktrees?
1. .worktrees/ (project-local, hidden)
Which would you prefer?
MUST verify directory is ignored before creating worktree:
# Check if directory is ignored (respects local, global, and system gitignore)
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
If NOT ignored:
<!-- Review: Patrik — removed stale attribution artifact -->Fix broken things immediately:
Why critical: Prevents accidentally committing worktree contents to repository.
project=$(basename "$(git rev-parse --show-toplevel)")
# Sync-main invariant: ensure local main == origin/main before branching.
~/.claude/plugins/coordinator-claude/coordinator/bin/sync-main.sh
# If sync-main.sh exits non-zero, stop — do not create a worktree from stale main.
# Determine full path
path="$LOCATION/$BRANCH_NAME"
# Create worktree with new branch off the now-current main
git worktree add "$path" -b "$BRANCH_NAME" main
cd "$path"
Auto-detect and run appropriate setup:
# Node.js
if [ -f package.json ]; then npm install; fi
# Rust
if [ -f Cargo.toml ]; then cargo build; fi
# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi
# Go
if [ -f go.mod ]; then go mod download; fi
Run tests to ensure worktree starts clean:
# Examples - use project-appropriate command
npm test
cargo test
pytest
go test ./...
If tests fail: Report failures, ask whether to proceed or investigate.
If tests pass: Report ready.
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>
| 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 |
| Tests fail during baseline | Report failures + ask |
| No package.json/Cargo.toml | Skip dependency install |
Parallel worktrees each see only the parent commit at the moment of branching — they do not receive subsequent commits made to the parent branch while they are in flight.
The hazard: If chunk A's worktree merges its changes to main while chunk B's worktree is still running, chunk B has no visibility into A's landed changes. When B returns, applying its diff blindly will overwrite or conflict with A's work — even on lines where both made changes that "shouldn't" conflict.
Two valid resolutions:
Sequence dependent chunks — don't parallelize them. If chunk B depends on or overlaps with chunk A's output, run B after A has landed and merged. Parallelism is only safe for truly disjoint file sets.
Superset + dedupe on return. When chunks have unavoidable overlap (discovered after the fact), take the superset of both changes and deduplicate — never blindly apply chunk B's diff over chunk A's landed change. The later chunk's version is not automatically correct; review the overlap and keep the right content from each.
Prefer option 1 at design time. Detecting overlap after both chunks are in flight and attempting superset reconciliation is significantly more expensive than sequencing correctly upfront.
git check-ignore before creating project-local worktreeYou: I'm using the coordinator:using-git-worktrees skill to set up an isolated workspace.
[Check .worktrees/ - exists]
[Verify ignored - git check-ignore confirms .worktrees/ is ignored]
[Create worktree: git worktree add .worktrees/auth -b feature/auth]
[Run npm install]
[Run npm test - 47 passing]
Worktree ready at /Users/jesse/myproject/.worktrees/auth
Tests passing (47 tests, 0 failures)
Ready to implement auth feature
Never:
Always:
Called by:
<!-- Review: Patrik — removed ghost callers; brainstorming doesn't invoke this skill; subagent-driven-development no longer exists -->Pairs with:
tools
Orient session — preflight, load context, choose work
documentation
Wrap up finished work — capture lessons, update docs
development
Triangulate plan-claim / code-reality / review oracles to classify each plan into DELIVERED+REVIEWED / DELIVERED-UNREVIEWED / PARTIAL / IN-FLIGHT / ABANDONED. Run after any crash or 'did we actually finish what we think we finished?' moment.
testing
Check for a published coordinator update and advise a preserve-by-default migration path — never a blind overwrite.