skills/generic/git-worktrees/SKILL.md
Git worktree management for parallel agent team development. Triggers: 'create worktree', 'worktree setup', or during /delegate dispatch. Do NOT use for branch creation without delegation context.
npx skillsauth add lvlup-sw/exarchos 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.
Create and manage isolated git worktrees for parallel development tasks.
Activate this skill when:
delegate with parallelizable tasksPriority Order:
.worktrees/ - If exists and gitignoredworktrees/ - If exists and gitignoredCLAUDE.md for project conventionsSafety Check (REQUIRED):
# Verify directory is gitignored before creating
git check-ignore -q .worktrees && echo "Safe" || echo "NOT GITIGNORED"
If not gitignored, add to .gitignore:
.worktrees/
# Create feature branch
git branch feature/task-name main
# Create worktree
git worktree add .worktrees/task-name feature/task-name
# Verify creation
git worktree list
Naming Convention: .worktrees/<task-id>-<brief-name>
.worktrees/001-user-auth.worktrees/002-api-endpointsSee references/commands-reference.md for the full environment setup table and scripts per project type.
Run baseline tests to ensure the worktree is ready:
exarchos_orchestrate({
action: "verify_worktree_baseline",
worktreePath: ".worktrees/task-name"
})
The script auto-detects project type (Node.js, .NET, Rust) and runs the appropriate test command.
On passed: true: Baseline tests pass — worktree is ready for implementation.
On passed: false: Baseline tests failed or unknown project type — investigate before proceeding.
If baseline fails:
Subagents work in worktree directory:
# After PR merged, remove worktree
git worktree remove .worktrees/task-name
# Optionally delete branch
git branch -d feature/task-name
# Prune stale worktree refs
git worktree prune
See references/commands-reference.md for parallel worktree creation examples, tracking format, and the full commands reference table.
Subagents MUST verify they're in a worktree before making changes. Working in the main project root causes:
Run the worktree verification script before any file modifications:
exarchos_orchestrate({
action: "verify_worktree"
})
To check a specific path instead of the current directory:
exarchos_orchestrate({
action: "verify_worktree",
cwd: "/path/to/.worktrees/task-name"
})
On passed: true: In a valid worktree — proceed with implementation.
On passed: false: NOT in a worktree — STOP immediately, do not modify files.
Include in all implementer prompts:
## CRITICAL: Worktree Verification (MANDATORY)
Before making ANY file changes, run:
exarchos_orchestrate({ action: "verify_worktree" })
If `passed: false`: STOP and report error.
DO NOT proceed with any modifications outside a worktree.
| Don't | Do Instead |
|-------|------------|
| Create worktrees in tracked directory | Use gitignored .worktrees/ |
| Skip baseline test verification | Always verify tests pass first |
| Leave stale worktrees | Clean up after merge |
| Forget dependency installation | Run project setup in each worktree |
| Mix work across worktrees | One task per worktree |
When delegation skill spawns parallel tasks:
When a subagent completes a task in its worktree, the workflow's HSM transitions from delegate to feature/merge-pending. Because the integration branch is shared — sibling worktree merges can race for it — serialize_merge is the integration-merge path: it holds a single-writer per-integrationRef lease, then composes merge_orchestrate to land the worktree's branch onto the integration branch via a local git merge with a recorded recovery-point SHA — see @skills/merge-orchestrator/SKILL.md for the full handoff protocol. Do not dispatch raw merge_orchestrate for this integration merge (a live foreign lease makes it fail closed); raw merge_orchestrate is for a non-integration merge or a crash-resumed caller re-presenting its original lease.
Worktree cleanup (step 7 above) runs after the merge reports phase: 'completed'.
This is not the same as the synthesize-phase remote PR merge (merge_pr). serialize_merge / merge_orchestrate operate on local refs in the main worktree; merge_pr calls the VCS provider once the integration branch is ready for the human-review PR.
For worktree setup:
For worktree cleanup:
testing
Create pull request from completed feature branch using GitHub-native stacked PRs. Use when the user says 'create PR', 'submit for review', 'synthesize', or runs /synthesize. Validates branch readiness, creates PR with structured description, and manages merge queue. Do NOT use before review phase completes. Not for draft PRs.
testing
Shepherd PRs through CI and reviews to merge readiness. Operates as an iteration loop within the synthesize phase (not a separate HSM phase). Uses assess_stack to check PR health, fix failures, and request approval. Triggers: 'shepherd', 'tend PRs', 'check CI', or /shepherd.
development
Single adversarial review pass over the integrated branch diff — spec-compliance, code quality, and test adequacy judged together by one fresh-context reviewer. Triggers: /review, 'review the changes', or after delegation completes. Emits one verdict (reviews.review.status). Do NOT use for plan-review (that is its own dispatched gate) or for debugging.
testing
Restore and read workflow state after a context break — re-inject workflow phase, task progress, and behavioral guidance into the current session, reconcile state against git reality, and verify whether a workflow exists. Use when the user says 'resume', 'rehydrate', 'where were we', or runs /rehydrate, or when the agent has drifted after context compaction. Do NOT use for saving or mutating state (that is /checkpoint).