/agent-traffic-control:parallel-session-coedit-via-source-mtime-and-idempotent-rebuildfrom agent-traffic-control
Edit a shared deliverable while another live session or a colleague's agent is editing the same file right now — "don't delete each other's work", "only write when the other one is finished". When the file is built from many per item sources by an assembler (sections into one HTML, slides, reports): source mtime shows which items they are on, disjoint sources cannot clobber, and an idempotent rebuild merges everybody's sources. Grepping the assembled build is a false negative test, and staging then pausing lets their commit absorb your files. Not for planning who edits what next session.
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: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The user says: "a parallel session is making active edits on the same file, so please don't delete each other's work — maybe only write on it when the other one is finished." The deliverable is large and shared. The naive readings both fail: serialize (do nothing until they finish — wastes the session, ignores the user's "fan out / go fast") or dive in blindly (and clobber their work, which is exactly what they warned against).
There is a third path that is fast AND safe — but only once you notice the build model: the artifact is assembled from per-item source files, and the assembler is idempotent (reads all sources from disk, regenerates the one output). That changes the collision math entirely.
_assemble.py, a bundler, a
static-site generator) inlines per-item source files (sections/*.html,
partials, slides) into ONE output file. The output is a build artifact, not
the source of truth.Find the build model FIRST. Never hand-edit the assembled OUTPUT. Locate the assembler and confirm the big file is generated from per-item sources. Edit the source files; the output is regenerated. (If you edit the 2 MB assembled HTML directly, the next rebuild by either session silently overwrites you.)
Map hot/cool per item via SOURCE-FILE mtime — this is your real-time ownership signal, no git needed:
stat -f '%Sm %N' -t '%H:%M:%S' sections/*.html # BSD/macOS
# or: ls --time-style=+%H:%M:%S -l sections/*.html # GNU
Files touched in the last few minutes = the other session's HOT set; old mtimes = COOL. Re-stat right before each edit batch — the other session moves between cards/items quickly (a broad pass can touch 6+ files in minutes).
Edit ONLY cool, disjoint source files. Two sessions on different source files never clobber each other — last-writer-wins only bites the same file. So staying on disjoint items satisfies "don't delete each other's work" without serializing. Ask the user to confirm ownership at item granularity ("does the other session own items 1–9 and I take 10 + the analysis?").
An idempotent rebuild is NON-destructive — this is the key insight. The assembler reads ALL source files from disk and regenerates the output, so any session's rebuild auto-merges everyone's saved source edits. Your edits survive the other session's rebuild, and theirs survive yours — as long as all edits live in the SOURCES, not the output. You don't even have to rebuild yourself: the next rebuild by anyone picks up your saved sources. (Verified: my edits to one card survived the other session's rebuild that happened minutes later; that rebuild pulled my changes into the output untouched.)
The only two real collision surfaces — avoid both during the active window:
(a) both sessions editing the same source file; (b) editing the shared
assembler/config (e.g. reordering items in _assemble.py, which also
renumbers everything). If the ask is "position X near Y," prefer a
cross-reference note inside the (disjoint) source files over a physical
reorder of the shared assembler. Defer structural reorders until the other
session is done.
Verify your edits survived. After the other session bumps the mtime of a file you edited, RE-READ it to confirm your changes are intact. (The Edit tool also errors on stale state, so a blind edit fails safe rather than clobbering.)
Rebuild only when sanctioned ("rebuild now") — then verify the OUTPUT contains every session's content.
grep "my exact phrase" on assembled HTML gives
false negatives when the phrase wraps across a source line break OR an inline
tag (<i>, <b>) sits mid-phrase. Use:
python3 -c "import re,sys; t=re.sub(r'\s+',' ', re.sub(r'<[^>]+>',' ', open(sys.argv[1]).read())); print(sys.argv[2] in t)" OUT.html "my exact phrase"
sections/*.html. See
shipped-change-not-visible-deploy-vs-gate-vs-cache (Step 0) + lessons #181.Two live sessions co-editing report_bundle_ENRICHED.html, assembled from
sections/*.html via _assemble.py. stat showed the other session sweeping
cards 01–09 (mtimes in the last ~5 min); my targets 07/08b/10 were cool (hours
old). I edited 08b first; the other session's later rebuild (16:12) pulled my 08b
edits into the output cleanly. When they moved onto 09, I held the 09 cross-ref
until the user gave me explicit ownership of all four cards. I used cross-reference
notes (07↔09) instead of physically reordering cards (which would have meant
editing the shared _assemble.py). Final rebuild verified all four of my cards
and the other session's card-09 enrichment present; two "missing" greps turned
out to be a line-wrap and an inline <i> tag (false negatives), confirmed by the
tag-stripped check.
When you wrap up (e.g. /session-handoff) while the deliverable is still co-edited
live on a shared branch, the handoff skill's default "commit ALL work → open a
PR → auto-merge docs" is wrong and will entangle or ship the other session's
in-progress work. git status on the shared worktree shows both sessions' edits
intermixed — there is no clean per-session diff. Invert Phase 4:
DO-NOT-MERGE) artifact. Leaving the deliverable saved-but-uncommitted for
the worktree owner / post-sign-off commit is the protocol, not a loose end.git add -A/-u, which sweeps the
other session's files + untracked build scripts
(git-add-all-sweeps-untracked-artifacts-into-commit).
git add writes to
the one shared index; if the other session runs its git commit (even a
plain commit, no -a) while your files sit staged, your staged files ship in
ITS commit — you never ran git commit. Observed 2026-07-01: path-staged
cards 08/10 were absorbed into the parallel session's f9e63216 ("bundle card
1B…"). Mitigate: run git add <paths> and git commit atomically in the same
step, and re-check git diff --cached --name-only shows exactly your paths
in the instant before committing (abort if a foreign path appears). If you'd
rather your content edits land in the other session's commit anyway (the owner
is actively rebuilding that file), just leave them unstaged and let it fold
them in. See lesson_shared_worktree_staging_absorbed_by_parallel_commit (the client
project memory).git log @{u}..HEAD shows them above origin); pushing publishes their
work. The other session owns the push.MEMORY.md index line) instead of adding one.main now, land them via a separate worktree off
origin/main (a "safe-docs PR" excluding the gated deliverable) — never
branch-switch the shared/active branch.Net (verified the client report bundle 2026-06-30c): 2 path-staged doc commits, unpushed, atop the other session's commits; every deliverable edit (yours + theirs) left uncommitted; one labeled follow-up issue; an existing memory file updated in place.
shared-file-redesign-parallel-author-serial-integrate (one orchestrator
authoring handoff prompts / in-session fan-out) and
large-redesign-parallel-branch-collision-audit (git-branch collisions).file:// URL points at
that worktree's copy.shared-file-redesign-parallel-author-serial-integrate — single-orchestrator
parallel authoring & serial integration (git branches / handoff prompts).large-redesign-parallel-branch-collision-audit — pre-existing branches that
collide with a redesign's files.merge-conflict-generated-files — when the assembled output is tracked and
conflicts in git.session-handoff — the Variant above inverts its Phase 4 (commit-all + PR +
auto-merge) for a shared, live-co-edited, gated branch.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-verify