$npx -y skills add levi-qiao/graphkit --skill loop-graphRun a long-horizon coding task as a small graph of agent nodes driven by two scheduled loops, instead of one drifting loop. Generates an executor node (works against a single-source-of-truth ledger) and a clean-context supervisor node that audits from outside the executor's conte
| 1 | # loop-graph — a graph of agent nodes, not a drifting loop |
| 2 | |
| 3 | ## What it does & why |
| 4 | |
| 5 | Turns a vague long-horizon request ("make it production-ready", "accuracy above baseline", "finish the migration") into a small **graph of agent nodes** that stays on-spec across many rounds: |
| 6 | |
| 7 | - an **executor node** — drives the work round by round against a single scoreboard; |
| 8 | - a **clean-context supervisor node** — audits the work from *outside* the executor's context (re-verifying claimed-done against the shared standards) and corrects course before drift compounds. |
| 9 | |
| 10 | Why a graph, not a loop: an agent grinding a long task **is inside the context that drifted**, so it rationalizes scope creep and calls half-done work "done". graphkit's nodes talk only through durable, inspectable state (ledger, git tree, directives file) — never a shared, polluted context. The supervisor boots fresh each tick and judges the run like an outside reviewer. |
| 11 | |
| 12 | ## The graph it builds |
| 13 | |
| 14 | ``` |
| 15 | ┌─────────────┐ reads / rewrites ┌──────────────┐ |
| 16 | │ EXECUTOR │ ───────────────────▶ │ │ |
| 17 | │ node │ ◀─────────────────── │ ledger.md │ ← single scoreboard |
| 18 | │ (does work) │ │ (shared state)│ |
| 19 | └─────────────┘ └──────────────┘ |
| 20 | ▲ ▲ |
| 21 | │ reads each round │ reads only (never writes it) |
| 22 | │ │ |
| 23 | ┌───────────────┐ appends corrections ┌──────────────────┐ |
| 24 | │ directives.md │ ◀──────────────────── │ SUPERVISOR │ ← fresh, CLEAN context |
| 25 | └───────────────┘ │ node (watches) │ every tick |
| 26 | └──────────────────┘ |
| 27 | │ checkpoint-commits clean work |
| 28 | │ escalates human-only calls |
| 29 | ▼ |
| 30 | git / you |
| 31 | ``` |
| 32 | |
| 33 | Five artifacts from a short interview: |
| 34 | |
| 35 | 1. **`executor.md`** — executor prompt: one task book, one cadence, anti-bloat rules, stop conditions, red lines. |
| 36 | 2. **`ledger.md`** — the single scoreboard both nodes read; the executor rewrites it every round. |
| 37 | 3. **`directives.md`** — the one-way corrections edge, seeded near-empty (STANDING locks + numbered corrections the supervisor appends). |
| 38 | 4. **`ops.md`** *(optional)* — durable env facts (build commands, credential/data policy) the executor consults, not re-derives. |
| 39 | 5. **`supervisor.md`** *(optional)* — supervisor prompt, scheduled; independently re-verifies claimed-done work, checkpoint-commits what passes, decides pending items, and corrects drift / steers the plan via the directives file. |
| 40 | |
| 41 | **Run directory — fixed, one per run.** Everything above goes in `.graphkit/<YYYY-MM-DD-slug>/` at the repo root (workspace root for multi-repo runs), plus an `archive/` subdir for in-run rotations. **A new run gets a new directory, generated fresh from the templates — never retarget or edit a previous run's files**: patching stale prompts wastes tokens and leaves leftover text steering toward the old goal. The old directory stays untouched (it *is* the archive); distill what still holds into the new ledger's starting snapshot and copy still-in-force STANDING directives forward. Commit the run directory unless data policy forbids — it's the durable state the graph depends on. |
| 42 | |
| 43 | Invariants: **ledger = the only scoreboard**; **one item per round → verify → update ledger**; **the supervisor steers only through `directives.md` (a one-way edge) — it never edits the ledger or shares the executor's context**. |
| 44 | |
| 45 | ## When to use it |
| 46 | |
| 47 | - Task spans many rounds; the user won't babysit each one. |
| 48 | - "Done" is verifiable (tests, gates, metrics) — the graph needs a definition of done it can check itself. |
| 49 | - Real risk of scope creep, "looks done" work, or quietly changing contracts / lowering the bar. |
| 50 | |
| 51 | **Not** for a one-shot edit, or when success needs a human to judge every time — say so, suggest a |