/agent-traffic-control:recover-killed-session-from-transcript-and-worktreefrom agent-traffic-control
Recover a prior Claude Code session that crashed or was killed mid task — its plan, its work and what killed it — from its transcript and its leftover worktree.
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.
A prior session was doing real work (building a feature, fixing a batch of issues) and got killed mid-task — a hung tool call, an API 529 after a long run, the user quit. It left uncommitted WIP and a half-finished plan, but no handoff. Starting fresh wastes the work AND risks repeating whatever killed it. The session's full intent + state lives in its transcript JSONL + its worktree artifacts — recover from there.
Every trigger below depends on a human noticing. That is this skill's weak point, not its scope: a subagent killed mid-run leaves its partial output sitting in the parent's transcript, and a later session resuming that branch reads it as a finished result. Nothing prompts anyone to reach for this skill at all.
The resume-gate hook in this same plugin is the automatic trigger.
It runs on SessionStart:resume, detects the two ways a subagent dies (the harness's own
partial-output notice for a synchronous one; a non-completed task-notification status for an
async one), names each affected subagent, and puts an ask prompt in front of push / merge /
deploy until they have been re-verified. Its warning points back here. Install it once and step
4 below stops depending on you remembering to do it.
resume-gate warning on session start naming a subagent whose work was never assessed.tasks/session_N_todo.md (or similar
plan file) + maybe a baseline screenshot, but no matching merged PRs.git -C <repo> worktree list # find the named worktree + its branch/HEAD
ls <worktree>/tasks/ <worktree>/ # leftover plan (session_N_todo.md), baseline pngs
git -C <code-repo> status -sb # uncommitted WIP from the killed run
git -C <code-repo> reflog -20 # what it did right before dying
A leftover tasks/session_N_todo.md is gold — it's usually the killed session's (often advisor-vetted)
plan with specific implementation notes. Read it FIRST; it may make transcript-mining optional.
Transcripts live at ~/.claude/projects/<encoded-cwd>/*.jsonl, where <encoded-cwd> is the session's
working dir with /→- (a worktree at .../worktrees/token-app → ...-worktrees-token-app).
DIR=~/.claude/projects/<encoded-worktree-path>
ls -lt "$DIR"/*.jsonl # newest = most likely the killed session
for f in "$DIR"/*.jsonl; do printf "%6s %s\n" "$(wc -l < "$f")" "$(basename "$f")"; done
The killed session is usually the most-recently-modified file; it's often abnormally SHORT (died early) or ends abruptly. Confirm by reading its tail (below).
Each JSONL line is a JSON object; user content is a string, assistant content an array of
text/tool_use blocks. Extract with jq (don't read whole multi-MB files into context):
# user messages (decisions, instructions) — content is a STRING for type=="user"
jq -rc 'select(.type=="user" and (.message.content|type=="string")) | .message.content' "$f" \
| grep -viE 'system-reminder|tool_result'
# the last things that happened before death (cause)
jq -rc 'select(.type=="assistant") | .message.content[]? |
if .type=="text" then "TEXT:"+(.text[0:200]) elif .type=="tool_use" then "TOOL:"+.name else .type end' "$f" | tail -15
Recover:
tasks/*.md).browser_take_screenshot hung on "waiting for element to be stable" then API 529 — the screenshot
trap, see playwright-screenshot-hangs-on-infinite-animation. Knowing this, you AVOID the same call.)For large transcripts, dispatch a subagent to mine them (protects your context) — but transcript
mining can overload (a fan-out subagent 529'd here); if it fails, fall back to jq yourself.
A killed session's "fixed and verified" notes were frequently written mid-verification (it died before finishing). Real example: the dead run claimed "#50 fixed and verified numerically" but had only checked ONE symptom (the right-edge); the fix was actually incomplete (label still wrapped, value still clipped) — caught only by re-measuring fully. Re-verify inherited fixes end-to-end before trusting them.
resume-gate hook so the next killed subagent announces itself on
resume instead of waiting to be found. It also gates push/merge/deploy behind a human keypress
while anything is outstanding, which is the part that stops a partial result from shipping while
you are still deciding whether to run this procedure.playwright-screenshot-hangs-on-infinite-animation (a common session-killer),
claude-code-projects-jsonl-worktree-fanout + claude-code-session-shipped-and-agent-labels-from-transcript
(transcript-location + extraction mechanics), handoff-prompt-stale-user-hint-newer-state (the
related "newer state landed since the prompt" case).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.
session-handoff-detect-prior-orphan-pr — a previous handoff run already left a branch, PR or worktree behind — find it before opening a duplicatesession-handoff-number-collision-with-unmerged-sibling — two sessions picked the same handoff number because each only sees what merged on its own branchverify-live-prod-before-shipping-superseded-fix — a parallel session already shipped a different fix to the same live artefact while you were building yoursdurable-script-copy-still-imports-the-session-scratchpad — the dead session's script you are about to re-run was copied somewhere durable but still imports its helper from the scratchpad, so it dies with /tmp; and the same check applies to anything YOU save for the next sessionWhat 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.