Team Worktree — Isolate the Implementation
Create a git worktree per involved repository so implementation happens on
isolated branches without affecting any main working tree. In single-repo
mode (the default) this is one worktree in the home repo. In multi-repo
mode (when docs/plans/<id>/4-repos.md is present) it is one worktree per
listed repo, all sharing the same <id> branch name.
Core contracts
- Detect a linked checkout with
git rev-parse --git-dirandgit rev-parse --git-common-dir. - Non-default branch in an existing linked checkout → skip worktree creation for this repo.
- Default branch → report and stop.
- In single-repo mode run
git worktree add .claude/worktrees/<branch>. - For every
4-repos.mdentry rungit -C <repo> worktree add .claude/worktrees/<branch>. - Record every created path under
## Worktreesin4-repos.md.
Procedure references
Read each reference completely when reaching that stage. Follow them in order; later stages depend on state and gates established earlier.
- Input
- Detect mode
- Detect existing worktree
- Execution