/agent-traffic-control:durable-script-copy-still-imports-the-session-scratchpadfrom agent-traffic-control
You copied a script out of the session scratchpad into a durable directory so the next session (or the next you) can re-run it — but it still imports a helper from the scratchpad, so the copy dies with `/tmp` and looks complete until someone runs it. Use when: (1) you are saving a wrap-up, re-run or analysis script anywhere outside the scratchpad; (2) a handoff note, issue or pull request body points a reader at a script "saved to" a durable path; (3) you are about to say a script, log or artefact is preserved; (4) you are re-running a predecessor's saved script and hit `ModuleNotFoundError`, `source: no such file`, or `Cannot find module`. A copy is durable only if its DEPENDENCIES are: a `sys.path.insert` of the session directory, a relative `source helper.sh`, a `require('./lib')`, or a data file read by absolute scratchpad path all outlive the copy by exactly as long as the temp directory lives. The failure is deferred to whoever trusts the handoff, and the bytes look identical to a working script. Copy every local import beside it, repoint the path to the script's own directory, and run the durable copy from the durable directory before you call it saved.
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.
The session scratchpad — a per-session directory under the system temp tree — is where a session writes its working scripts. At the end of the run you copy the useful one somewhere durable so the next session can re-run it: a logs directory outside the temp tree, a repo path, a shared folder.
The copy is a real copy and reads as finished. It is also dead on arrival if it still
reaches back into the scratchpad for anything: a helper module on sys.path, a sourced
shell fragment, a relative require, a data file named by absolute path. Nothing fails at
copy time. Nothing fails while this session is alive, because the scratchpad is still there.
It fails for the reader, later, with a ModuleNotFoundError naming a directory that no
longer exists — and by then nobody knows what the helper contained.
<durable path>" so a successor can re-run it.grep -rnE '/(private/)?tmp/|/var/folders/|scratchpad|sys\.path|source |require\(' <durable-dir>
Every hit is either a dependency to bring along or a path to rewrite. A sys.path.insert
naming the session directory is the classic; an absolute input path is the quiet one,
because the script starts fine and dies in the middle.
Copy each local helper beside the script. One directory, everything it needs.
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
Shell: . "$(dirname "$0")/helper.sh". Node: a relative require already resolves against
the file, so what breaks there is data paths rather than modules.
cd <durable-dir> && python3 ./wrapup.py --dry-run
Running it from the scratchpad proves nothing: the scratchpad is on the path and the helper is right there. If the script has no dry-run mode, run it in a throwaway copy of its target.
The honest test is whether the copy works with the scratchpad unreachable:
mv "$SCRATCHPAD" "$SCRATCHPAD.hidden" # your own session's, never a peer's
( cd <durable-dir> && python3 ./wrapup.py --dry-run ); rc=$?
mv "$SCRATCHPAD.hidden" "$SCRATCHPAD"
echo "durable-copy-exit=$rc"
That is the state the next reader is in. Anything else is a rehearsal on a stage that will have been struck.
A wrap-up script that edits a hand-maintained data file was written in the scratchpad
alongside a small parsing helper, then copied to a durable directory outside the temp
tree at the end of the session. The copy carried
sys.path.insert(0, "<session scratchpad>") and imported the helper by name. It would have raised ModuleNotFoundError the first time a later session ran
it — after the temp directory was cleared — while the directory listing showed a complete,
recently-saved script. Fixed by copying the helper beside it and repointing the insert at
os.path.dirname(os.path.abspath(__file__)).
<path>" belongs in a handoff only after
Step 4 has been run; until then, say the script exists and is untested outside the session.recover-killed-session-from-transcript-and-worktree
— the reader on the other end of this: a later session reconstructing a dead run from its
leftovers, for whom a script that cannot run is a dead end rather than a head start.session-context-runs-out-mid-brief-measure-first-hand-back-early
— what to put where the next reader will find it when a session ends early.What SKILL.md sets; muted values are Claude Code's defaults
118 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.
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control