/agent-traffic-control:concurrent-session-checkout-clobbers-shared-worktreefrom agent-traffic-control
A second Claude Code session (or agent/person) sharing the same working directory runs `git checkout`/`git switch`, flipping the branch for the whole working tree underneath your session and clobbering your uncommitted work. Use when: (1) a file you just edited has silently reverted — often with a "file was modified, either by the user or by a linter" system reminder, (2) `git branch --show-current` shows a branch you didn't switch to, (3) `git reflog` shows a `checkout: moving from X to Y` you never ran, (4) unfamiliar files/changes appear in `git status`. Covers detecting the collision and recovering via an isolated git worktree. Every trigger above is a symptom, so this skill fires only once damage exists; the pre-dispatch check that prevents the fan-out case is a separate skill, `pre-dispatch-agent-isolation-parameter-not-prompt`.
Ships in agent-traffic-control. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
git checkout clobbers your shared working directoryTwo Claude Code sessions (or any two agents/people) operate in the same
working directory on the same clone. git checkout / git switch changes
HEAD for the entire working tree — it is not per-session. When session B
switches branches, session A's tree changes underneath it:
git add -A.It is invisible until something breaks: a function you wrote is "gone", a test errors on a symbol you defined, or a harness emits "file was modified, either by the user or by a linter" for a file you didn't expect to change.
git branch --show-current is not the branch you were working on.git status lists changes or untracked files you don't recognize.git reflog shows checkout: moving from <yours> to <other>
that you never performed.Do not keep fighting inside the shared directory — you will collide again. Isolate into a git worktree.
git reflog -5 reveals the foreign checkout.
git log <your-branch> --oneline confirms your committed work is still safe
on its branch (commits survive a checkout; only uncommitted work is at risk).git worktree add /path/outside/repo/my-worktree <your-branch>
Place it outside the repo (a sibling dir) to avoid .gitignore edits that
would themselves collide.cp the new files you created).git checkout <files-you-modified> and rm your untracked
files (you copied them already).git worktree list shows your isolated worktree on your branch.git status shows only the other session's files.Session A is on feature/config-validation with an uncommitted app/config.py edit.
The parallel session runs git checkout feature/settings-page in the shared repo/.
Session A's app/config.py edit vanishes; git reflog shows
checkout: moving from feature/config-validation to feature/settings-page. Recovery:
git worktree add ../config-worktree feature/config-validation, copy the untracked new
files in, re-apply the lost config.py edit, git checkout app/main.py + rm
the strays in repo/, then EnterWorktree and carry on — committing each task.
Everything on this page is recovery, and every trigger above is a symptom — so if you are the one who fanned agents out believing they were already isolated, nothing here will prompt you to look until the damage exists.
Prose in a dispatch prompt is not configuration. The isolation comes from the dispatch
tool's isolation: "worktree" parameter and from nothing else; a prompt opening "You are
in your OWN isolated git worktree" creates no worktree. The pre-dispatch check for that —
read the call back, and make each agent print git rev-parse --show-toplevel and
git branch --show-current as its first bash call — is
pre-dispatch-agent-isolation-parameter-not-prompt.
It carries the worked example and the tell; it is not repeated here.
index.lock blocks BOTH concurrent sessions (v1.1.0)Symptom: git commit/git add fails with Unable to create '.git/.../index.lock': File exists. Another git process seems to be running. In a shared worktree this often is not an active git
op — it's an orphaned lock from an earlier commit that was killed (e.g. a session interrupted
mid-commit), and it blocks every session sharing the directory, including a parallel one that's
sitting in a retry loop waiting for the lock to clear (so nobody makes progress). Diagnose stale vs
active before removing:
Lock age: python3 -c "import os,time;p='.git/worktrees/<wt>/index.lock';print(round(time.time()-os.path.getmtime(p)))" — a multi-minute-old, 0-byte lock is almost certainly orphaned.
No active git op: ps aux | grep -E '[g]it (commit|add|push|merge|rebase)' returns nothing (a sibling's polling shell loop may appear, but that's not a git op holding the lock — its own args often reveal it's waiting on the same lock).
Then rm -f the lock and commit specific paths with a short retry guard (the sibling may grab
the freed lock first; loop 3–5× with a sleep 2). Removing it unblocks both sessions. Only remove
after both checks pass — deleting a lock held by a live git process corrupts the index.
Prevention: when starting isolated feature work, create a worktree first
(the superpowers:using-git-worktrees skill). Shared-directory work is only safe for a
single session.
A native EnterWorktree tool can enter an already-created worktree by path.
Nothing is permanently lost even if the other session commits your strays — file content survives; you can recover it. But it is messy; isolate early.
superpowers:using-git-worktrees — create an isolated workspace up front.git reflog is the source of truth for "who switched the branch."What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-controlOther plugins' skills for the same job
118 skills in this plugin
/agent-refusal-with-evidence-beats-literal-complianceA dispatched agent that does exactly what you asked can ship a defect you would
have stopped yourself, because it can see something at the worksite that you
could not see when you wrote the brief. Use when: (1) you are writing a brief
that prescribes a specific fix, threshold, wording or value rather than the
outcome you want; (2) an agent reports that it did not do what you asked and
you are deciding whether that is insubordination or judgement; (3) an agent
asserts "this is fine" or "not needed" with no measurement behind it; (4) you
are reviewing overnight output and want to know which decisions were checked
and which were assumed. Two halves, and both are needed: give the agent
explicit permission to satisfy the INTENT of an instruction while refusing its
letter, and REQUIRE the evidence with the refusal — what it built or measured,
what that showed, what it did instead. Evidence is the whole difference between
a refusal you can bank and one you have to re-litigate. Four agents correctly
declined an instruction in a single run; one built the suggested fix, measured
that it turned a silent safe refusal into a permanently red pipeline, and
reverted it unpushed.
/auto-merge-rearms-while-agent-live-kill-then-disarm-verify