/agent-traffic-control:dispatched-bash-agent-git-checkout-clobbers-uncommitted-editfrom agent-traffic-control
A verification/review/audit subagent YOU dispatched (Workflow agents, Explore, general-purpose, code-reviewer — anything with Bash) runs a file-level `git checkout <path>` / `git restore <path>` / `git stash` to compare your work against HEAD, and silently REVERTS your uncommitted working-tree edit in the shared worktree. The agent then reports that edit as "missing / not persisted / blocker", and sibling agents pile onto the phantom. Use when: (1) a review or verification agent reports a file/entry/line you KNOW you just wrote is "missing", "not in the file", "not persisted", or "only in the diff not the file"; (2) its evidence cites "a subsequent git checkout shows…" or "git diff shows it but the working tree doesn't"; (3) a harness "file was modified, either by the user or by a linter" reminder names a file you edited but didn't touch since; (4) your own passing test suite REQUIRES the thing the agent says is missing (the decisive tell — if tests that need it passed, it WAS there). Prevention: commit (or stash to your own ref) BEFORE dispatching Bash-capable agents onto a shared worktree. ALSO covers the SELF-INFLICTED variant: YOU run `git checkout -- <file>` / `git restore <file>` to RESTORE a source file after a mutation test (deliberately breaking a guard to prove a test reddens, then reverting) — but the file had UNCOMMITTED edits you needed to keep, so the checkout silently discards them and reintroduces failures. Safe only when the file is clean-vs-HEAD; if it has uncommitted edits, back up with `cp` (restore from the copy) or `git stash`.
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.
git checkout reverts your uncommitted worktree editYou dispatch one or more Bash-capable subagents (a Workflow fan-out, Explore,
general-purpose, code-reviewer, etc.) to review/verify work in the same git
worktree where you have uncommitted edits. An agent, investigating "is X
present / persisted?", runs a file-level git command to compare against HEAD:
git checkout analysis/SQL/foo.toml # or: git restore <path> / git stash
This reverts your uncommitted edit to that file back to HEAD. The agent then reads the reverted file, finds your change gone, and reports a false "missing / not persisted / blocker" finding. In a multi-agent review, other agents reading the same now-reverted file repeat the phantom — so a majority can "fail" on something that was actually correct and committed-in-spirit.
This is distinct from its siblings:
concurrent-session-checkout-clobbers-shared-worktree — an unknown session
flips the branch (git checkout <branch> / git switch). Here the clobberer
is an agent you dispatched running a file-level checkout/restore/stash.subagent-read-stale-worktree-needs-head-pin — read agents return stale data
from the wrong worktree (no mutation). Here a single shared worktree is
mutated underneath you.git checkout/git restore/git stash
or "git diff vs file content mismatch".git status you run afterward shows a file you edited is no longer modified
(it silently reverted), often with a harness "file was modified, either by the
user or by a linter" reminder.grep -c "<the thing>" <file> and git status --short. If it's gone from a
file you edited but didn't revert, an agent clobbered it.git add any new untracked files the agents flagged).git checkout) are more
trustworthy than agents whose evidence is a git comparison.git stash to your own ref) BEFORE dispatching any Bash-capable
review/verification agents onto a shared worktree. Committed work cannot be
clobbered by a file-level checkout. This is the cheap, reliable fix.Agent/Workflow
isolation: "worktree"), or restrict them to read-only tools (no Bash) so they
cannot run git mutations.git checkout/git restore/git stash/git reset — read the
working-tree files as-is."git checkout to restore a mutation test (v1.1.0)No subagent involved. To prove a test genuinely binds, you mutation-test: break a guard in a source file, run the test, confirm it reddens, then restore the file:
# break the guard, run the test (expect RED), then:
git checkout -- bake_monitor.py # "restore" — but this reverts to HEAD, not to
# your pre-mutation working-tree state
git checkout -- <file> restores the file to HEAD (the last commit), NOT to
whatever uncommitted state it had before you mutated it. If you'd made uncommitted
edits to that file after the last commit (e.g. a fix you applied earlier in the
session but hadn't committed yet), the checkout silently discards ALL of them — and
your suite goes red again on the now-missing edits, looking like a fresh bug.
The trap is state-dependent and intermittent: the first few mutation tests in a
session are often safe because the file is still clean-vs-HEAD (nothing uncommitted
to lose), so git checkout is a perfect no-op restore. The moment you make an
uncommitted edit to that same file and then run another git checkout-based
mutation test, it clobbers the new edit. "It worked the last three times" gives false
confidence.
Prevention — pick by what you're protecting:
cp backup (simplest, always correct): cp file /tmp/bak && <mutate> && <test> && cp /tmp/bak file. Restores the exact pre-mutation bytes regardless of commit state.git checkout is safe (it restores to your just-committed state).sed-on-a-copy mutation never touches the real file.Decisive tell (same as the dispatched-agent case): a suite that passed moments
ago now fails on edits you know you made → grep -c the file → the edits are gone →
your last git checkout/git restore/git stash ate them. Recover by re-applying
from conversation context (the content is never lost), re-run, then commit.
grep -c shows your change back in the file; git status
lists it as modified again; the suite is green; you've committed it.S28 of brief-runner: a 4-agent Workflow adversarially reviewed an
uncommitted PR in the shared worktree. One Explore agent ran
git checkout analysis/SQL/media_mix.registry.toml to compare a new [[template]]
entry against HEAD — reverting the uncommitted edit. Two of four agents then
returned verdict: fail, "registry entry missing — git checkout shows only 2 templates". But the full test suite (which includes a test asserting the entry
loads and is selected) had passed at 379/11 minutes earlier — proof the entry was
there. Recovery: re-applied the registry edit, re-ran (26 → 379 green), committed,
then re-triaged: the two "fail" verdicts were phantoms; only the edge-case auditor's
findings (which ran real Python) were genuine.
git checkout <path> reverting a single file, not a branch
switch — so git reflog (the concurrent-session skill's tell) shows nothing
unusual. Diagnose via current file content vs. your passing tests instead.run_in_background agents can't write, but Bash-capable foreground
review agents (incl. Workflow agent() calls) can run git mutations.concurrent-session-checkout-clobbers-shared-worktree: when YOU are the one
spawning the clobberer, you control the fix — commit first.concurrent-session-checkout-clobbers-shared-worktree — branch-switch variant by an unknown session.subagent-read-stale-worktree-needs-head-pin — read-only stale-worktree variant (no mutation).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.