Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
broomva avatar

Persist

  • 5 installs
  • Updated May 18, 2026
  • broomva/persist

Persist is a Claude Code skill implementing a cross-context restart loop for long-horizon agent work, keeping state in the filesystem so each iteration runs in a fresh agent context.

About

This skill is a persistent-loop discipline for long-horizon agentic work where state lives in the filesystem (PROMPT.md, git tree, state.jsonl) rather than the conversation. Each iteration spawns a fresh agent context to avoid the context-rot failure mode past roughly 100K tokens. A developer uses it for work that may span hours and exceed the model's reliability horizon, with success gated by external signals like exit codes or tests.

  • Cross-context restart loop with state in the filesystem, not the conversation
  • Spawns a fresh agent context per iteration to avoid context rot past ~100K tokens
  • Validation backpressure from compilers/tests/linters, not model self-grading

Persist by the numbers

  • 5 all-time installs (skills.sh)
  • Ranked #13,046 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Jul 8, 2026 (Skillselion catalog sync)
At a glance

persist capabilities & compatibility

Capabilities
long horizon loop · agent orchestration · context management
Use cases
orchestration
Pricing
Free
From the docs

What persist says it does

Cross-context restart loop where state lives in the filesystem (PROMPT.md + git tree + state.jsonl), not in the conversation.
SKILL.md
**Persist solves this by restarting the context every iteration** while keeping state in the filesystem.
SKILL.md
Validation backpressure: compilers/tests/linters, **not** model self-grading
SKILL.md
npx skills add https://github.com/broomva/persist --skill persist

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5
Last updatedMay 18, 2026
Repositorybroomva/persist

What it does

Use it to run long-horizon agent work as a filesystem-state restart loop that survives context exhaustion and crashes.

Who is it for?

Long-horizon agent work that may exceed the model's ~1h reliability horizon or shows context drift past 100K tokens

Skip if: Short tasks that fit comfortably in a single context; the loop restart overhead is unnecessary there

When should I use this skill?

Before work that may exceed ~1h unsupervised, when session tokens cross ~100K, or when a fix has failed 3+ times

What you get

A filesystem-state restart loop where each iteration is a fresh context and success is verified by external signals

  • PROMPT.md loop spec
  • state.jsonl event log
  • iterated result gated by success condition

By the numbers

  • 3 success-condition forms
  • default 50 iterations / 4h wall-clock
  • context rot past ~100K tokens

Files

SKILL.mdMarkdownGitHub ↗

persist — bstack P12 Persistent Loop Discipline

Cross-context restart loop. State in filesystem, not conversation.

The defining moves: 1. The agent writes a goal + state snapshot to PROMPT.md 2. persist iterate PROMPT.md spawns a fresh agent context per iteration 3. State persists in the filesystem (PROMPT.md + git tree + state.jsonl) 4. Validation backpressure: compilers/tests/linters, not model self-grading 5. Loop exits when success_condition fires OR budget exhausted OR user interrupts

Why this exists

METR's Time Horizon 1.1 puts the 80%-reliability deployable horizon at ~1 hour on Opus 4.6. Above that, model coherence degrades silently — context rot past ~100K tokens (the Dumb Zone). In-context loops (ReAct/TAO) fail because they share the rotting context window. Persist solves this by restarting the context every iteration while keeping state in the filesystem.

When to invoke

The reflexive trigger rule (full text in workspace AGENTS.md §P12):

1. Before starting any work that may exceed ~1h of unsupervised agent time — write PROMPT.md, decide budget, pick success condition, call persist iterate. 2. When token usage in the current session crosses ~100K — restart instead of continuing in the rotted context. 3. When the same fix has been attempted ≥3 times without convergence — stop the in-context loop; write the diff history to PROMPT.md and start fresh. 4. When orchestrating long-horizon work — default to persist with periodic checkpoints; compose with P5 worktrees for parallel persist loops.

CLI

persist iterate PROMPT.md \
  --max-iterations 50 \
  --max-wall-clock 14400 \
  --success-condition "grep:DONE:STATUS" \
  --agent-cmd "claude -p '{}'"

persist status                  # show open loops
persist status --json           # machine-readable
persist abandon <loop-id>       # terminal: mark ABANDONED, free slot
persist doctor                  # health-check (state dir, git available)
persist conformance             # run test battery

The {} token in --agent-cmd is replaced with the prompt file's contents. Default agent is claude -p '{}'. Codex: --agent-cmd "codex {}". Gemini CLI: --agent-cmd "gemini -p '{}'".

Success conditions

Three forms:

  • `exit-code-0` — last agent invocation returned 0
  • `file-exists:PATH` — agent writes a sentinel file when done
  • `grep:PATTERN:FILE` — agent writes a status line that matches PATTERN

The agent is responsible for updating PROMPT.md or writing the sentinel file at the end of each iteration. The script doesn't try to interpret agent output — that's the backpressure must come from external signals invariant.

State machine

SPAWNED ──→ ITERATING ──→ ITERATING ──→ ... ──→ SUCCESS (terminal)
                  │                          ╲
                  ↓                           ↘ BUDGET_EXHAUSTED (terminal)
              PAUSED ──→ ITERATING            
                  │
                  ↓
              ABANDONED (terminal)

State events append to ~/.config/broomva/persist/state.jsonl (JSONL append-only with flock).

Composition with bstack

primitivecomposes via
P5 Parallel Agentsrun N persist loops, one per git worktree
P7 CI Watchereach iteration's pushed PR uses p9 watch for productive-wait
P10 Worktree Hygieneclean tree before iteration; janitor after each merge
P11 Empirical Feedbackper-iteration validation; persist's success_condition is multi-modal evidence
P6 Bookkeepingpersist loops produce graph-relevant material → bookkeeping replay between loops

Invariants

  • State lives in the filesystem. Each iteration starts from PROMPT.md content, not conversation history.
  • Validation backpressure is external. Don't ask the agent "are you done?" — check exit codes, file presence, or status pattern.
  • Budget bounds must be honored. Default 50 iterations / 4h wall-clock. The 4h default matches METR's 80%-horizon ceiling.
  • State.jsonl is append-only. Loop terminations are terminal — no resurrection. To restart, spawn a new loop with a new ID.
  • Each iteration is a fresh process. persist calls the agent CLI in a subprocess; agent context never persists between iterations except via filesystem state.

See also

Background

Pattern popularized by Geoffrey Huntley as "everything is a ralph loop" (Jan 2026). Anthropic shipped a `ralph-wiggum` plugin; OpenAI shipped `/goal` in Codex CLI 0.128.0. bstack's P12 is the same mechanism with non-anthropomorphized naming and explicit composition with the rest of the bstack contract.

Related skills

FAQ

Where does state live?

In the filesystem: PROMPT.md, the git tree and state.jsonl, not in the conversation history, so each iteration starts fresh.

How is completion decided?

By external success conditions: exit-code-0, a sentinel file, or a grep pattern in a status file, never by asking the model if it is done.

What are the default budgets?

50 iterations or a 4h wall-clock, where the 4h default matches METR's 80%-reliability horizon ceiling.

AI & Agent Buildingagentsautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.