/agent-traffic-control:worktree-does-not-isolate-shared-installed-artefactsfrom agent-traffic-control
A git worktree isolates the SOURCE TREE and nothing else. Anything installed or cached under a key that is not the worktree path — a simulator keyed by bundle id, DerivedData keyed by project path, a plugin cache keyed by version string, a venv keyed by package name — is shared by every worktree on the machine, so a build/test/run in one worktree can silently exercise ANOTHER worktree's artefact. Use when: (1) a test result contradicts one you already trust, or reports values from a build you reverted; (2) suites you never touched fail, or a "clean worktree" baseline disagrees with a full run; (3) two runs that should differ produce identical output, or a fix appears to have no effect; (4) several sessions/worktrees build the same app on one machine. Fix: check PROVENANCE (bytes and compiled-in source paths), not version labels; uninstall/pin the shared artefact rather than trusting a rebuild; and verify a staleness fix the way you verified the staleness.
Trending skills
7-day visitors to each skill page
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.
Worktrees make source isolation cheap, which makes it easy to believe the whole build is isolated. It is not. The worktree is one input; every other input is keyed by something else and is therefore shared by every worktree on the machine:
| keyed by | shared artefact |
|---|---|
| package name | venv / editable install (see verify-pytest-imports-worktree-not-primary-checkout) |
| bundle id | an installed app on a simulator/emulator/device |
| project path or a hash of it | build caches (Xcode DerivedData, gradle, cargo target dirs) |
| version string | a plugin/tool cache directory |
| port | a dev server another worktree started |
So a run in worktree A can exercise worktree B's artefact, and nothing in the output says so. There is no crash and no blank — just a confident, complete, internally consistent answer about the wrong code.
Each of these caches is keyed on identity the worktree does not participate in.
A simulator holds one app per bundle id, so whichever worktree installed
last wins and the next xcodebuild test may reuse it. A tool cache directory
named for a version is refreshed on the version, so republishing the same
version leaves stale content behind a correct-looking label.
The three worst properties, in order:
1. Check provenance, not labels. A version number, a directory name and a filename are labels; a label matching is not evidence the contents match.
md5 -q "$BUILT/App" ; md5 -q "$INSTALLED/App" # bytes, not names
diff -q <(git show HEAD:path/to/file) cache/path/to/file
Best of all, use identity the toolchain compiled in. Test frameworks print the source path recorded at compile time; if it names another worktree, the run is void:
grep -oE "/[^:]*/Tests/[A-Za-z]+\.(swift|py|ts)" run.log | sed 's|/Tests/.*||' | sort -u
2. Prevent rather than detect, where the artefact is an install:
xcrun simctl uninstall "$UDID" com.example.app # before every run
3. Pin the shared cache to this worktree where the tool allows it
(-derivedDataPath, PYTHONPATH, CARGO_TARGET_DIR, GRADLE_USER_HOME).
4. When two results contradict each other, stop reasoning and look. Install the built artefact somewhere fresh and observe it directly. This is minutes and it terminates the argument.
One machine, ten worktrees, one iOS app, 2026-08-05. The same shape three times:
xcodebuild test printed ** TEST SUCCEEDED **
having executed zero cases — an -only-testing: filter naming a method
the built bundle predated matches nothing, and matching nothing is not an
error.xcodebuild believed it
had replaced, through a clean and a simctl erase: seven failing suites
plus a layout guard reporting the exact values of a build reverted an hour
earlier. The same build, installed by hand on a second simulator and
photographed, was correct. Then a clean-worktree baseline ran test bundles
built by two other worktrees and was silently void — caught only because
the failure messages carried their compiled-in source paths.1.14.1 held
content 44 lines short of the published 1.14.1, so a skill step written the
day before was not running. While syncing it, the session copied 1.14.2's
content into the 1.14.1 directory — recreating "same version string,
different content", the defect it had just spent twenty minutes diagnosing.The run that got polluted was the one that bypassed the wrapper doing the uninstall. Use your own tooling, especially when you are in a hurry.
simctl erase does not guarantee a fresh install on the next run; it was
observed not to.verify-pytest-imports-worktree-not-primary-checkout — the same
failure in Python; this skill is its generalisation.prove-test-failures-pre-existing-via-clean-worktree — the right method for
"mine or pre-existing?", and the one whose baseline this pattern can void.concurrent-session-checkout-clobbers-shared-worktree, superpowers:using-git-worktrees.leg-guard — the machine is the shared artefact this
skill is about, and the one nothing isolates. A worktree gives you a private
source tree and no private CPU, RAM or disk, so two sessions' test runs collide
however cleanly their trees are separated. This hook refuses to start a second
heavy local leg while a peer's is running, which is the only isolation available
for that particular shared artefact.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control118 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-verifyDisarming auto-merge on a PR whose agent is still running does not hold it —
the agent re-arms within minutes and the PR merges, because arming is a step in
the agent's brief and disarming is not an instruction to the agent at all. Use
when: (1) you want to STOP a pull request from merging that an agent opened and
armed, for review, for a rethink, or because it is landing into a queue you are
trying to drain; (2) a PR you disarmed merged anyway; (3) you are telling agents
which PRs are on hold and want the hold to be enforced rather than announced;
(4) you are about to run `gh pr merge --disable-auto` and have not decided what
to do about the agent. The order is KILL THE AGENT FIRST, THEN DISARM, THEN
VERIFY the disarm by reading `autoMergeRequest` back — a disarm you did not read
back is not a hold. The stronger form needs no ordering at all: convert the PR
to a draft with `gh pr ready --undo`. A draft cannot merge whatever any agent
does to it, so the hold survives an agent you missed, an agent that restarts,
and an agent you did not know about.
/batch-member-cites-a-path-only-a-non-member-addsYou wrote something correct that the default reader cannot reach: a batch member citing a
path only a NON-member adds, or a rule, ruling or ledger sitting on an unlanded branch.
/batch-merge-subject-is-not-evidence-a-member-landedYou are about to close, delete the branch of, or mark as landed a pull
request because a batch, roll-up or merge-train commit on the target branch
names it in the subject line, and because the member's own commits all
predate that merge by wall clock. Neither of those is evidence. A batch
branch is assembled at some moment BEFORE it merges, so anything the member
pushed after assembly is outside it, and the subject records INTENT at
assembly time rather than CONTENT at merge time. Use before closing a
member, when an ancestry check against a squashed batch says no, or when a
member's branch still shows commits ahead of the target. Compare file
content against the target branch instead, expecting exactly one legitimate
difference: the shared aggregate file every member appends to.
/check-a-stale-branch-is-not-undoing-newer-main-workA branch built on an out-of-date main is about to merge, or has merged, and may undo work
that landed since. Use when a green, conflict-free PR deletes files you never touched,
newer values or a whole redesign vanish after a sibling PR merged, rows of a shared ledger
(tracker, registry, CHANGELOG) disappear or revert, or when `git diff main...HEAD` or a
reviewer says your small PR touches dozens of files you did not change.
/ci-leg-skipping-moves-minutes-it-does-not-remove-themYou are about to propose, price or approve a CI cost saving that works by
making a job or matrix leg SKIP on pull requests — a path filter, a safe
list, a changed-files gate, an exemption list. Check first whether the
pipeline runs a complement or backstop on merge, on push, or nightly:
many do, and then the legs a pull request skipped are exactly the legs some
later run executes, so a branch that goes green once and merges bills the
same total either way and the wall clock does not move at all. Use when
pricing a filter change, when a percentage saving is quoted with no basis,
or when choosing between filtering legs and batching pull requests. The
question that separates money from bookkeeping is whether the change
removes RUNS or merely moves LEGS.