/agent-traffic-control:injected-claude-md-is-the-worktrees-copy-not-mainsfrom agent-traffic-control
The CLAUDE.md (or AGENTS.md / GEMINI.md) your session quotes is the copy in the checkout the session STARTED in, not the one on the default branch — and a long-lived worktree's copy can be weeks behind, so every house rule in context may be retired. Use when: (1) you are about to write or say "CLAUDE.md says X", "the house rule is X", or "the project file is stale about X"; (2) your session runs in a worktree that was created days or weeks ago; (3) a SessionStart hook or banner mentions the instruction file differing from the default branch; (4) you are about to file an issue, correct a document, or tell a peer that a shared instruction file contradicts the code. The failure inverts: the file on the default branch is usually RIGHT and your injected copy is the stale thing, so the bug report points at the wrong artefact. A retired copy is often LONGER than the current file — superseded correction notes accumulate until a rewrite deletes them — so the stale version reads as the more complete one. The copy carries no date and no banner, and compaction RE-READS it from disk, so the bytes can change mid-session in either direction. A session's age is therefore not evidence about which copy it holds: only a marker sentence present in one version and absent in the other settles it. Settle it with `git show <remote>/<default-branch>:CLAUDE.md` and cite that, never the text in context.
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.
Claude Code reads the project instruction file — CLAUDE.md, and the equivalent
for other harnesses — from the checkout the session started in, and injects it
into context at session start. In a worktree that was created three weeks ago and
never merged since, that is a three-week-old file.
Nothing about it looks old. It arrives in the same position, with the same heading, as the current file would. It has no commit stamp, no date, no "you are reading a snapshot" banner. Every rule in it reads as the house rule in force.
Two properties make it worse than an ordinary stale read:
The damage is not that you follow an out-of-date rule — that is usually benign, because retired rules are mostly stricter than current ones. The damage is when you make a CLAIM about the file: you report that the shared instruction file is stale, contradicts the code, or needs an issue. The direction inverts. The file on the default branch is correct and already says the thing you are about to "discover"; the stale artefact is the copy in your own context. The issue, the correction and the peer message all point at the wrong artefact, and they are persuasive because you quoted the file.
You are in the right place if any of these hold:
Two things that look like corroboration and are not:
One command settles it, and the claim must cite that command rather than the text in your context.
git fetch -q origin main
git show origin/main:CLAUDE.md | wc -c
git log -1 --format='%h %ci %s' origin/main -- CLAUDE.md
The third line is the one that tells you whether a rewrite happened and when.
wc -c CLAUDE.md # your checkout's copy
git show origin/main:CLAUDE.md | wc -c # the live one
A large size difference in EITHER direction means your copy is not the live file. Do not reason about which is "more complete" — see Problem, property 1.
git show origin/main:CLAUDE.md | grep -n "<the subject of your claim>"
If the live file already states the thing correctly, there is no defect and no issue to file. If it genuinely disagrees with the code, you now have a real finding, sourced from the live file.
The stale copy will keep being injected into every future session started in that worktree, including other people's. Merge the default branch into the worktree's branch (never a hard reset of somebody else's work), or, if the worktree is finished, remove it after the usual clean check:
git -C <worktree> status --porcelain # must be empty before removing
My copy of CLAUDE.md (worktree
<path>, from<sha>) says A;origin/main's CLAUDE.md (read just now, last changed in<sha>on<date>) says B.
"The file is stale" is a conclusion you may only write AFTER Step 1, and it names which copy.
The check must be able to return "current", or it is not a check.
Run Steps 1-2 in a fresh worktree of the default branch and confirm they report identical bytes and the same last-changed commit:
git worktree add /tmp/control-check origin/main
cd /tmp/control-check
[ "$(wc -c < CLAUDE.md)" = "$(git show origin/main:CLAUDE.md | wc -c)" ] \
&& echo "CURRENT" || echo "STALE"
A control that says STALE on a fresh checkout of the default branch is measuring
something else — most likely you compared against a local main ref that is
itself behind, rather than origin/main after a fetch.
To settle which copy YOUR CONTEXT holds — which is a different object from any file on disk — use a marker sentence rather than a byte count. Pick a sentence that exists in the retired version and not in the current one (a superseded correction note is ideal, since a rewrite deletes those), and check both sides:
git show origin/main:CLAUDE.md | grep -c "THE CENSUS THAT USED TO BE HERE IS GONE"
# 0 on the current file; the retired copy contains it. Then look for the same
# sentence in the text you were injected, and for the current file's own opening
# line. Whichever you find is the copy you are reasoning from.
A byte count cannot do this: you cannot wc -c your own context, and the file on
disk may have moved since it was injected.
Worked example from a route-generation repository where several sessions run in parallel worktrees. Paths and SHAs are that repository's; the mechanism is not.
A session running in a worktree created weeks earlier was asked to save its lessons. Reconciling one of them against the code, it measured that the house file's passages about which drawing the search actually uses were contradicted by the code, and drafted both a memory note and a message to the coordinating session saying so.
Measured before sending:
checkout's CLAUDE.md ....... 238,232 bytes
origin/main's CLAUDE.md ..... 81,929 bytes
origin/main last change ..... d23357470 2026-09-15 "CLAUDE.md carries only the
house rules as they stand today"
The live file was right. It stated the code's behaviour correctly and had done since the rewrite two days earlier. What the session held was the 238 KB pre-rewrite copy — nearly three times the size, carrying months of correction notes the rewrite had deleted. The "defect" was entirely inside its own context.
Two details worth carrying:
The same class, same day, one layer up. The same session checked a plugin's
skills for duplicate coverage by reading the installed copy under
~/.claude/plugins/cache/..., which held 99 skills at v1.29.0, while the
source repository on disk held 111 at v1.36.1 — twelve skills newer,
committed by peers twenty minutes earlier. The duplicate check was re-run against
the source and one of the two candidate lessons turned out to be already covered.
A cache directory named for a version is a label, not an identity.
isolate-subagent-verification-from-live-worktree
covers a live worktree changing DURING a run. Here nothing changes: the file is
quietly a different, older file for the whole session.inherited-scope-doc-names-may-not-exist
is the same principle for a plan or scope document from a previous session —
verify what an inherited artefact asserts before you dispatch on it. This skill
is the case where the inherited artefact is the RULES themselves, injected
automatically, with no moment at which you chose to trust it.CLAUDE.md:
AGENTS.md, GEMINI.md, nested per-directory instruction files, and a
plugin's or skill's installed copy under a cache directory.CLAUDE.md in 255 worktrees and told several
peers they were "holding stale rules". Those are two different objects, and the
second was never read. Its own withdrawal names the gap: the sendable sentence
is "worktree X on disk carries N bytes; what YOUR session holds I have not
read — a marker sentence settles it". A verdict about a peer's context needs
the peer to check a marker sentence, which costs them one command.git show instead; the worktree's
own copy does not need to be current for that.git show — <rev>:<path>
reads a path out of a commit without checking it out, which is what makes
Step 1 free and unambiguous.git worktree — each
worktree carries its own working-tree copy of every tracked file, including the
instruction files a harness injects.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.