session-sandbox
Skill0 starsChanged 5 months agoMITView on GitHub
Safely develop and test automation that starts/kills Claude or tmux sessions, installs cron/systemd timers, or touches live sessions — inside an isolated, guard-enforced sandbox where only sbx-* names can be targeted, so real sessions are structurally unreachable (a sandbox session may still refresh itself). Use before building any session-continuity / rotation / auto-launch / auto-resume mechanism, or any script that could kill a session, install a cron job, or change global config. Prevents the "it ran on my live session and broke it" failure.
In this repository57 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ask-mattSkill
- cast-memberSkill
- check-feedbackSkill
- codebase-designSkill
- content-pipeline-initSkill
- content-pipelineSkill
- data-analystSkill
- decision-mappingSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- draft-asset-promptsSkill
- edit-articleSkill
- fableSkill
- game-concept-interviewSkill
- git-guardrails-claude-codeSkill
- global-guidelinesSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- implementSkill
- improve-codebase-architectureSkill
- karpathy-guidelinesSkill
- launch-sessionSkill
- lesson-reviewSkill
- link-claude-skillsSkill
- loop-meSkill
- migrate-to-shoehornSkill
- obsidian-vaultSkill
- opusSkill
- prototypeSkill
- publish-metadataSkill
- resolving-merge-conflictsSkill
- retrieve-lessonsSkill
- reviewSkill
- rotate-sessionSkill
- run-buildSkill
- run-clipsSkill
- scaffold-exercisesSkill
- setup-matt-pocock-skillsSkill
- setup-pre-commitSkill
- setup-status-lineSkill
- showrunner-shortSkill
- sonnetSkill
- tddSkill
- teachSkill
- to-issuesSkill
- to-prdSkill
- triageSkill
- verify-outputsSkill
- wrap-allSkill
- wrapSkill
- writing-beatsSkill
- writing-fragmentsSkill
- writing-great-skillsSkill
- writing-shapeSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
PROVE the guard first: Run sbx_assert_target against the real session names on the box AND a couple of sbx-* names.
- Distinctive: line 61
BEFORE the kill — that ordering, not a timer, is what guarantees no gap in coverage.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
session-sandbox — develop live-session automation without blast radius
Any automation that starts, kills, or rotates Claude/tmux sessions, installs cron/systemd timers, or edits global config can damage a real running session (e.g. the operator's live session) if a name, env var, or pattern resolves wrong. This skill develops such automation in an isolated sandbox where a single guard makes non-sandbox targets impossible to hit — then promotes it only once proven.
The one rule that makes it safe
Everything the sandbox can act on lives in a reserved namespace: names MUST match ^sbx-[a-z0-9]+$.
A single guard (sbx_assert_target) refuses any name that isn't sbx-*. There is no kill-by-pattern
and no kill-all code path — the only kill is sbx_kill <sbx-name>, and it calls the guard first. A
typo or bad env var can therefore never resolve to a real session name (real sessions can't match the
prefix). A sbx-* session may target itself — self-rotation (refresh) is the whole point, and the
prefix, not a "== current" rule, is what keeps real sessions safe.
Workflow (do in order — prove the guard BEFORE any live action)
- Record the current live session (
tmux display-message -p '#S') and state plainly: this is never a target. It is protected by the guard, not by care. - Scaffold from
assets/into a sandbox repo (default~/repos/sandbox): copysbx-env.sh(the guard + constants),sbx-launch.sh(TTY-clean launcher),sbx-status.sh(read-only checks). AdjustSBX_REPO/SBX_MODELif needed. Keep thesbx-prefix, the${HOME}/.cache/…sandbox lock, and the# SANDBOX-CONTINUITYcron tag. - PROVE the guard first. Run
sbx_assert_targetagainst the real session names on the box AND a couple ofsbx-*names. Real names (and"", uppercase, injection strings) MUST all REFUSE; onlysbx-*ACCEPT. Do not launch anything until this passes. - Develop & test in isolation. Launch
sbx-1,sbx-2, … Verify each withsbx-status.sh: claude on a real TTY (/dev/pts/*) and relay-connected (established conn to Anthropic160.79.104.0/22). After every run, confirm the real session is untouched (pid +has-session). - Cron/timer tests go through the tagged helpers only — every sandbox cron line carries
# SANDBOX-CONTINUITY, so it can be added/removed surgically without touching other crontab entries (crontab -l | grep -v 'SANDBOX-CONTINUITY' | crontab -to clear only sandbox lines). - Promote only when certain. Once the mechanism is proven in the sandbox, adapt it for the real
target — parameterize the project dir, keep the guard, and (if it becomes a global
~/.claudeskill or edits global config) file the FYI issue your project requires.
Hard-won gotchas (bake these into whatever you build)
- Never
| teea session's launch command. Piping claude's stdout moves it off the TTY (stdout.isTTY == false) → the interactive TUI and remote control never initialise. Log withtmux pipe-pane -o -t <name> "cat >> log"instead — it captures pane output without touching the TTY. - Never
rm -fa live flock file. It unlinks the entry but the held lock stays on the old inode; a new open+flock succeeds on a different inode and defeats the mutex. Release by killing the holder. - Self-destruct needs an actual exit. An interactive session that hits the credit limit idles alive
(does not exit → does not self-clean). One-shot (
-p) ticks exit and self-clean; long interactive sessions are managed singletons — guard duplicates withhas-session. claude -pcannot be remote-controlled (headless ⊥ interactive). If it must be steerable, it must be interactive--remote-control.- Duplicate RC names collide on claude.ai. A dead session that registered a name can shadow a live one of the same name. Ensure the predecessor is fully dead before a successor claims the name.
Refresh (session rotation) — the proven mechanism
assets/sbx-rotate.sh <sbx-name> [delay_s] refreshes a session in place: writes a breadcrumb,
schedules a same-name successor (detached via systemd-run --user, so it survives the caller
dying — needs loginctl enable-linger), then guarded self-kill. From claude.ai the named session
drops, then reappears fresh after delay_s with the breadcrumb available. Schedule the successor
BEFORE the kill — that ordering, not a timer, is what guarantees no gap in coverage. Works as
self-rotation (run from inside the session) or driven from another session.
Assets
assets/sbx-env.sh— constants + the isolation guard (sbx_assert_target,sbx_kill). Source first.assets/sbx-launch.sh— launch onesbx-*remote-control session on a real TTY (pipe-pane logging).assets/sbx-rotate.sh— refresh/rotate asbx-*session (breadcrumb + same-name successor + self-kill).assets/sbx-status.sh— read-only: persbx-*session, on-TTY? relay-connected?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

