perpetuum
Original:🇺🇸 English
Translated
6 scripts
Set up, supervise, and control a persistent multi-layer "explore → execute → escalate" agent loop on a project. Use whenever a user asks to keep an agent running on a task across sessions or days — finding bugs, polishing writing, distilling a style, watching feeds, scanning for gaps, or any task whose value grows with how many findings the agent produces. Also use when the user wants to inspect, pause, resume, stop, or send a new instruction to an already-running perpetuum task.
3installs
Sourcezc277584121/perpetuum
Added on
NPX Install
npx skill4agent add zc277584121/perpetuum perpetuumTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →perpetuum
A persistent three-layer "explore → execute → escalate" loop on top of
. Designed for tasks whose value grows with how many findings
or improvements an agent can produce over hours or days.
cc-useThis file is a router. Every mechanism below has a one-paragraph
summary here; details live in . Read the relevant
reference when the user's intent matches the corresponding section.
references/When to invoke this skill
- The user wants to start a new persistent loop on a project (bug hunting, style distillation, PR/issue triage, observability scanning, etc.)
- The user wants to inspect, pause, resume, stop, or nudge an already-running loop
- The user wants to answer an escalation the loop has surfaced
- The user wants to run multiple loops in parallel on the same project via git worktree
If the user's intent isn't clear from "use perpetuum" alone, ask
before doing anything.
Route by intent
| User wants to… | Read |
|---|---|
| Start a new task | |
| See current status | |
| Pause / resume / stop / kill | |
| Push an instruction / answer an escalation | |
| Parallel lines via git worktree | |
Write or adjust | |
| Understand the design rationale | |
How it works (architecture in one screen)
Layer 4 you + host agent monitor + relay (optional)
↓
Layer 3 trigger.sh heartbeat: paste prompts, wait for done
↓ flags, sleep, loop
Layer 2 middle agent (tmux) judge + dispatch, two prompts:
↕ 1_explore.md (plan)
2_execute.md (dispatch + judge)
Layer 1 inner agent fresh context per dispatch — has no
(cc-use) memory of previous cycles, cannot
rubber-stamp known behaviorThe split between Layer 1 (producer, fresh context) and Layer 2 (judge,
persistent context) is the GAN-like discriminator / generator
separation that prevents the self-certifying problem of or
Ralph Loop. Layer 1 reports back to Layer 2; Layer 2 commits, fixes,
or escalates.
/goalMechanisms (one paragraph each)
Each mechanism is summarized here; for the full procedure see the
linked reference.
-
Ratchet (monotonic progress). Every accepted finding becomes a local; every reject is a
git commit. The branch is monotonically improving — borrowed from Karpathy's AutoResearch pattern, but for tasks without a scalar metric. Details ingit reset.references/design.md -
Exploration vs exploitation split. Two prompts per cycle.is divergent (list dimensions, sample broadly, populate the backlog).
prompts/1_explore.mdis convergent (work through the backlog, commit or escalate). Lexically-sorted files mean you can drop aprompts/2_execute.mdin to add a reflection phase without touching code. Details in3_reflect.md.references/trigger.md -
Async human escalation.is the channel for ambiguous decisions the agent can't make alone. Agent writes Open items with A/B/C options; human writes answers in Resolved. New cycles run while questions sit unanswered — the loop never blocks on the human. Details in
escalations.md.references/feedback.md -
Inbox (human → agent push).is where the user nudges the agent: SKIP, PRIORITIZE, ADD, STOP, DIRECTION, NOTE, or plain natural language. Read at every cycle's explore phase. Details in
inbox.md.references/feedback.md -
Trigger abstraction. Three trigger types —(every N minutes),
schedule(poll an external state likeconditional),gh pr list(event-driven). Same Layer 2 and Layer 1; only Layer 3 differs. Default in examples iswebhookwith a 2-minute interval — see cost note below. Details inschedule.references/trigger.md -
Control signals./
touch .pausedto pause and resume;rm .pausedto gracefully stop after the current cycle;touch .stop_after_current+pkill -f trigger.shfor hard stop. File-level signals, no new protocol. Details intmux kill-session.references/control.md -
Parallel lines via git worktree. For several perpetuum tasks on the same project, useso each task gets its own branch and directory.
git worktree addrecords the worktree metadata. Details in_meta.md.references/worktree.md -
File-as-contract.is agent-maintained (humans should route changes through
plan.md);inbox.mdis human-write;inbox.mdis bidirectional with the "agent writes Open, human writes Resolved" convention. Nothing is enforced at the filesystem level — it's a convention, not a lock. Details inescalations.md.references/feedback.md
Task layout
When a task is initialized:
<project-or-worktree>/
└── .perpetuum/
└── <task-name>/
├── _meta.md worktree/branch metadata
├── trigger.sh per-task; adjusted during setup
├── prompts/
│ ├── 1_explore.md prompt 1: plan
│ └── 2_execute.md prompt 2: dispatch + judge + record
├── plan.md agent-maintained state machine
├── inbox.md human → agent
├── escalations.md agent ↔ human
├── trigger.log
└── state/
└── .cycle_done_* per-cycle sync flags (transient)Any file matching is fed to Layer 2
in lexical order, one per cycle phase. Default is 2
(, ); add
for a reflection phase,
to insert a step between, etc.
prompts/[0-9]+(\.[0-9]+)?_*.mdprompts/1_explore.mdprompts/2_execute.mdprompts/3_reflect.mdprompts/1.5_check.mdKeeping prompts in a subdirectory separates editable templates from
runtime state ( / / ) — users can
edit the dir freely without mixing prompt edits and state
edits.
plan.mdinbox.mdescalations.mdprompts/What the state files actually look like
Use these as templates when you generate or judge file content. Match
the structure; render the content in the user's language per the
language rule below.
plan.mdmarkdown
## Pending
- [ ] [auth] test expired token refresh
- [ ] [parse] malformed XML input
## Done
- [x] (cycle 3) [auth] login flow
- operation: cli login --user x
- observed: 200 + valid JWT
- status: PASS
- [x] (cycle 5) [parse] xss in error envelope
- status: [FIXED] commit:abc1234inbox.mdmarkdown
## Pending
- SKIP: postgres backend, not shipping
- PRIORITIZE: PR #123 first
- NOTE: I'm OOO Friday, no urgent escalations
## Processed
- (cycle 6) SKIP applied — removed 4 postgres items from plan.mdescalations.md## Open## Resolvedmarkdown
## Open
### (cycle 4) off-by-one in --range flag
A: 1-based inclusive (matches head/tail/sed)
B: 0-based half-open (matches array semantics in most languages)
C: leave both, document the discrepancy
## ResolvedSetting up a new task
Setup is the longest interaction this skill has with the user. Don't
rush it — a mis-launched perpetuum task wastes hours and tokens. Walk
the user through the steps below. Detail for each step lives in
; this section is the overview.
references/setup.md1. Prerequisites — confirm both are present
These are the only two things the skill depends on. Don't proceed if
either is missing.
-
skill must be available in whichever skill environment the current host agent uses. Layer 2 of perpetuum dispatches every unit of work to a fresh inner agent via
cc-use. Without it, there is no Layer 1.cc-useInstall it the same way perpetuum was installed:bashnpx skills add zc277584121/cc-use --all -gAfter installing, the user may need to reload skills before the current agent can see it. The exact command varies by host agent — Claude Code has; other agents may need a TUI restart. Follow that agent's docs./reload-skills -
must be installed locally. Verify with
tmux. The middle agent (Layer 2) lives in a persistent tmux session for the duration of the task.tmux -V
If is missing, ask the user whether to install it. If
is missing, point them to their package manager and stop — perpetuum
cannot run without it.
cc-usetmux2. Suitability gate — judge fit with the user
Not every task fits this architecture. A bad fit wastes the user's
tokens. Don't skip this step.
- Strong fit: "find more of X" / "converge toward Y" / "watch for Z" tasks. Dimensional structure. Per-finding independence.
- Poor fit: one-shot tasks; strongly linear builds; tasks needing synchronous human decisions; tasks shorter than ~30 minutes total.
If the task is borderline, reshape it with the user (e.g. turn
"refactor X" into "scan X module-by-module and surface one smell per
module"), or recommend a non-perpetuum approach (single agent run,
one-off dispatch). Full questionnaire in
.
cc-usereferences/setup.md3. Pick an example and create the task directory
Look at for the closest task shape and copy that
directory's contents to . Then
customize:
examples/<project>/.perpetuum/<task-name>/- — replace generic dimension hints with this project's actual axes; use the user's language
prompts/1_explore.md - — set the
prompts/2_execute.mdabsolute path; adjust commit-style and classification policy to the project--project - — set
trigger.shto something unique, adjustMIDDLE_SESSION, decide trigger type (schedule / conditional / webhook). The script also reads anMAX_ITERenv var: default is Claude Code, but users on Codex / Cursor / etc. can override before launch (e.g.AGENT_CMDor the saferAGENT_CMD="codex --dangerously-bypass-approvals-and-sandbox"). Mention this explicitly to non-Claude-Code users.AGENT_CMD="codex --full-auto" - — fill in worktree path, branch, parent repo, merge target
_meta.md - Leave ,
plan.md,inbox.mdempty (their skeletons are already in the example)escalations.md chmod +x trigger.sh
For parallel tasks on the same project, set up via
first — see .
git worktreereferences/worktree.md4. Cost / cadence confirmation — say this out loud
The default in schedule-type examples is
2 minutes, intended for full throttle. With , the
loop burns through all 20 cycles in a few hours; each cycle costs O(a
few inner-agent dispatches via ).
SLEEP_BETWEEN_CYCLESMAX_ITER=20cc-useBefore launching, ask the user:
- Do they have token budget for ~MAX_ITER cycles at this cadence?
- Are they on a usage-based plan (cost matters) or a flat plan (rate limits matter)?
- Will they babysit the first few cycles, or launch and walk away?
If they hesitate: bump (1800 = 30 min, 3600 =
1 hour), reduce , or switch to the trigger
pattern (only fires when there's real new work).
SLEEP_BETWEEN_CYCLESMAX_ITERconditionalDon't skip this step. A "$X overnight" surprise is the easiest way to
make the user pull the plug on perpetuum forever.
5. Optional first-cycle trial
For first-time users, suggest a trial with :
MAX_ITER=1bash
sed -i.bak 's/^MAX_ITER=.*/MAX_ITER=1/' .perpetuum/<task>/trigger.sh
.perpetuum/<task>/trigger.sh # foreground, watch one cycle
mv .perpetuum/<task>/trigger.sh.bak .perpetuum/<task>/trigger.shInspect , , and after the trial.
Adjust prompts if anything went sideways before running 20 cycles.
plan.mdescalations.mdgit log6. Suggest .gitignore
and launch
.gitignorebash
echo '.perpetuum/' >> <project>/.gitignore # unless the user wants state in git
nohup .perpetuum/<task>/trigger.sh > /dev/null 2>&1 &Or hand the launch command to the user to start when they're ready.
Known Codex compatibility quirks (already handled)
For Codex CLI users, two tmux/TUI quirks are handled by the default
. No user action needed; documented here so you know
what the extra send-key lines are for:
trigger.sh-
Codex tmux "Enter doesn't commit" bug (openai/codex#12645).uses the same five-step sequence cc-use uses (
send_prompt→C-u→paste-buffer -d→Enter→C-m).Enter -
"Create a plan?" popup on complex prompts. Codex pops this on long planning-style prompts (ourtriggers it).
1_explore.mddetects Codex viasend_promptand sends$AGENT_CMDafter paste to dismiss it.Escape
The execute prompts in instruct the middle agent to
escalate any cc-use failure rather than work around it locally —
surface it as a blocked-on-environment item in and
stop the cycle, do not fake a fresh inner context within your own
conversation.
examples/escalations.mdCore invariants (do not violate)
These are the things that keep the loop honest. Don't weaken them
when adjusting prompts or scripts:
- Every accepted finding becomes a local .
git commit - is agent-maintained; humans route changes through
plan.md.inbox.md - Layer 1 always runs in fresh context (per delegate, not a reused inner session within a cycle).
cc-use - Layer 2's prompts are atomic and lexically ordered; don't fuse them.
- Sync uses flag + tmux silence fallback + total timeout — all three are needed; don't drop one.
.cycle_done_*
After-setup briefing
After launching, walk the user through these in their language. The
user just handed a coding agent the keys to their codebase; they need
to know how to drive.
-
How a cycle runs. Trigger fires → middle agent reads/
plan.md→ pastes prompt 1 to plan, then prompt 2 to dispatch viainbox.md→ judges each result → commits, escalates, or records. Then sleep, repeat. The whole thing keeps going across cycles, restarts, and your absence.cc-use -
What they can edit, and how.
- — yes, anytime, write a one-liner under
inbox.md## Pending - — yes, write answers in
escalations.md## Resolved - /
prompts/1_explore.md— yes, the next cycle picks up editsprompts/2_execute.md - — yes for cadence /
trigger.shMAX_ITER - — avoid, agent-owned; route changes through
plan.mdinbox.md - — static after setup
_meta.md
-
Talk to you or edit files — both work. They can say things in natural language to the host agent and you translate to file operations; or they can edit files directly in their editor. Make both paths explicit; some users prefer one, some the other.Translation table for common natural-language requests (English phrasings shown — map equivalent intent in any user language to the same operation):
User intent You do "pause" / "stop for now" / "hold on" touch .perpetuum/<task>/.paused"resume" / "keep going" / "start again" rm .perpetuum/<task>/.paused"stop gracefully" / "finish this cycle and stop" touch .perpetuum/<task>/.stop_after_current"kill it" / "force stop" / "just stop" pkill -f trigger.sh ; tmux kill-session -t middle-<task>"skip X" / "don't bother with X" append toSKIP: Xinbox.md## Pending"prioritize Y" / "Y first" append toPRIORITIZE: Yinbox.md"add a test/scan for Z" append toADD: Zinbox.md"change direction to W" append toDIRECTION: Winbox.md"for question X, pick option A" edit the matching Open item, add the answer, move toescalations.md## Resolved"what's the status?" / "what's it doing?" tail + summarizetrigger.logPending/Done counts + list any unresolved escalationsplan.md -
Reset the cost expectation. Reiterate whatand
SLEEP_BETWEEN_CYCLESare set to and what that implies for spend over the next N hours. The cost conversation in step 4 happened before they knew the system; remind them now.MAX_ITER
Don't skip the briefing. A user who doesn't know they can pause and
edit will the loop in panic the first time they
want to change anything.
inbox.mdpkillLanguage rule
The markdown files this skill generates (, ,
, the two prompt files, and any text written into
them at runtime) are for the user to read.
plan.mdinbox.mdescalations.mdIf the user speaks any non-English language and doesn't explicitly
ask for another, generate all human-facing content (prompts, plan
items, escalation entries, status messages) in that language.
Boundary: this rule applies only to perpetuum's own files and
to the perpetuum ↔ human interaction. It does not apply to the
project's own code, code comments, commit messages, documentation,
or anything the inner agent produces as part of the actual task
work — those follow the project's existing conventions.
File names, config keys, shell variables, and scripts are always
English (cross-language stable).