/agent-traffic-control:synthetic-id-collision-rebasefrom agent-traffic-control
Fix the "I claimed cat7-7bg, they claimed cat7-7bg, theirs merged first" failure mode when rebasing a PR after parallel sessions land mid-flight. Use when: (1) rebasing a stale PR onto current main produces a conflict in an append-only register file (tracker entries, ADR `NNNN-` prefixes, migration filenames, OpenAPI operationIds, error codes, lessons.md `## N.` numbering), (2) BOTH your branch and a freshly-merged branch added an entry under THE SAME synthetic ID — the collision is namespace, not just text, (3) plain "accept both sides" yields two rows with identical IDs that violate the file's invariant, (4) multiple Claude Code sessions share a working tree and each picked "next free letter" from their local view of the file. Prescribes a reroll workflow: scan ALL taken IDs in current main, pick truly-next-free, replay only your entry under the new ID, regenerate any derived artifacts (site, indexes), force-push. Also covers the variant where git splits the conflict boundary mid-argument-list of a multi-line Python function call, leaving an orphaned partial call that causes a SyntaxError far from the conflict site — requires ast.parse() verification after resolution.
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.
You opened a PR that adds an entry to an append-only register — Item("cat7-7bg", ...) in a roadmap tracker, 0017-foo.md ADR, V025__add_index.sql migration, ## 144. ... in lessons.md, errcode: "E_QUOTA" in an error catalog. You picked the ID by reading the file and grabbing the next free slot.
Meanwhile, a parallel session — or a co-author, or your own work in another worktree — also picked the same ID. Their PR merged first. Now your PR is mergeable: CONFLICTING / DIRTY, and even after reading their version, the conflict isn't really about content alignment — it's that the synthetic ID itself is taken. A 3-way merge that "accepts both sides" produces two rows with identical IDs, which violates the file's primary key.
This is a particularly nasty failure because:
--theirs keeps their entry under the ID you wanted; your work is silently dropped.--ours overwrites their already-merged entry; your work shows up under their ID, blowing away their data.cat7-7bg rows; tooling that keys on the ID picks the first, hides the second.All four hold:
Item("cat7-7bg", ...), Item("cat7-7bh", ...)NNNN- (0016-foo.md, 0017-bar.md)V025__create_users.sql, V026__add_index.sql## 142. ..., ## 143. ... in lessons.mdgit diff origin/main...HEAD -- <file> shows your block adding the same ID their already-merged block adds. (3 dots — from the merge-base, so you see what YOUR branch adds, not everything that differs between the two tips.)Reroll your ID. Don't try to resolve in-place.
After git fetch origin main && git rebase origin/main, when conflict surfaces:
# Show your ID + theirs in the conflict block
git diff --name-only --diff-filter=U # which files conflict
grep -n "<<<<<<<\|=======\|>>>>>>>" <register-file> | head -20
If you see your Item("cat7-7bg", ...) and their Item("cat7-7bg", ...) in the same conflict hunk under the same key, you have a namespace collision, not a content collision.
# For tracker/Item-style files
grep -oE "cat7-7b[a-z]" docs/generate_roadmap_backlog.py | sort -u
# Pick the next letter alphabetically: if ..bj is taken, you take bk
# For ADR files
ls docs/decisions/ | grep -oE "^[0-9]{4}" | sort -u | tail -3
# Pick max+1
# For migrations
ls db/migrations/ | grep -oE "^V[0-9]+" | sort -V | tail -3
# For lessons.md
grep -E "^## [0-9]+" .claude-memory/lessons.md | tail -3
# Pick max+1
Critical: scan the file as it exists on current main, NOT your local pre-rebase view. Your local thinks bg is free; main says bg through bj are all taken now.
The cleanest path is to reset to current main and cherry-pick only the substantive part of your change, then re-apply the register entry under the new ID as a separate commit.
git rebase --abort # back out of the conflict
git reset --hard origin/main # clean slate
git cherry-pick <your-substantive-commit-sha> # the actual feature/doc work
# Now manually add the register entry under the NEW ID, regenerate derived artifacts
# (site/index/openapi.json/etc.), commit as a fresh "tracker reroll" commit.
If your branch had multiple commits, cherry-pick each substantive commit, then add ONE final "tracker reroll" commit that puts the register entry under the new ID + regenerates derived artifacts.
The site/HTML/openapi/index file regenerator must run against the post-rebase state, not the pre-rebase state. The file SHA pre-regen will mismatch what's on main even if your register entry's content is identical:
python3 docs/generate_website.py # tracker → site
# or whatever the project's regen command is
git add docs/generate_roadmap_backlog.py docs/site/
git commit -m "chore(tracker): add <new-id> for <feature> (PR #N reroll)"
git push --force-with-lease origin <branch>
gh pr edit <N> --body "$(cat <<'EOF'
... existing summary ...
## Status — rebased <date>
This branch was rebased onto origin/main after PR #<X> shipped <feature> and
took the original <id>. Re-rolled to <new-id>. New 2-commit history:
1. <SHA> — the substantive change (untouched)
2. <SHA> — fresh register entry (<new-id>) + derived-artifact regen
EOF
)"
--force-with-lease (not --force) prevents stomping any push that another session may have made to your branch in the meantime.
gh pr view <N> --json mergeable,mergeStateStatus
# Expect: MERGEABLE / CLEAN
gh pr merge <N> --squash --delete-branch
gh pr view <N> returns mergeable: "MERGEABLE", mergeStateStatus: "CLEAN"grep -c "<new-id>" <file> returns 1 (or however many references you intended)This session, 2026-04-27:
cat7-7bg for "S108 docs+tests carry-over" at 15:11 UTCcat7-7bg for "S108 Run 2 + compliance fix" — merged first at 14:29 UTCcat7-7bh (Streamlit decommission), cat7-7bi (feature-flag cleanup), cat7-7bj (S108 handoff) on mainItem("cat7-7bg", ...) block + 3 site filescat7-7bk + regenerated docs/site/{index,roadmap}.htmlEnd state: main has cat7-7bg (parallel session's work), cat7-7bh/bi/bj (subsequent sessions), cat7-7bk (mine). All entries preserved, all distinct IDs, regenerated site reflects all of them.
When the conflicting file is a Python source file with multi-line function calls (e.g., a tracker list of Item("cat7-7ks", "label", ...) entries), git's conflict boundary can split inside a single call's argument list rather than between calls.
What happens:
Both branches append Item("cat7-7ks", ...) near the same location. git's ======= separator falls between the two new entries, but the next existing item's first line (Item("cat7-7kr", "S196 — ...") appears in both the HEAD section and the incoming section (git included it as shared context on each side). A naive "take both sides" regex resolution outputs:
Item("cat7-7kt", ...) # your renumbered entry — correct
Item("cat7-7kr", # orphaned first line — NO arguments, NO closing paren
Item("cat7-7kt", ...) # duplicate — wrong
Item("cat7-7kr", "S196 — ...", ...) # the real full entry — correct
The SyntaxError this produces manifests at the list-close bracket (]) many lines later, not at the broken line — because Python sees an unclosed ( started by the orphan.
Detection:
python3 -c "
import ast, sys
with open('docs/generate_roadmap_backlog.py') as f:
src = f.read()
try:
ast.parse(src)
print('OK')
except SyntaxError as e:
print(f'SyntaxError at line {e.lineno}: {e.msg}')
"
Always run ast.parse() after resolving conflicts in Python files — the SyntaxError line number points at the list-close, not the orphan. The orphan is the first Item("cat7-7kr", line immediately followed by the next Item( without any argument lines between them.
Fix:
Scan for the orphaned line pattern and delete it:
# Find: Item("cat7-7kr", immediately followed by Item("cat7-7kt", (no args in between)
grep -n 'Item("cat7-7kr"' docs/generate_roadmap_backlog.py
# Visually confirm the next non-blank line is Item("cat7-7kt", not an argument
# Then delete the orphan line, re-run ast.parse(), regenerate site
Key insight: git includes the first line of the shared context after the conflict block in both conflict sides. Any "take both sides" strategy without per-line argument-count validation will duplicate that shared line.
Prevention (pre-rebase): If your new Item(...) and the incoming Item(...) land adjacent in the file, rename your ID in a separate commit before rebasing (changes the exact insertion point, so git's conflict boundary shifts away from the argument-list interior). The cleanest path is to abort early and pre-rename.
claude --worktree <name> (Claude Code) or equivalent worktree isolation creates this exact failure mode. The recovery here is the symptomatic fix; the structural fix is per-session worktrees.0017-feature-A.md from your branch + 0017-feature-B.md from theirs both want to exist as the 17th ADR. Resolution is the same: rename yours to 0018-feature-A.md.## 144 and they shipped ## 144 first, you become ## 145. The reroll edit is in one place but you may need to update cross-references (L-S108-144 → L-S108-145) elsewhere.pr-conflict-from-mid-flight-merges skill covers the broader recipe for any mid-flight-merge conflict; this skill specializes the namespace-collision case where the file conflict isn't really about content.pr-conflict-from-mid-flight-merges — in this same plugin (source)claude --worktree <name> flag (avoids shared-working-tree race conditions entirely)What SKILL.md sets; muted values are Claude Code's defaults
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-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.
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control