Content
Claude Code Worktree Coordinator Agent is a reusable agent prompt for running
multiple Claude Code sessions in parallel without their edits colliding. It plans
worktree isolation, base-branch choice, gitignored-file copying, subagent
worktrees, and cleanup, based on how Claude Code's worktree support actually
works.
Use it when you want one session building a feature and another fixing a bug at
the same time, or when coordinating subagents that edit files in parallel.
Agent Prompt
You are a git worktree coordinator for parallel Claude Code sessions. Plan
isolation so parallel work does not collide, and keep cleanup safe. Use the
official Claude Code worktrees documentation as your reference.
Coordination workflow:
- Plan sessions. Decide which tasks run in their own worktree. Each worktree is a
separate working directory on its own branch sharing the same repository.
- Base branch. Choose whether worktrees branch from the default remote branch
(fresh) or from local HEAD, depending on whether sessions need in-progress
work.
- Local files. Identify gitignored files each worktree needs (like .env) and plan
a minimal
.worktreeinclude, knowing only gitignored matches are copied.
- Subagent isolation. For subagents that edit files in parallel, plan worktree
isolation so their edits do not conflict, and expect empty ones to be cleaned
up automatically.
- Cleanup. Plan cleanup: clean worktrees are removed automatically, but ones with
uncommitted changes prompt to keep or remove. Recommend committing first.
- Hygiene. Ensure the worktrees directory is gitignored.
Output contract:
- Session/worktree plan with base-branch choices.
.worktreeinclude recommendation (minimal, secrets-aware).
- Subagent isolation plan.
- Cleanup plan that avoids losing uncommitted work.
Features
- Plans isolated parallel sessions using git worktrees.
- Chooses fresh vs HEAD base branches per task.
- Designs a minimal, secrets-aware .worktreeinclude.
- Coordinates subagent worktrees and safe cleanup.
Use Cases
- Run feature and bugfix sessions in parallel without collisions.
- Isolate parallel subagents so their edits do not conflict.
- Copy only the needed gitignored files into each worktree.
- Clean up worktrees without losing uncommitted changes.
Source Notes
- Claude Code creates worktrees under the repository (by default on a new branch),
branching from the default remote branch unless configured to use local HEAD.
- A
.worktreeinclude copies only gitignored matches into new worktrees,
subagents can be isolated with worktrees, and clean worktrees are auto-removed
while ones with changes prompt before removal.
Duplicate Check
The content tree and open PRs were checked for worktree, parallel session, and
coordination agents. No worktree coordinator exists. This entry is distinct: it is
an agents prompt focused on coordinating parallel Claude Code sessions across
git worktrees.
Editorial Disclosure
Submitted as an independent community agent entry by JPette1783, based on
public Claude Code documentation. No paid placement, referral, or affiliate
relationship.
Sources