/unicorn-team:long-runningfrom unicorn-team
Orchestrates long-running, multi-iteration tasks with checkpointing, resume packs, and per-iteration enforcement gates. Use for tasks spanning multiple sessions or context windows.
Ships in unicorn-team. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill mimics the Fable 5 long-horizon harness by enabling multi-iteration workflows with durable state, self-pacing, and iterative enforcement. It adds two core primitives: durable .loop/ state files that persist across sessions, and the unicorn-team:loop-assist GO/NO-GO gate that enforces quality and coherence at every iteration boundary.
Fable 5 gets this machinery from its harness: scheduled wakeups, context continuation, a durable workflow journal, and between-turn verification. On sonnet or opus none of that exists, so this skill reconstructs each piece from files, agents, and commands the plugin already has. The operating principle: the loop is only as durable as its state files.
| Situation | Use this skill? |
|---|---|
| Task spans multiple iterations/sessions/context windows | Yes |
| Overnight/unattended build-out via /loop | Yes |
| Babysitting an external system (CI, deploy) | Yes |
| Migration or backfill touching many modules over hours | Yes |
| Long build/suite you would otherwise poll | Yes (see background discipline) |
| Single-pass implementation that fits one context window | No, route via orchestrator |
| One-off question or small fix | No, answer or delegate directly |
| Fable 5 harness capability | Plugin equivalent |
|---|---|
| ScheduleWakeup self-pacing (delaySeconds, cache windows) | Pacing table + /loop interval guidance in long-running skill |
| Context summarization + continuation | .loop/handoff.md resume pack, rewritten every iteration for a fresh-context reader |
| Workflow journal + resumeFromRunId | .loop/journal.md append-only iteration log + deterministic re-entry protocol |
| Background tasks + task notifications | run_in_background + check-on-wake discipline (never busy-poll) |
| Token-budget directives (+500k style) | budget block in .loop/state.json + stop conditions |
| Harness verify/enforcement | unicorn-team:loop-assist GO/NO-GO gate each iteration |
Full per-capability detail lives in references/fable-parity.md.
The lifecycle is: ORIENT -> EXECUTE -> VERIFY -> CHECKPOINT -> ENFORCE -> PACE.
| Step | What happens | Agent / tier | Artifact touched |
|---|---|---|---|
| ORIENT | Read .loop/handoff.md then .loop/state.json; never re-derive state from raw git history. Cheap (haiku-grade reading). | haiku | handoff.md, state.json |
| EXECUTE | Delegate next milestone to unicorn-team:developer @ sonnet; TDD mandatory (RED -> GREEN -> REFACTOR). | sonnet | code + tests |
| VERIFY | unicorn-team:qa-security @ sonnet for risky milestones; otherwise run tests + lint directly. | sonnet | tests, lint output |
| CHECKPOINT | Update state.json (milestone status, iteration++), APPEND journal.md, REWRITE handoff.md from scratch. | self | state.json, journal.md, handoff.md |
| ENFORCE | Spawn unicorn-team:loop-assist @ haiku. GO -> continue; NO-GO -> re-delegate fix-list (max 2 rounds); STOP -> finalize. | haiku | state.json, handoff.md |
| PACE | Choose next interval from pacing table, or end loop. | self | pacing table |
.loop/handoff.md to reconstruct the current goal and context..loop/state.json to identify the next milestone and its status.Agent tool -> unicorn-team:developer @ sonnet
Milestone ID: {milestone-id}
Title: {milestone-title}
Acceptance Criteria:
{acceptance-criteria}
TDD Mandate: RED -> GREEN -> REFACTOR
- Write failing test first (RED)
- Implement minimal code to pass (GREEN)
- Refactor for clarity and maintainability (REFACTOR)
- Run the FULL test suite before committing
- Commit message format: `feat({milestone-id}): <description>`
- Do not commit debug code, console.log, or temporary files
- Do not modify any files outside the scope of this milestone
pytest --tb=short and ruff check directly.iteration counter in .loop/state.json.done in milestones[].## Iteration N -- <ISO date> entry to .loop/journal.md with:
.loop/handoff.md with a fresh, self-contained summary including:
unicorn-team:loop-assist @ haiku with the following prompt template:Agent tool -> unicorn-team:loop-assist @ haiku
Run: scripts/verify-next-run.sh
Evaluate the following checks:
E1: state.json is coherent (parses, one unambiguous next milestone, acceptance testable)
E2: regression baseline is green (full test suite passes)
E3: verification harness is in place (runner, lint, type config exist; acceptance expressible as failing tests)
E4: working tree is clean (committed, no stray files, no debug code, no unresolved task markers)
E5: handoff.md is fresh (rewritten this iteration, sufficient for fresh agent)
E6: journal.md has appended this iteration's entry
E7: stop conditions are evaluated (budget, iterations, repeated failures, user triggers)
Return exactly one of: GO, NO-GO, or STOP
Include evidence per check (e.g., "E1: two milestones marked in_progress" -> NO-GO)
Repair .loop/ artifacts yourself only when they are the sole deficiency; return
code deficiencies as a fix-list with an owner agent per item.
.loop/ artifacts itself (state.json, journal.md, handoff.md) when they are the only deficiency, then re-runs the checks.| Waiting on | Interval | Why |
|---|---|---|
| External state that changes in minutes (CI, deploy, queue) | 60-270s | Stays inside the 5-min prompt-cache window |
| Anything "about 5 minutes" | 270s, never ~300s | 300s pays the cache miss without amortizing it |
| Work that takes tens of minutes / idle heartbeat | 1200-1800s | One cache miss buys a long wait |
| Harness-tracked background work | Long fallback only (1200s+) | Completion re-invokes you; polling is waste |
Evaluated at ENFORCE from state.json stop_conditions[] and budget. Canonical triggers:
On STOP: finalize journal + handoff, report final state, end loop. Record which stop condition fired in the final journal entry.
/loop 20mrun_in_background -> 1200s fallback only| File | Discipline | Contents |
|---|---|---|
.loop/state.json | machine-readable, single source of milestone truth | goal, milestones[] {id, title, acceptance, status: pending / in_progress / done}, iteration, stop_conditions[], budget {iterations_max, notes}, updated (ISO date) |
.loop/journal.md | APPEND-ONLY | One ## Iteration N -- <date> entry per cycle: did / verified / deficiencies / next |
.loop/handoff.md | REWRITTEN each iteration | Goal, current state summary, exact next step + acceptance criteria, known risks/landmines, verify commands, pointers to key files |
Quickstart bash block:
skills/long-running/scripts/loop-state.sh init "Bookstore inventory REST API"
skills/long-running/scripts/loop-state.sh status
skills/long-running/scripts/loop-state.sh next
skills/long-running/scripts/loop-state.sh check
Never hand-edit state.json mid-iteration; ORIENT (read) and CHECKPOINT (write) are the only touch points. Full schemas + worked examples in references/state-format.md.
For a fresh session or fresh context window:
.loop/handoff.md FIRST..loop/state.json second..loop/journal.md third.scripts/verify-next-run.sh BEFORE doing any work.On NO-GO:
verify-next-run.sh to confirm all checks pass before continuing.cat .loop/handoff.md
skills/long-running/scripts/loop-state.sh status
tail -40 .loop/journal.md
skills/long-running/scripts/verify-next-run.sh
The whole resume should cost a few hundred lines of reading, not a re-derivation of history; that is what the handoff is for.
run_in_background for long builds or test suites.| You want | Do this |
|---|---|
| Interactive session | Drive the lifecycle inline yourself, step by step |
| Unattended interval loop | /loop <interval> with LOOP-PROMPT.md; pick interval from the pacing table |
| Exactly one enforced iteration | /long-task workflow (available after skills/orchestrator/scripts/install-workflows.sh) |
# Unattended: one milestone per wake, 20-minute cadence
/loop 20m /orchestrator # paste the cycle prompt from LOOP-PROMPT.md
| Check | Certifies | Mechanical or judgment |
|---|---|---|
| E1: state coherent | state.json parses, exactly one unambiguous next milestone, testable acceptance | mechanical + judgment |
| E2: baseline green | full suite passes NOW | mechanical |
| E3: harness in place | runner + lint/type config exist; acceptance expressible as failing tests | judgment |
| E4: tree clean + no markers/debug code | committed, no stray files, no unresolved task markers, no debug code | mechanical |
| E5: handoff fresh | rewritten this iteration, sufficient for a fresh-context agent | mechanical (mtime) + judgment |
| E6: journal appended | this iteration's entry exists | mechanical |
| E7: stop conditions | recommend STOP over GO when met | judgment |
The mechanical half is scripts/verify-next-run.sh (exit code = number of failed checks).
Full check definitions and the may-fix vs must-re-delegate table live in agents/loop-assist.md.
references/fable-parity.md -- Maps Fable 5 harness features to plugin equivalents.references/state-format.md -- Full JSON schema and worked examples for .loop/ state files.scripts/loop-state.sh -- CLI tool to initialize, query, and validate .loop/ state.scripts/verify-next-run.sh -- Validates enforcement contract; exits with count of failed checks.agents/loop-assist.md -- Definition of the GO/NO-GO gate agent and its decision logic.LOOP-PROMPT.md -- Template for unattended loop prompts; defines context and pacing intent.skills/orchestrator/SKILL.md -- Routing and tiering for the agents this loop delegates to.What SKILL.md sets; muted values are Claude Code's defaults
15 skills in this plugin
/code-readingStrategic code comprehension protocol for navigating existing codebases. ALWAYS trigger on "understand this code", "how does this work", "refactor", "before changing", "legacy code", "code review", "what does this do", "explain this codebase", "walk me through", "unfamiliar code", "read through". Use when exploring unfamiliar code, preparing to modify legacy systems, debugging complex issues, or conducting code reviews. Different from pattern-transfer which maps known solutions across domains -- this skill builds accurate mental models of existing code./domain-devopsGuides the user through containerization, CI/CD pipelines, Kubernetes deployments, observability, and infrastructure management. ALWAYS trigger on "dockerize", "CI/CD", "kubernetes", "deploy", "monitoring", "logging", "metrics", "helm", "infrastructure", "observability", "rollback", "scaling", "pipeline", "container", "k8s", "GitOps", "Dockerfile", "health check", "troubleshoot deployment". Use when containerizing applications, building pipelines, deploying services, setting up monitoring, or debugging infrastructure issues. Different from the DevOps agent (agents/devops.md) which handles orchestration and runbook execution rather than pattern guidance./estimationGuides the user through risk-based task estimation using decomposition, three-point estimates, and PERT formula. ALWAYS trigger on "estimate", "how long will this take", "time to complete", "sizing", "scope this", "effort estimate", "how many hours", "story points", "project timeline", "when will this be done", "cost estimate", "level of effort". Use when sizing any work item, feature, or project.npx claudepluginhub aj-geddes/unicorn-team --plugin unicorn-teamOther plugins' skills for the same job