/agent-traffic-control:pr-conflict-from-mid-flight-mergesfrom agent-traffic-control
A pull request that was clean when you opened it now says on GitHub "This branch has conflicts that must be resolved", because others landed on main over the days it sat open. Use when `gh pr view N --json mergeable,mergeStateStatus` returns CONFLICTING and DIRTY, when your branch carries commits you do not recognise, or when some of yours are already on main under a different sha from a squash merge. Find which landed and which of yours are redundant, then reset to the origin tip, rebase and force push with lease. Special case: a stated test count both sides added. Not for generated output.
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.
You opened a PR, it was clean and mergeable. While reviewers/CI/you were elsewhere, other PRs landed on main that touched some of the same files. Your PR now shows mergeStateStatus: DIRTY / mergeable: CONFLICTING on GitHub, with a "This branch has conflicts that must be resolved" banner.
A naive git rebase origin/main may try to replay 14+ commits that aren't really yours — including commits that were squash-merged into main under different SHAs, or commits that someone else cherry-picked onto your branch. You need to (a) identify the actual delta, (b) drop redundant local commits before rebasing, and (c) reconcile any incidental cross-PR additions in a follow-up commit.
All four hold:
gh pr view N --json mergeable,mergeStateStatus now returns mergeable: "CONFLICTING" and mergeStateStatus: "DIRTY".git log --oneline $(git merge-base HEAD origin/main)..origin/main shows ≥ 1 commit on main since your branch point.git diff --name-only $(git merge-base HEAD origin/main)..origin/main shows files that overlap with your PR's changes.Adjacent symptom that strengthens the diagnosis: git log --oneline HEAD~5..HEAD shows commits you don't recognize ("docs: changelog entry for v3.1.0..." when you only meant to add a README fix) — this means a sibling branch's work got pulled into your local feature branch via checkout-with-modified-state or someone else's cherry-pick.
Seven-step recipe. Run from the PR's local feature branch.
gh pr view <PR#> --json mergeable,mergeStateStatus,baseRefName,headRefName
Expect mergeable: "CONFLICTING", mergeStateStatus: "DIRTY". Note baseRefName (usually main) and headRefName (your feature branch).
git fetch origin main
git merge-base HEAD origin/main # branch point SHA
git log --oneline $(git merge-base HEAD origin/main)..origin/main # what they merged
git diff --name-only $(git merge-base HEAD origin/main)..origin/main # which files
This tells you which PR(s) caused the conflict. If you see commits like <sha> docs(README): … (#37) and your PR also touches README, the file overlap is the conflict source.
This is the non-obvious step. Compare origin/<your-branch> (what GitHub sees) against your local HEAD:
git rev-parse origin/<your-branch> # what's on the PR
git log --oneline -5 # what's on local HEAD
If local HEAD is ahead of origin AND the extra commits' content is already on main via a sibling PR (e.g., a CHANGELOG entry that was independently added to a release PR), those local commits are redundant — they were probably cherry-picked or generated locally for testing and never pushed. They must be dropped before rebasing, otherwise the rebase will try to apply them and conflict-resolve them against their own merged copy.
Confirm a local commit is redundant by grepping its content on main:
git show <local-only-sha> --stat
git log origin/main --oneline --grep="<keyword from that commit's message>"
If a recent main commit references the same content, the local commit is redundant.
This drops the redundant local commits and aligns local with what GitHub thinks the PR contains:
git reset --hard origin/<your-branch>
This is safe — you're not losing real work, only stray local commits. The actual PR content lives on origin and is preserved.
git rebase origin/main
What you should see:
warning: skipped previously applied commit <sha> — git correctly recognized that the squash-merged commit on main is the same logical change as one of your branch's commits (matched via git patch-id) and skipped it. This warning is expected and good. Do not use --reapply-cherry-picks unless you're sure you want a duplicate.Successfully rebased and updated refs/heads/<your-branch>. — clean rebase, no manual conflicts.If git instead drops you into manual conflict resolution, that means the file edits genuinely overlap (same lines edited differently). Resolve normally with your editor, then git add <file> and git rebase --continue.
After rebase, your PR's diff against main may now lack content that landed in a sibling PR — e.g., the v3.1 release added a row to a Version History table, but your PR was written against v3.0 and only added v3.0. Add a small follow-up commit:
# example: README update reconciling against a release PR that landed mid-flight
git add README.md
git commit -m "docs: reconcile <topic> against <sibling-PR-#N> after rebase"
Keep this commit small and tightly scoped. The PR description should be updated (next step) to call out that the rebase happened.
A stated count — 342 tests, 97 skills, a coverage percentage, a totals row — is the one
kind of reconciliation where both sides of the conflict can be wrong at once:
Taking "the newer side" is the natural move and it is only correct when your own branch
changed nothing that the number counts. In a stack where every PR adds tests, it is wrong
every time. Measured across three PRs in one stack (2026-08-07): resolutions of 459, 461
and 476 against merged trees that actually collected 461, 476 and 480. Three
resolutions, three wrong, each a real count of a real tree — and each looked reasonable
when it was made.
And "bigger is newer" is not a tiebreak, because a count can go DOWN. A later PR in the
same repo was rebased four times and its row went 530 → 559 → 516, while the merged tree
collected 517. Tests get deleted, renamed and moved between suites.
The remedy is to make the value un-shippable until it is measured: resolve the conflict to a literal placeholder, finish the rebase, then measure the final tree once and replace it.
# | `pytest docs` | **PENDING-REMEASURE** collected | ← during the rebase
git add README.md && git rebase --continue
pytest docs -q --co 2>&1 | tail -1 # AFTER the rebase completes, not between steps
grep -rn "PENDING-REMEASURE" . # must be empty before you push
A half-plausible number survives by inertia — nobody re-checks a value that already looks
like a value. Full treatment, including why this fires in a skill about generated files
when nothing here is generated, in
merge-conflict-generated-files
§Variant — the derived thing is a VALUE inside a hand-authored file.
git push --force-with-lease origin <your-branch>
gh pr view <PR#> --json mergeable,mergeStateStatus
# expect mergeable: MERGEABLE, mergeStateStatus: CLEAN
--force-with-lease is safer than --force: it refuses to push if origin moved since your last fetch, preventing you from clobbering someone else's force-push.
Then refresh the PR body via gh pr edit <PR#> --body "..." to note:
gh pr view <PR#> --json mergeable,mergeStateStatus,commits \
--jq '{mergeable, mergeStateStatus, commits: [.commits[] | {oid: .oid[0:7], message: .messageHeadline}]}'
Expect:
mergeable: "MERGEABLE"mergeStateStatus: "CLEAN"commits array shows only your real changes (no WIP, no stray cherry-picks, no commits whose message refers to a sibling PR's topic)PR #38 was opened on docs/readme-panel-p0-fixes against main, with one commit: README P0 fixes from a panel review. Hours later, gh said:
{"baseRefName":"main","headRefName":"docs/readme-panel-p0-fixes","mergeStateStatus":"DIRTY","mergeable":"CONFLICTING"}
Step 2 revealed two PRs had landed on main: #37 (the dedup base this branch was built on, now squash-merged) and #39 (independent v3.1.0 release). Both touched README.md.
Step 3 revealed local HEAD was 1 commit ahead of origin/docs/readme-panel-p0-fixes — a 51bbaa0 docs: changelog entry for v3.1.0 commit that didn't belong (its content was already on main via PR #39's release commit).
Step 4: git reset --hard origin/docs/readme-panel-p0-fixes dropped 51bbaa0.
Step 5: git rebase origin/main ran cleanly, with warning: skipped previously applied commit 6e1d28a confirming the dedup commit was correctly recognized as already on main.
Step 6: A small follow-up commit added a v3.1 row to the Version History table (since main now had v3.1.0 as the latest) and bumped a 342 tests claim to 379 to match the v3.1.0 test count.
Read that count bump as a special case, not as the recipe. Copying main's
379was right here only because this branch was a README-only change that added no tests, so main's number was also the merged tree's number. On a branch that adds tests, taking either side of that line is the failure described in step 6 — resolve to a placeholder and re-measure after the rebase.
Step 7: git push --force-with-lease succeeded, gh pr edit refreshed the body, mergeStateStatus flipped to CLEAN, and the PR merged.
git rebase --reapply-cherry-picks unless you've verified the "previously applied" commit is genuinely different from the one on main. The default skip behavior is correct in 99% of mid-flight-merge scenarios.git push --force — always --force-with-lease. The lease check prevents you from accidentally clobbering work that landed after your last fetch.git branch --show-current before continuing. Abort with git rebase --abort if the count is suspicious.warning: skipped previously applied commit line is your friend — it's git telling you the rebase identified a squash-merge equivalence via git patch-id. If you don't see this warning when you expected to (i.e., your branch was based on an unmerged branch that has now squash-merged), check whether that base branch's content is actually on main via git log origin/main --grep or git diff <merge-base>..origin/main -- <file>.verify-a-squash-merge-by-content-not-lineage covers a related but different symptom ("untracked working tree files would be overwritten by merge"). Use that one when the conflict is about uncommitted local changes vs. an incoming merge, not about a feature branch needing rebase.--force-with-lease safer-force-push pattern:
https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegtThese carry disable-model-invocation: true. They never appear in the skill
listing and the Skill tool refuses them, so the only way in is to open the file
with Read when one of these matches what you are looking at.
verify-a-squash-merge-by-content-not-lineage — checking whether an upstream commit survived a propagation PR (ancestry says no, content says yes), or gh pr merge --squash printing far more files than your PR touchedreland-work-that-missed-a-squash-merge — commits pushed to an open PR branch never reached main because it was squash-merged between pushesrecover-from-an-async-post-commit-hook — a background hook's own follow-up commit is orphaned by the squashgh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletes — gh pr merge fails in a way that looks like a conflict but is an UNSTABLE mergeStateStatusgha-pr-merge-ref-shows-upstream-changes — CI fails on a file you never changed because it tested the merge ref, not your branchgit-diff-2dot-vs-3dot-merge-safety — a false "this PR deletes files on main" alarm from using two-dot instead of three-dot diffcheck-a-stale-branch-is-not-undoing-newer-main-work — a PR from an old branch point silently reverts files that landed on main afterwards, or git diff main...<branch> reports dozens of upstream files because the local main ref is staleTwo more about the churn itself rather than the conflict it produces. Reach for these
when the PRs are BEHIND rather than DIRTY — there is nothing to resolve and nothing
lands anyway:
merge-queue-thrash-stop-inflow-and-open-prs-as-drafts — main moves faster than the slowest CI leg, so every branch goes stale before its own run finishes; stop the inflow, land one at a time, and open pull requests as drafts by defaultauto-merge-rearms-while-agent-live-kill-then-disarm-verify — holding one pull request out of that queue: a disarm does not hold while the PR's own agent is still running, and a draft doesbatch-merge-subject-is-not-evidence-a-member-landed — a batch's squash subject names a member that never landed, because the batch was assembled before the member's last pushbatch-member-cites-a-path-only-a-non-member-adds — the other direction of the same batch check: a member's added comment or tracker row cites a repository path that only a NON-member adds, so the batch merges green and the target branch points at a file it does not have. Overlap asks who touches a file; this asks who NAMES one. Since 1.1.0 it also carries the mirror — a rule, ruling or ledger every session must obey, sitting where the default reader cannot reach it.conflicted-pr-starts-no-ci-run-push-resolution-first — while the PR is CONFLICTED no CI run exists or can start, so two of its three status fields are non-facts; push the resolution before your local legs finishWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
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.