/agent-traffic-control:solo-repo-branch-protection-stable-gate-and-self-mergefrom agent-traffic-control
Lock main on a solo repo so nothing red lands and you are not locked out — no second reviewer needed. Use when something broken reached main by direct push (CI runs too late to block it), or status checks are required and pushes still land. Traps: a matrix names check runs `test (20)`/`test (22)`, not the workflow name, so require a stable aggregation gate that fails, not skips; `required_status_checks` gates merges, not pushes; and `required_approving_review_count: 0` is what lets you self-merge — `enforce_admins` does the OPPOSITE, it removes your bypass. Not for an undeployed merge.
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 want main to be unbreakable — no direct pushes, the test check must be green before anything lands — but you're the only maintainer, so you can't require a second reviewer, and you don't want a config that deadlocks all merges later. Three traps make the naive approach wrong.
main because it was pushed directly (CI runs
after the push lands, so a post-push workflow can't block it).A workflow name: Tests with a job test and strategy.matrix.node-version: [20, 22]
produces check-runs named test (20) and test (22) — not Tests. If you
require Tests (the workflow name) as a status check, it never exists → no merge ever
satisfies it. If you require test (20)/test (22) directly, then changing the matrix
(drop 20, add 24) silently orphans the required context and deadlocks all merges.
Fix: add a stable aggregation gate job and require only it. if: always() +
checking needs.test.result makes it FAIL (not skip) when any matrix leg fails — a
skipped required check would itself deadlock merges.
test-gate:
if: always()
needs: test
runs-on: ubuntu-latest
steps:
- name: Verify the test matrix succeeded
run: |
if [ "${{ needs.test.result }}" != "success" ]; then
echo "test matrix did not succeed: ${{ needs.test.result }}"; exit 1
fi
Push this and let it run once, then confirm the check-run name exists:
gh api repos/<owner>/<repo>/commits/main/check-runs --jq '.check_runs[].name'.
Required status checks only gate PR merges. To block direct pushes to main you must
also require a pull request (required_pull_request_reviews must be present/non-null).
required_approving_review_count: 0 is the whole of it. A PR is required, but zero
approvals are, so you can merge your own PR once the check is green. GitHub will not let
you approve your own pull request, so any value ≥ 1 deadlocks a solo maintainer outright.
enforce_admins is not part of that and does the opposite of what its placement here
suggests. The REST docs are explicit: "Enforce all configured restrictions for
administrators. Set to true to enforce required status checks for repository
administrators." It APPLIES the rules to admins — it removes the bypass an owner would
otherwise have. So it is what makes the gate real, and it is also the switch you flip to
false if you ever need to get past your own protection (see Emergency lift below). It
never grants a merge. Do not cite it as the reason self-merge works.
cat > /tmp/protection.json <<'EOF'
{
"required_status_checks": { "strict": true, "contexts": ["test-gate"] },
"enforce_admins": true,
"required_pull_request_reviews": { "required_approving_review_count": 0 },
"restrictions": null
}
EOF
gh api -X PUT repos/<owner>/<repo>/branches/main/protection --input /tmp/protection.json
Needs repo scope (gh auth status). Pair with a local .githooks/pre-push that runs
the suite for fast local failure — protection is the authoritative gate, the hook is the
fast layer.
# config active
gh api repos/<owner>/<repo>/branches/main/protection \
--jq '{checks:.required_status_checks.contexts, admins:.enforce_admins.enabled, pr:.required_pull_request_reviews.required_approving_review_count}'
# direct push REJECTED (use --no-verify to bypass local hook and test the SERVER)
git commit --allow-empty -m probe && git push --no-verify origin main # → GH006, "must be made through a pull request"
git reset --hard HEAD~1
# happy path still works: branch → gh pr create → wait test-gate → gh pr merge --squash --delete-branch
Expected rejection: remote: error: GH006: Protected branch update failed ... Changes must be made through a pull request. ... Required status check "test-gate" is expected.
gh api -X DELETE repos/<owner>/<repo>/branches/main/protection, or PUT with enforce_admins:false to
keep an admin bypass. You own the repo, so this state is always recoverable.strict: true means a branch must be up to date with main before merge (rebase if stale).gh pr create --fill aborts if run from the wrong cwd / before the branch is detected;
pass --repo/--base/--head explicitly (see gh-pr-create-orchestration-cwd-wrong-head).test-gate-style stable check. See also claude-plugin-repo-ci-release, a plugin in the
claude-ecosystem-hygiene marketplace rather than this one.These 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.
workflow-run-deploy-gate-fork-pr-ref-name-escalation — a deploy gated on on: workflow_run and a branch name can be escalated from a fork PRmerged-pr-not-deployed-gate-label-missing — the PR merged and CI is green but production never got it — a deploy gate label was missingci-leg-skipping-moves-minutes-it-does-not-remove-them — a filter that makes a leg skip on pull requests moves its minutes to the merge run rather than deleting themThese were named in this skill's description until v1.18.0. The description is resident in context on every turn, so a cross-link there costs budget on every turn and buys nothing -- a user never types another skill's name. They belong here, where the model reads them once retrieval has already succeeded.
gh-pr-merge-unstable-state-needs-auto-and-watch-branch-deletesgh-pr-checks-exit-code-folds-a-by-design-red-wait-on-the-row — once the required check is an aggregation context, a repo that reds it on purpose (on a draft, say) makes gh pr checks exit non-zero on a healthy pull request, so a background waiter keyed on the exit status reports a failure that is not thereWhat 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.