Skill
Git worktree for parallel agents
Create isolated git worktrees for parallel Claude Code / agent windows — git worktree add/remove + auto-dependency-install + cleanup — so multiple agents never conflict on the same repo.
Primitives inside (12)
branch-single-checkout-constraintcalibrationA branch cannot be checked out in two git worktrees at once — `git worktree add` refuses with `fatal: '<branch>' is already used by worktree at '<path>'` (rc=128): plan one branch per parallel agent/worktree and read the refusal as by-design, never as corruption to work around.
When: Planning branch names for multiple concurrent worktrees on one repository; allocating branches to parallel agents; diagnosing a failed worktree add.
dot-git-is-file-in-worktreegotcha-fixIn a linked worktree `.git` is a FILE (a gitdir pointer), not a directory — any tool, hook, or script that assumes a .git/ directory breaks inside worktrees; test with [ -f .git ].
When: Running build tooling, hooks, or .git-path-assuming scripts inside an agent's worktree.
git-dash-c-relative-path-resolutiongotcha-fixA relative path argument under `git -C $REPO` resolves against the -C directory, NOT the caller's cwd — `git -C <repo> worktree add ../worktrees/x` lands sibling to the repo root no matter where the agent runs from.
When: Scripting worktree creation (or other git path-taking commands) from agents whose cwd is unpredictable.
no-auto-install-in-untrusted-reposfailsafeAutomatic dependency install (npm/pip/bundle/go) runs third-party package managers that may execute install scripts and fetch from the network — keep auto-install OFF when the repo is untrusted.
When: A setup automation offers to auto-detect project type and install dependencies after creating a workspace.
no-worktrees-on-submodule-reposfailsafeDo not use multiple worktrees on a repo with submodules — `man git-worktree` BUGS states multiple checkouts of a superproject are NOT recommended (support incomplete).
When: Deciding whether the parallel-worktree pattern applies to a given repository.
worktree-branch-survives-removalgotcha-fixThe branch SURVIVES `git worktree remove` — repeated create/remove cycles silently accumulate orphan branches, and re-running with the same name fails because -b refuses an existing branch; delete with branch -D on the discard path or use -B to reset.
When: Cleaning up after a parallel-agent worktree cycle, especially in loops that reuse worktree names.
worktree-detach-throwawaytool-sequenceFor approaches you expect to discard, create the worktree with --detach (detached HEAD, no branch) — nothing to clean up branch-wise when the losing candidates are removed.
When: The 'N approaches to the same problem' pattern where most worktrees will be thrown away.
worktree-per-parallel-agenttool-sequenceGive each parallel agent its own isolated working tree: from the primary repo run git worktree add <abs-path> -b <branch>, verify with git worktree list, launch the agent cd'd into that directory, and on completion remove via git worktree remove [--force] from the primary repo plus git worktree prune.
When: More than one agent/session must work on the same repository simultaneously without branch conflicts or context bleed.
worktree-prune-stale-metadatatool-sequenceAfter a worktree directory is deleted manually (rm -rf), `git worktree list` marks the entry `prunable`; run `git worktree prune` to clear it immediately (otherwise auto-prune waits for gc.worktreePruneExpire, default 3 months).
When: Repo hygiene after crashed agents or manual deletion of worktree directories.
worktree-refs-sharing-rulescalibrationAcross worktrees: HEAD and pseudo-refs are per-worktree; refs/* are shared EXCEPT refs/bisect, refs/worktree, and refs/rewritten; another worktree's HEAD is addressable as worktrees/<name>/HEAD.
When: Scripting across multiple worktrees (reading sibling agents' HEADs, running bisect, rebase-in-progress states).
worktree-remove-refuses-uncleangotcha-fixgit worktree remove refuses a worktree with uncommitted changes (rc=128); pass --force explicitly when the changes should be discarded — the refusal is a safety default, not an error.
When: Tearing down agent worktrees that may hold uncommitted work.
worktree-repair-after-movetool-sequenceIf the main repo or a linked worktree is moved manually, `git worktree repair` re-establishes the broken metadata links instead of recreating the worktree.
When: A repo or worktree directory was relocated (mv, volume migration) and worktree commands now error.
Get the whole skill
All 12 primitives of this skill as one package, with the order to apply them.
Buy only the primitives you need
Each primitive is 1 credit (≈ €0.10). Pick them from the list above — the button is next to each one.
Upgrade your own skill
Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).
Upgrade my skillNeighbour skills
Skills whose primitives are closest to this one (bge-m3 similarity):