/agent-traffic-control:extract-workflow-markdown-from-output-jsonfrom agent-traffic-control
Use when a Workflow (or background Agent) synthesis step returns a LARGE markdown deliverable inside a structured-output (schema) field — e.g. a `next_prompt_markdown`, a full report, a generated doc — and you need to persist it to a file. The completion notification TRUNCATES the result and shows the field JSON-escaped (literal `\n`, `\"`), so hand-retranscribing it into a Write call is both lossy (you only saw part of it) and error-prone (escapes leak as literal text). Trigger: you're about to retype an agent's big returned markdown blob from a `<task-notification>` or truncated tool result into a file. Symptoms it prevents: a saved doc containing literal `\n`/`\"`, or silently missing the tail past the truncation cap.
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 Workflow's synthesis agent(..., {schema}) returns a big markdown deliverable in a schema
field (e.g. next_prompt_markdown, report, plan). You want it on disk. The instinct is to
copy it out of the completion <task-notification> (or the truncated tool result) into a Write
call. Two failures follow:
... (truncated N chars, full result in <path>). Retyping from it silently drops
everything past the cap.\n, quotes are
\". Hand-copying (or reflowing) it often ships those escapes as literal text in the saved file,
so the markdown renders as one line with visible \n.Workflow / background Agent finished; its result contains a long markdown/string field you
want to save as a .md (a next-session prompt, a synthesized report, generated copy).<task-notification> says full result in /private/tmp/.../tasks/<task-id>.output.The full, unescaped result is always persisted to the output file named in the notification
(.../tasks/<task-id>.output, a JSON envelope {summary, agentCount, logs, result}). Parse it and
write the field — let json.load do the unescaping; never retype.
OUT="/private/tmp/.../tasks/<task-id>.output" # path from the <task-notification>
python3 - "$OUT" <<'PY'
import json, sys
r = json.load(open(sys.argv[1]))["result"]
# navigate to the field (e.g. result.synthesis.next_prompt_markdown)
doc = r["synthesis"]["next_prompt_markdown"]
open("docs/handoffs/the_doc.md", "w").write("<your header>\n\n" + doc + "\n")
PY
current_state/files_to_touch), build it in the SAME python pass —
you already have the parsed object.Agent whose final text you saved, and for resuming from a
killed run via the agent-*.jsonl transcripts.grep -c '\\n' the_doc.md → must be 0 (no literal backslash-n leaked).head the file: the markdown header/structure renders as real newlines, not one wrapped line.truncated N chars hint — if your file is
~the truncation cap, you retyped the truncated view by mistake).python3 -m json.tool "$OUT" >/dev/null confirms the envelope is valid JSON before extracting.A 4-investigator + synthesis Workflow returned a large next_prompt_markdown (~28KB, a full
paste-ready next-session prompt) plus four per-issue findings objects. The notification truncated at
~35k tokens (roughly line 100 of 170). Instead of retyping the prompt, I json.load-ed the
tasks/<task-id>.output envelope, wrote result.synthesis.next_prompt_markdown to the handoff doc
(with a prepended provenance header) AND built a second evidence doc from result.findings in the
same pass. Verified grep -c '\n' = 0 and the header rendered. Hand-retranscription would have
dropped a large fraction (~40%) of the prompt and risked literal-\n leakage.
/private/tmp/.../<session>/tasks/<task-id>.output — ephemeral; extract
before it's cleaned up, and copy it into docs/ (e.g. docs/reviews/ or docs/analysis/) if you
want durable provenance.flatten-workflow-parallel-arrays-before-collecting,
workflow-standalone-schema-agent-crash-and-args-string (other Workflow-mechanics traps),
claude-code-transcript-token-dedup-by-message-id (reading agent transcripts directly).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.