/agent-traffic-control:gh-pr-checks-exit-code-folds-a-by-design-red-wait-on-the-rowfrom agent-traffic-control
`gh pr checks` returns ONE exit status for the whole pull request, so a check your repo keeps red ON PURPOSE — a required aggregation context that is red while a PR is a draft, a placeholder context, a job the workflow allows to fail — makes the command exit non-zero on a pull request where everything that actually ran passed. Use when: (1) you are writing a background wait loop or watchdog that polls a PR and decides from `$?`; (2) a background poll came back "failed with exit code 1" and you are about to diagnose a red that may not exist; (3) you are about to report a PR as failing, or hold a queue on it, on the strength of an exit status; (4) your repo deliberately reds a context on drafts so a draft cannot merge on a green no suite produced. The exit code cannot tell a by-design red from a real one, and a non-zero exit from a backgrounded poll is surfaced by the harness exactly like a failing job. Poll the ROW for the check you care about and exit 0 yourself; `8` means pending, not failure; and confirm a red is the by-design one by reading that job's log, not by assuming it.
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.
gh pr checks Folds a By-Design Red Into One Exit Status — Wait on the RowYou want a session to keep working while a pull request's cheap checks finish, so you
background a poll and let the harness notify you when it exits. The obvious loop ends with
gh pr checks <n> and trusts its exit status.
On a pull request where everything that ran passed, that loop reports failure — because
one context is red on purpose and the exit status has no room to say so. The notification
reads failed with exit code 1, which is indistinguishable from the run genuinely going
red, so the next thing the session does is diagnose a defect that does not exist, or hold a
landing queue on a branch that is fine.
until-style poll around a pull request.gh pr checks --help | sed -n '/Additional exit codes/,+3p'
Measured on gh 2.97.0: 0 every check passed, 8 checks are still pending,
1 something is not passing. A loop written as until gh pr checks "$PR"; do sleep 30; done therefore treats pending and failed the same way, and treats a by-design red as a
reason to keep waiting forever.
# The per-check rows are TSV: name, state, elapsed, link.
state() { gh pr checks "$1" 2>/dev/null | awk -F'\t' -v n="$2" '$1==n{print $2}'; }
for _ in $(seq 1 40); do
s=$(state "$PR" "$CHECK") # $CHECK = the job whose verdict you want
[ -n "$s" ] && [ "$s" != "pending" ] && break
sleep 30
done
echo "$s" # and exit 0 yourself
gh pr checks <n> --json name,state,bucket is the structured form where available;
--required narrows to required contexts, which is usually what a queue cares about.
Whichever you use, the loop's own exit status must be something you set, not something
gh handed you about a different check.
Keep the list of contexts your repo reds on purpose next to the waiter, and treat any OTHER red as real. A waiter that ignores every red is worse than one that trusts the exit code.
gh run view <run-id> --job <job-id> --log | grep -i "draft"
The aggregate job that is red on purpose says so in words. If the grep finds nothing, you have a real failure wearing a familiar name.
On a pull request whose expensive suites are skipped and whose cheap checks are green:
gh pr checks "$PR" > /dev/null; echo "exit=$?" # exit=1, and nothing is wrong
gh pr checks "$PR" | awk -F'\t' -v n="$CHECK" '$1==n{print $2}' # pass
Exit 1 beside a passing row is the whole finding. Then run your waiter against the same pull request and confirm it exits 0 and prints the row's state. A waiter you cannot make exit 0 on a healthy draft has not been tested.
A draft pull request, measured 2026-09-17. The rows:
| check | state | note |
|---|---|---|
| whole-diff guard job | pass (1m33s) | the only job a draft runs |
| label check | pass | |
| test-suite matrix | skipping | skipped on drafts by policy |
| node suites | skipping | skipped on drafts by policy |
| aggregate required context | fail | red on drafts by design |
gh pr checks → exit 1. The background poll that ended on that command was reported as
failed with exit code 1, and the first reading was that the fix had broken something. It
had not: the aggregate context's own log carries the sentence explaining that it is red
because the pull request is a draft and no suite has run on the code.
--watch --fail-fast, which exits the moment the by-design red
appears — on a draft, that is immediately.waiter-pgrep-matches-its-own-command-line.conflicted-pr-starts-no-ci-run-push-resolution-first.gh pr checks --help — the Additional exit codes block (8: Checks pending).solo-repo-branch-protection-stable-gate-and-self-merge
— why a required check is an aggregation context rather than a matrix leg, which is what
puts a single by-design red in front of every waiter.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-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.