/agent-traffic-control:merge-queue-thrash-stop-inflow-and-open-prs-as-draftsfrom agent-traffic-control
When main moves faster than the slowest CI leg, every open branch goes stale before it can merge and the whole queue jams with nothing red. Use when: (1) several PRs sit at mergeStateStatus BEHIND with auto-merge armed and none of them lands; (2) branches are being updated, re-running CI and going stale again before that run finishes; (3) you are landing work continuously and wondering why the queue is not draining — you are the cause, not a victim; (4) you are deciding how a fleet of agents should open pull requests in the first place. The immediate fix is to STOP THE INFLOW and land one at a time, newest-CI first. The structural fix is to open every pull request as a DRAFT and mark it ready only when it is next to land: on the repo this was measured, a draft run cost about 46 seconds against about 16 minutes for a full one, and over 8 days draft-by-default would have saved 23-48% of every CI minute, because 36% of pull-request runs were merges of main carrying no new code at all. NOT for a PR that conflicts — BEHIND is not DIRTY, and nothing here resolves a conflict.
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.
Six pull requests, all green when they were pushed, all with auto-merge armed. None of them merges.
Nothing is wrong with any of them. mergeStateStatus reads BEHIND on every one —
not DIRTY, so there are no conflicts and nothing needs resolving. Each is simply
behind a main that moved after its last run finished.
The loop:
branch is BEHIND → update it from main → CI re-runs (16 min)
↑ ↓
someone lands on main ← branch is BEHIND again
If the interval between merges into main is shorter than the slowest required CI
leg, the queue cannot drain. Every branch is stale before its own run finishes.
Auto-merge does not help: it is waiting for a state — up to date and green — that no
branch is ever in for long enough.
The cause is almost always you. In the observed run, the inflow was a single session landing work continuously, all night. Each individual merge was correct and wanted. Together they made every other branch unlandable. This is worth stating plainly because the instinct when nothing merges is to go looking for a broken check, and there isn't one.
mergeStateStatus: BEHIND with auto-merge armed, and no merges
landing.Merge branch 'main' into … commits
that changed nothing in the branch's own code.# The one-line diagnosis: how many are BEHIND, and is anything DIRTY?
gh pr list --json number,title,mergeStateStatus \
--jq 'group_by(.mergeStateStatus)[] | {state: .[0].mergeStateStatus, n: length}'
BEHIND in bulk is this skill. DIRTY is
pr-conflict-from-mid-flight-merges
— a real conflict, a different job, and nothing here will resolve it.
The queue drains only if main holds still. So:
gh pr update-branch while a run is in progress on that branch —
it invalidates work already underway. The safe predicate is per-branch, and getting
its scope wrong stalls the lane completely:
orchestrator-rule-too-strict-stalls-agent-silently.The deeper problem is that a PR pays full CI from the moment it opens, and then again every time main moves under it, for as long as it stays open. Most of that spend buys nothing: it is testing a branch nobody is about to land.
So open the PR as a draft, and mark it ready only when it is next to land.
gh pr create --draft --title "..." --body "..." # every PR, by default
# ... work, review, sit in the queue as long as you like ...
gh pr ready <N> # only when it is next to merge
gh pr merge <N> --squash --auto
For this to save anything, the expensive workflows must actually skip drafts. That is one condition on the job, and it is the whole mechanism:
jobs:
expensive-suite:
if: github.event.pull_request.draft == false
Measured on the repo this was learned on:
| duration | |
|---|---|
| a draft PR's run (cheap gates only) | ~46 seconds |
| a full PR run (all suites) | ~16 minutes |
And across 8 days of history, opening every PR as a draft would have saved
23–48% of every CI minute spent. The reason the saving is that large is the second
measurement: 36% of pull-request runs were merges of main into a branch, carrying
no new code at all — over a third of the bill was re-testing other people's already-
tested work.
It also happens to give you a hold that GitHub enforces: a draft cannot merge, whatever
an agent does to it. See
auto-merge-rearms-while-agent-live-kill-then-disarm-verify.
paths-filtered workflow that
did not trigger stays pending forever and blocks merge with no failure. Different
jam, same symptom — gh pr checks <N> names it.main actually the base? A stacked PR whose base branch is another PR goes
BEHIND for reasons that have nothing to do with inflow, and merging its base can
auto-close it:
stacked-pr-base-branch-deletion-auto-closes-dependent.Drafts stop the bill for branches nobody is landing. The next leak is running a full test pass per member and then landing them one at a time. Once several drafts are ready:
The queue is draining when:
# BEHIND count is falling between checks, and something has actually merged
gh pr list --json number,mergeStateStatus \
--jq '[.[] | select(.mergeStateStatus == "BEHIND")] | length'
gh pr list --state merged --limit 5 --json number,mergedAt
Draft-by-default is actually in force when:
gh pr list --json number,isDraft shows open PRs as drafts by default, not as an
exception.draft == false condition — check the workflow file,
not the intention.Six pull requests sat BEHIND with auto-merge armed and nothing landed. No conflicts, nothing red, every branch green at its last run and stale by the time anyone looked.
The cause was the orchestrating session itself, landing work continuously through the night. Each merge was individually correct and collectively made the queue unlandable — main moved faster than the slowest required leg, so every branch was stale before its own run finished. Auto-merge armed on all six was waiting for a condition none of them could reach.
The recovery was to stop landing anything else and take them one at a time, newest CI first.
The invention that prevents it structurally was draft-by-default: open every PR as
a draft, promote it to ready only when it is next to land. On this repo a draft run
cost ~46 seconds against ~16 minutes for a full one, and over 8 days
draft-by-default would have saved 23–48% of every CI minute — because 36% of
pull-request runs were merges of main carrying no new code at all.
--auto is still right; it is just not a queue-control mechanism. It waits for a
condition. If the condition is unreachable it waits forever, quietly.--draft in the brief, not in your memory.pr-conflict-from-mid-flight-merges
— what to do when the same churn produced a real conflict (DIRTY, not BEHIND)auto-merge-rearms-while-agent-live-kill-then-disarm-verify
— the other use of draft: a hold GitHub enforcesorchestrator-rule-too-strict-stalls-agent-silently
— the per-branch predicate for when gh pr update-branch is safe, and what happens
when that rule is scoped repo-wide insteadgh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes
— UNSTABLE, BLOCKED and the rest of the mergeStateStatus tablestacked-pr-base-branch-deletion-auto-closes-dependent
— when BEHIND is about a stacked base rather than inflowmergeStateStatus enumWhat 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.