/agent-traffic-control:poll-loop-treats-an-unreadable-status-as-finishedfrom agent-traffic-control
You are watching a long-running job you dispatched — a hosted batch execution, a remote build, a queued run — by asking its API for status on a loop, and the loop decides "finished" by pulling one field out of the reply and testing that the field is not empty. An error line, a fallback token or a truncated reply is also not empty, and `cut` without `-s` hands a delimiter-free line back whole whatever field you asked for — so the test passes on a reply that carries no status at all. Use when a watch loop reports done and you are about to act on it — report the work complete, cancel a sibling, delete the inputs, start the next stage — when the machine slept or the session resumed mid-watch, or when a status reading disagrees with how long the work should have taken. Parse a completion fact, keep UNKNOWN as its own state, and re-read the source before an irreversible act.
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.
A watch loop asks a remote system "is it done yet?" and has to turn the answer into a boolean. The usual shape projects a few fields out of the reply, splits them on a delimiter, takes one position, and treats a non-empty value as the completion signal.
Three things make that decision unsound, and they compound:
cut -d, -f5 hands back the WHOLE
LINE whatever field you asked for, unless -s is given, while
awk -F, '{print $5}' and ordinary shell field splitting return empty.
Verified, not assumed — the three commands are in the References below. Only
the first turns an error string into "the completion time".The two failure directions are not symmetric, and the quiet one is the expensive one. A false BUSY is loud and cheap — the loop keeps spinning and somebody notices. A false FINISHED is silent and is the reading you ACT on: you report the work done, you cancel the sibling that was "no longer needed", you delete the inputs, you launch the next stage against half-written output, or you release a coordinator that was holding a queue for you. By the time the job really finishes, the acts are done.
Measured, 2026-09-17. A session watched hosted batch executions with a background poll whose status call projected five comma-delimited fields and read field 5, the completion time, as the done signal. The laptop slept overnight, so the watch did not fire while the work ran. On waking, the status query did not return a record: what reached the field test was a single token with no comma in it, so the split produced one field, the field was non-empty, and the check — nominally "the completion time is populated", actually "the reply is not empty" — passed. The monitor printed a terminal state.
The part that makes this worth a skill: the verdict was CORRECT, and that is luck rather than evidence. Read directly, both executions had genuinely finished hours earlier, overnight. So the broken check and a working one agreed on the only occasion anyone looked, and the same reply would have passed identically over a job still running — the test cannot tell those apart, which is precisely what it was there to do. A check that returns the right answer for the wrong reason is the hardest kind to notice, because nothing downstream ever disagrees with it. What found it was reading the executions themselves before reporting anything, not the monitor's own output.
$(... | cut -d, -f5), a [[ -n "$field" ]], or an awk '{print $3}' over a
projection you chose by position.Require a value the running state cannot produce:
# a terminal state from a closed set — not "the state field is populated"
case "$state" in
SUCCEEDED|FAILED|CANCELLED) done=1 ;;
RUNNING|PENDING|QUEUED) done=0 ;;
*) done=unknown ;; # everything else lands here
esac
If the signal is a timestamp, parse it. A string that does not parse as a date is not a completion time, however non-empty it is.
Positional projections renumber silently when a field is empty, when the API adds a column, or when the reply is not a record at all. Where the client can return a single named value, or JSON you address by key, take that: a missing key is an absence you can detect, where a missing position is a shift you cannot.
An unparseable reply is neither done nor busy. Collapsing it into "busy" hangs the loop forever; collapsing it into "done" is this skill. Count consecutive unknowns, print the raw reply when one appears, and escalate after a few rather than deciding.
They are different questions and neither answers the other. A client can exit 0 having printed an error; a non-zero exit says your query failed, not that the work did. Check the exit status first, and on a non-zero exit record UNKNOWN without looking at stdout at all.
The mirror of this step — a waiter that trusts an exit status which FOLDS
several results into one — is
gh-pr-checks-exit-code-folds-a-by-design-red-wait-on-the-row. Between them:
never decide from the exit status alone, and never decide from the payload
without checking the exit status.
A suspend, a resume, a re-auth or a poll interval that plainly overran means the loop's next reading is the one most likely to be malformed. Throw it away, read again, and only then compare.
A monitor's verdict is a COPY of a state that lives elsewhere. Before reporting completion, deleting inputs, cancelling a sibling or starting a dependent stage, query each job directly, one at a time, and read the state out yourself. That one call is the cheapest step here and it is what keeps a bad parse from becoming a bad act.
An output object, a results file, a row with the run's id in it — written LAST, by the job, on the path it actually produces. An error string cannot forge one, and unlike a state field it distinguishes "finished" from "died". Pair it with the job's own terminal state: the marker proves the output exists, the state proves how the run ended.
Feed the parser its failure replies, not its happy one. Extract the done-decision into a function that takes the raw reply text, then assert on:
A monitor exercised only against a running job and a finished job has never run the branch that actually fires. If the loop is already written and running, do not edit it in place — a running script edited under itself is its own failure mode; verify the parser in a copy and fix the loop on its next launch.
The watch that was right by accident. Hosted executions, watched by a background poll that ran one status call per job, projected five comma-separated fields and took the fifth as the completion time. The laptop slept overnight, so the poll did not fire while the work ran. On wake the status query returned no record and a single comma-free token reached the field test, which passed it as a completion time. The monitor printed a terminal state.
Both executions had in fact finished overnight, so the verdict matched reality — and that is the trap, not the reprieve. Nothing about the output looked wrong, nothing downstream disagreed, and the same token would have produced the same verdict over a job with hours left. The check was found by Step 6 and nothing else: before reporting completion, the session read each execution directly rather than trusting the monitor's line. What would otherwise have followed the verdict — telling the waiting session the work was done, and deleting the inputs as the next step in the brief — is where the cost of this bug actually lands, and none of it is recoverable by noticing later.
The shape to copy into the loop instead: read the state field by name; map it through a closed set of terminal values; treat anything else as UNKNOWN and print the raw reply; and re-read each job directly before the act.
job-reports-success-while-its-worker-was-oom-killed is a job listed as
SUCCEEDED whose forked worker was killed and whose output is empty. That is
the case for Step 7: a marker the work writes last is the only signal that
survives both a bad parse and an honest-but-hollow success.waiter-pgrep-matches-its-own-command-line asks this question
of a LOCAL process list, where absence cannot tell finished from died;
subagent-external-wait-orchestrator-takeover is the layer above — whether
the polling should be happening in this session at all;
scheduled-fallback-check-cites-stale-task-id covers the identifier a delayed
check names going stale between scheduling and firing; fan-out-cost-control
covers what a job loses when it is stopped before it writes anything out.A status projection is a contract with the client's output format, not with the service's API — read the client's own documentation for what it prints when the call itself fails.
Shell field splitting, measured rather than recalled — a line containing no delimiter is ONE field, and the splitters disagree about what that means:
printf 'ERROR: could not read the execution\n' | cut -d, -f5 # the WHOLE line
printf 'ERROR: could not read the execution\n' | cut -d, -f5 -s # nothing
printf 'ERROR: could not read the execution\n' | awk -F, '{print $5}' # empty
cut(1) passes a line with no delimiter through unchanged whatever field you
asked for, unless -s is given — so the error text becomes "field 5" and a
non-emptiness test passes on it. awk returns empty for the same input and
would have failed safe. That single flag is the mechanism behind the
measurement above; it is not a reason to trust awk either, because an empty
field read as "not finished" only fails in the quieter direction.
What 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.