self-cycle
Skill0 starsChanged 58 days agoMITView on GitHub
Arm a detached watchdog that compacts or restarts THIS Claude Code session inside its cmux pane and then re-prompts it so outstanding work continues. Use when the user asks to self-compact, auto-compact, self-refresh, self-restart, cycle the session, or pick up a new Claude Code build without losing the current task.
In this repository2 other files it gives its agents.
- self-compactSkill
- self-refreshSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Write a specific continuation prompt, then:
≈ “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
self-cycle
Two operations, one engine (selfcycle.sh):
- compact — inject
/compact, wait for a transcript outcome, re-prompt. - refresh — respawn the pane on its cmux resume binding, re-prompt the restored session.
Claude Code also exposes these as /self-compact and /self-refresh. This skill is the installable package that includes the engine. After npx skills add, run install.sh once so those slash names exist under ~/.claude/skills (and under ~/.agents/skills / ~/.cursor/skills if those directories are already present). The installer is idempotent.
Engine path
ENGINE="${SELFCYCLE_HOME:-$HOME/.claude/skills/self-cycle}/selfcycle.sh"
[ -f "$ENGINE" ] || ENGINE="$HOME/.agents/skills/self-cycle/selfcycle.sh"Compact
Write a specific continuation prompt, then:
bash "$ENGINE" compact "<continuation prompt>"End the turn immediately. SELFCYCLE_ARMED means the watchdog fires in ~8s. SELFCYCLE_ABORT means nothing was armed — report the reason and stop; do not retry.
Refresh
Same pattern, but the pane will be killed:
bash "$ENGINE" refresh "<continuation prompt>"Refuse if you are mid-flight on work a restart would lose, a /goal is in progress, or you still need background tasks / subagents. Refresh a sweep driver last.
SELFCYCLE_ABORT no cmux resume binding means respawn would destroy the conversation. Sessions started by typing claude into a shell have no binding.
Recovery
bash "$ENGINE" status
bash "$ENGINE" abort
bash "$ENGINE" doctorLog: state/selfcycle.log next to the engine.
Requirements
cmux (macOS 14+), a terminal cmux pane (CMUX_SURFACE_ID), cmux's Claude Code hook registry, jq, and bash 3.2+. There is no tmux/iTerm fallback. See README.md.
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.

