skills/long-running/SKILL.md
Orchestrates long-running, multi-iteration tasks with Fable-5-style checkpointing, resume packs, self-paced scheduling, and per-iteration enforcement gates. ALWAYS trigger on "long running task", "keep working", "work overnight", "autonomous loop", "checkpoint", "resume where we left off", "iterate until done", "multi-session task", "self-pacing", "background build". Use when a task spans multiple iterations, sessions, or context windows. Different from orchestrator which routes a single pass -- this skill manages state, pacing, and enforcement across iterations.
npx skillsauth add aj-geddes/unicorn-team long-runningInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.tools
Coordinates the 10X Unicorn agent team with cost-aware model tiering, MCP-aware routing, and workflow fan-out. ALWAYS trigger on "implement", "build", "create", "design system", "deploy", "learn new language", "refactor", "fix bug", "set up CI", "code review", "how long will this take", "estimate", "architecture", "add feature", "write code", "debug", "review PR", "set up pipeline", "migrate", "optimize". Use for any multi-step task, implementation request, architecture decision, or quality enforcement. Different from individual agent skills which handle execution -- this skill handles coordination, routing, model selection, and quality gates.
development
Guides the user through test-first development and test strategy decisions. ALWAYS trigger on "write tests", "TDD", "test coverage", "mock", "test fails", "flaky test", "how to test", "unit test", "integration test", "e2e test", "test structure", "what to test", "test organization", "coverage report", "testing strategy", "arrange act assert". Use when writing new tests, choosing test types, setting up mocking, debugging flaky tests, improving coverage, or designing testable code. Different from qa-security agent which focuses on code review and security audits rather than test authoring.
development
Guides deliberate management of technical debt: recognition, tracking, prioritization, and paydown. ALWAYS trigger on "technical debt", "code shortcut", "pay down debt", "debt tracking", "just for now", "temporary hack", "hardcoded value", "copy-paste code", "missing tests", "TODO cleanup", "refactor plan", "debt priority", "interest cost", "boy scout rule", "code quality backlog". Use when taking a shortcut, discovering suboptimal code, planning debt paydown, or quantifying ongoing cost of compromises.
development
Guides the user through systematic pre-commit quality verification. ALWAYS trigger on "review my code", "check my work", "before commit", "self-review", "quality check", "am I ready to commit", "pre-commit review", "code quality", "verify my changes", "sanity check", "review before merge", "is this ready". Use before any commit, merge, or code review submission.