/forge:fg-loopfrom forge
Drives unattended task loops (run → verify → seal) toward a machine-verifiable stop condition with bounded replan. Use when you want Claude to autonomously converge on a goal without per-step confirmation.
Ships in forge. 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.
This is not a stage of the forge loop. It is a goal-driven orchestrator: one upfront conversational inquiry fixes a machine-verifiable stop condition, then fg-loop drives whole task loops (run → verify → seal, the retro decided unattended inside the seal) until the stop-condition checks pass — including, within explicit bounds, generating its own fix-forward tasks when checks fail. It is the third lane next to the formal loop (retro conversation included) and fg-next all (drain the human-grilled backlog, halt at empty): fg-loop converges on a goal instead of merely draining a queue. Rationale and the three bounds: .forge/adr/0016-fg-loop-goal-driven-bounded-replan.md.
This deliberately relaxes pillar #1 within bounds (the precedent is fg-quick relaxing pillar #2 for trivial work — ADR-0003): fg-loop may create plans without a per-plan grilling conversation, but only inside the replan scope the user pre-authorized during the initial inquiry, and never past the cap or the walls. "The AI thinks it's done" is not a stop condition — only the recorded checks are.
Once the goal contract is pinned, the drive runs unattended to completion. It does not pause to ask the user for preferences or confirmations. At every soft decision point — one that carries a recommended or default option (a delegated skill's handoff menu, the TDD question, a slug-collision prompt, "which task first") — auto-select the recommended/default and proceed, recording each such choice as a ruling in that task's run.md ## Rulings section (definition: DRIVE.md Part 4); never turn such a choice into a question to the user. The retro is decided inside the seal: the drive invokes fg-done as an unattended seal (§2), which never asks.
The drive's only legitimate stops are goal-met, the walls and declared external-evidence waiting in §4, and a workflow-script approval the harness physically requires to continue. None of these human-needed walls is a "preference with a recommendation": each is a genuine block where proceeding alone would be wrong, not merely unconfirmed — a silently-sealed unverifiable UAT would violate ADR-0009; a genuine design fork is consequential and the human's to make. So "don't ask the user" and "halt at the walls" are not in tension — the walls are precisely the points where there is no recommendation to auto-pick.
Keep the initial inquiry (§1) lean: ask only what is needed to pin the machine-verifiable checks, the replan scope, and the cap. Take the documented defaults for everything else — TDD per .forge/config.json, the default replan scope, cap 3, auto-decompose into tasks — rather than grilling each sub-decision. The human judgment this lane preserves is pinning the stop condition up front, not approving each step toward it.
One deliberate exception carves out of "lean": the faithfulness of the stop-condition checks themselves. Leanness applies to the periphery — replan scope, cap, and sub-decisions (TDD, slug, task decomposition) — never to the checks. The checks are the only thing that decides "done" in an unattended drive, so a gameable or incomplete check is exactly what makes looping untrustworthy; grill the checks' faithfulness adversarially (the four faithfulness lenses declared in INQUIRY.md) even though that makes the check-pinning part of the inquiry non-lean. Grilling the checks hard is the "pinning the stop condition up front" this lane preserves, done properly — not a contradiction of leanness but its correct boundary (ADR-0016 amended 2026-07-16).
Language: This skill file is authored in English, but you MUST write every message shown to the user — inquiry questions, status lines, halt reports, and handoff text — in the user's language (detect it from the user's own messages), never mirroring this file's English. Documents it writes into the user's project (loop.md, generated plans) are written in the user's language.
Explaining forge: forge's vocabulary is not the user's — verified: failed, unsealed tail, a pillar or gate name means nothing unread. Always, never gated on eco: gloss a forge-specific term on first use in a message (a few words, not a paragraph), put the purpose before the mechanism, and lead with the answer, closing on what it means for the user. A gloss is not filler — with eco on, ECO.md's terse rules govern form (length, padding) while these govern vocabulary, so terseness never deletes a gloss.
Evidence and candor: every claim you make about code, state, or results — in a message or in a document you write (plan, run notes, retro, ADR) — carries its evidence in the same sentence (a file:line, a command and its output) or a label: Measured (you checked it this session), Inferred (reasoned from what you checked), Guess (a prediction or an unseen cause), rendered in the user's language. A label is not a license to skip a check — if a cheap check would settle it, run it; never hand the user a check you could run. Agreement is not the default: when asked whether to do something, invited to add scope, or shown an approach, give your real judgment first — the strongest objection, and "don't do it" when that is true. Change a recommendation only for a new fact or argument, never for repetition; the decision stays the user's — state the objection once, then follow their call without re-arguing or silently deviating. Output a deterministic script printed is already measured and needs no label.
Host contract: unattended driving depends on the host's prevent_stop capability (forge's Stop hook — the mechanism is defined once in ../fg-next/DRIVE.md Part 2). Read ../../core/HOST.md and check ../../hosts/<host>/capabilities.json. When prevent_stop is false or the host is unknown, the drive is not broken — it is turn-bounded: it runs as far as one turn allows, keeps loop.md, and resumes statelessly on re-trigger (DRIVE.md's honest fallback). Say so at drive entry rather than implying continuous execution. Every wall, gate, and cap in this file is host-neutral and unaffected.
Forge root: every .forge/... path below is relative to the resolved forge root — .forge/ on the default branch, .forge/branch/<branch>/ (git-tracked) on any other branch. Resolve it per ${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/skills/fg-run/FORGE-ROOT.md (skill-relative ../fg-run/FORGE-ROOT.md) before reading or writing state (ADR-0011).
Branch on whether the contract already exists. If .forge/loop.md is present, this drive is a resume: do not read INQUIRY.md — go to Resume preflight immediately below, which owns validating any newly supplied decision and writing contract updates, and only then continue to §2. The resume path is therefore complete from this file alone. If .forge/loop.md is absent, this is a new goal and the contract must be pinned first — read INQUIRY.md and follow it. It owns the whole conversational inquiry: settling the goal, the machine-verifiable stop-condition checks (and evidence: external), the approved fix-forward scope, the replan cap, the budget-tokens ceiling, the ## Tasks membership list, and writing loop.md plus the initial backlog.
The all argument — kept for compatibility (ADR 261024-191024). /fg-loop all <goal> used to switch on an auto-retro mode (ADR 261010-230950). Every seal now runs fg-done's retro judgment, so an auto retro log is written whenever a task left something to learn, in every loop — all is still accepted and means the same as /fg-loop <goal>. A legacy retro: auto / retro: skip field in an existing loop.md is read without error and changes nothing; the inquiry no longer writes it. The rest of the argument after all is the goal text, as without it.
This inquiry is conversational and outside any workflow (pillar #1) — it is split into that file only for token efficiency on the resume path, which is the common one during a drive; behavior is unchanged from when it lived inline.
If .forge/loop.md exists, skip the new-goal inquiry in INQUIRY.md — not this section — and read the saved goal, scope/exclusions, wall, ledger, and membership, together with decisions already given in this conversation. Do not reset wall: merely because the user re-triggers fg-loop or says "continue". Before creating a drive marker, running checks, or spending a replan round:
/goal instruction. Name the precise missing decision or evidence and stop. The next action is supplying that decision/evidence, not re-running fg-loop.wall: none and continue in the same turn without a second approval or a fresh trigger. Preserve cumulative rounds, spend, attempts, and regressions; apply normal evidence-based counter updates, never reset history just to bypass a wall. Re-evaluate all applicable gates before repair.The drive still selects only ## Tasks members. Leave non-member backlog plans untouched and report their count once. For a legacy contract missing ## Tasks, ask once which slugs belong before promotion. At any preflight halt, remove this invocation's drive marker if one exists, using the normal exit cleanup; never leave a blocked loop requesting automatic continuation.
Write the drive marker at entry, and delete it at every exit (ADR-0028 amended 2026-08-22). Only after resume preflight permits driving, and only when the host's prevent_stop capability is true, write <forge-root>/drive.md (started: epoch seconds · blocked: 0 · session: this session's id) — the shape and rationale are defined once in ../fg-next/ALL-MODE.md; do not restate them. forge's shipped Stop hook blocks the turn from ending while that marker lives, which is what lets /fg-loop alone drive to the stop condition without /goal (now a fallback). It is a separate file on purpose: nothing is added to loop.md, so this skill's discipline of absorbing new capability into existing sections rather than minting fields is untouched.
Delete the marker at every exit — all nine walls (no-progress · cap-exhausted · unverifiable-uat · fork · tension · safety · stalled-waiting · blocked-health · budget-exhausted), goal-met, and a waiting turn-end. The last one is easy to miss because waiting is deliberately not a wall (§4) — but the drive genuinely cannot proceed until external evidence lands, so a live marker there would spin the turn against something no local action can change. A workflow script approval is the same case.
Drive one task loop at a time, reusing fg-next all's machinery by reference (../fg-next/ALL-MODE.md — do not duplicate its rules here). Select the next backlog plan listed in loop.md's ## Tasks section, using fg-run's priority → part → slug order among members only, then invoke fg-run with that member's task: number or slug. fg-run still owns the promotion into the active slot; the explicit identifier prevents its ordinary multi-backlog selector from offering or auto-taking a non-member plan. A backlog plan not on the list is not the loop's to run: leave it untouched and mention it in one status line; it belongs to the formal loop. Then execute via fg-run, attempt the UAT aggressively, seal via fg-done as an unattended seal (its retro judgment records retro: skipped (<reason>) or writes an auto retro log with promotion deferred — same write-attribution as fg-next all; ADR 261024-191024), and continue. All per-task writes, including promotion, happen inside the delegated skills; fg-loop itself writes loop.md, the plans it generates (and deletes them again when they go stale unrun — see the stop conditions below), and the marker-only repaired-by provenance on an in-place failed repair (see §3) — this is the deliberate difference from fg-next, which writes nothing.
Follow-ups. Every delegated seal must run fg-done's candidate checkpoint (../fg-learn/FOLLOWUPS-FORMAT.md). Persist concrete future work in the ledger before the task sources are removed; neither a skipped retro nor an auto retro suppresses this write. Auto retros reuse run candidate IDs so later batch promotion cannot duplicate them.
The retro is fg-done's, decided unattended. fg-done's step 0b (../fg-done/SKILL.md) owns the judgment, and the auto retro log (<!-- auto-retro: fg-loop --> on its first line, nothing promoted or proposed). fg-loop adds only its own material: when it hands a task to fg-done, it points at that task's in-place repair record (repaired-by, the fresh run.md, the ledger's reflection: for its check), so a repaired task's retro sees what was tried.
pending or failed task.Do not end the turn between task loops (within-turn continuation — DRIVE.md Part 1). After sealing, immediately check the stop conditions and continue to a member task or bounded replan. Stop at goal-met, a wall, or a declared external-evidence wait. Cross-turn continuation and its honest host-dependent fallback are owned by DRIVE.md Part 2; a delegated handoff is not a new approval gate.
After each seal, and whenever the backlog empties, run the stop-condition checks and update both their checkboxes AND the ## Check progress ledger in loop.md (each check's result, its consecutive no-progress count ×N, its regression count regressed: ×N — compare each freshly-run result against the result the ledger currently records; a pass→fail flip is a regression event, but increment regressed: only when the just-sealed work was a fix-forward (a generated plan with generated-by: fg-loop, or an in-place repair carrying repaired-by: fg-loop) — that is the tension signal (§3). A flip caused by a human-grilled member task during backlog drain is normal multi-task interference, not tension: record it in last-evidence (the check is now failing, which the remaining backlog or the eventual fix-forward addresses) but do not count it toward regressed:, and do not halt the drain — the last-evidence you observed, and any tried: slug). This persisted ledger is what makes the no-progress wall, the tension wall, and fg-status work across a stateless resume — update it every run:
The ## Check progress ledger and the wall: field are load-bearing, not decorative — fg-loop is stateless across resumes, so without them a re-triggered drive cannot tell that a check already failed twice with no change, and would keep generating near-identical fix-forward tasks up to the cap (the "keeps proposing the same task with no progress" failure mode). After every stop-condition run, update each check's line: its result (pass/fail), the consecutive no-progress count (×N — increment when a check is still failing AND its evidence is unchanged from the prior round; reset to 0/“×1” on any observable change or pass), the regression count (regressed: ×N — a pass→fail flip against the previously-recorded run, incremented under the qualified rule stated above: only when the just-sealed work was a fix-forward. It is the signature of a fix-forward for one check breaking another, which the no-progress ×N misses because the flip is an observable change that resets it), the last-evidence (the command output you actually observed), and append the tried: slug when a fix-forward was generated for it. The no-progress wall reads ×N ≥ 2; the tension wall (§3/§4) reads regression recurrence; on any halt, set wall: to the precise cause so fg-status/resume report why (never a bare "resume fg-loop").
waiting is recorded in this same ledger — deliberately NOT as a new loop.md field. A check declared evidence: external and not passing records waiting ×N · last-evidence: "…" on its ledger line, where ×N is the count of consecutive drive halts at which it was still waiting (reset to 0 on a pass, or on any change in last-evidence). Three rules make it a genuinely distinct state rather than a relabelled failure:
waiting ×N never feeds fail ×N or regressed: ×N, and a waiting check does not consume replan-round. Polluting those counters would trip the no-progress and tension walls on a check that was never even judged.reflection:. Reflexion verbalizes why an attempt failed; a waiting check has no attempt to reflect on.wall: none, because nothing is being handed to a human (see §4). Never leave an earlier halt's cause in wall: while waiting: e.g. after the human resolves a blocked-health (gh) wall and re-triggers, if only an external check remains, the state must read wall: none + C3: waiting ×1 — not the resolved blocked-health — or fg-status would report the same moment as both "a wall you must resolve" and "a wait owing you nothing", and a stateless resume would misread the stale cause as current.
Keeping this in the ledger instead of a top-level waiting: field is the same discipline applied twice before (.forge/retro/2026-07-16-fg-loop-check-faithfulness-grilling.md): absorb a new capability into an existing section's output rather than minting a field, so the six downstream consumers of loop.md do not each need a new one. The cost is that "is anything waiting?" is read from the ledger rather than one top line — small, since every consumer already parses the ledger. started is stamped by the human at creation (skills can't read the clock) or left as a literal placeholder.Meter the spend at those same checkpoints — no new checkpoint is introduced (ADR-0016, amended 2026-08-19 / 2026-08-20). fg-loop only regains control at a task boundary (fg-run owns the workflow, and a Dynamic Workflow takes no input mid-run), so mid-task interruption is not a reachable option.
Be honest about what the number is when you report it. It is the raw four-field token total over every message.usage in this project's transcripts since since: — i.e. token throughput for the whole project while the loop is alive, not this drive's billed cost. Cache reads dominate it and are far cheaper per token, and work a human does in this repo between a wall and a resume lands in the next delta. Both are accepted: this is a safety bound, not an accounting ledger, and over-counting is the safe direction (an early halt is raised by a human; under-counting means the ceiling never fires). Counting cache reads is the point — they are the context re-sent on every iteration.
Call the meter ONCE per task boundary — bash "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/forge-loop-spend.sh", or node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/forge-loop-spend.js" where there is no bash (dual dispatch, ADR-0022). One call yields both verdicts; there is no --preflight flag. Post-hoc and pre-flight were once two calls at what is the same moment, and the first advanced since:, so the second re-counted the interval and inflated the spend (measured 10 → 20). Route by exit code (the script judges, this prose sets the wall — ADR-0030/0031):
3 (EXHAUSTED spent=N cap=M) → the ceiling is reached. Halt with wall: budget-exhausted (§4).4 (PREFLIGHT-HALT … avg=A remaining=R) → the remaining budget is below the observed per-task average (spend ÷ member tasks already sealed), so the next task probably cannot be covered. Halt with wall: budget-exhausted. The first task has no average and therefore always starts, which bounds the worst-case overshoot at one task; a conservative false halt is the safe failure direction.5 (BLOCKED <reason>) → a ceiling is declared but cannot be measured (transcript root unreadable, since: not a timestamp, ceiling value unparseable). Halt with wall: blocked-health (<reason>) — an environment defect, not a code one (§4 #8), and never read as "nothing spent yet". Reporting 0 spend here is what makes a broken ceiling invisible, so the two states are deliberately distinct.0 (OK …, or NONE no-budget-declared when budget-tokens: none) → carry on.The meter is host-coupled, and that coupling fails closed — say so before declaring a ceiling. What it sums is the raw token total of Claude Code's session and subagent transcript files (~/.claude/projects/<slug>/). On a host that does not write them, the derived root simply is not there, so the meter returns exit 5 (BLOCKED transcripts-unreadable) and the drive halts at blocked-health — it never reads an unreadable root as "nothing spent yet". That is the safe direction, but a halt on the first task boundary is a poor surprise, so when the active host is not Claude Code, either declare budget-tokens: none (the checks are bypassed entirely) or point the meter at that host's own transcript location with --transcripts DIR. There is deliberately no built-in path for another host: inventing one would be a claim about a location nobody has observed, and the capability discipline in ../../core/HOST.md forbids exactly that.
2/64 are state/usage faults, not budget verdicts — report them and do not invent a wall.Evaluate the stop conditions top to bottom; the first match wins — except the second line, a cleanup that always falls through to the lines below it. A member is a plan in backlog/ whose forge-slug is listed in loop.md's ## Tasks (a non-member plan never counts); "backlog empty" below means no member plan is left in backlog/.
wall: blocked-health (<name>), even with members unrun — a member drive must not continue past an environment defect.<!-- generated-by: fg-loop --> → discard every such stale generated member now, before any further task runs: it fixes-forward a failure that no longer exists. Delete its backlog/<slug>.md, remove its slug from ## Tasks, and record the slugs on one discarded: line in the ## Check progress ledger so a stateless resume can still report them — a later discard appends to that same line (cumulative, never overwritten), and ledger readers treat only Cn: lines as checks. fg-loop created these plans, so no human work is lost. The discriminator is the marker and all checks passing; a human-grilled member (no marker) is never discarded. Then continue with the next line.backlog/ → keep driving, whatever the checks say — including when every check already passes. Goal-met is not declared over unrun member work: once loop.md is gone, that work would run with no stop check watching it, so a member that broke a check would go unnoticed and the "all checks passing" report would already be stale. These tasks follow the normal drive rules (ledger, fix-forward, tension); a pass→fail flip caused by a human-grilled member is interference, not tension (the ledger rule above). Because this list is re-evaluated after every seal, any generated member still unrun at a later all-passing evaluation is discarded by the line above before the next member runs.loop.md's ## Tasks — the sealed member done/ paths and the auto retro count (see Handoff) — report a summary (tasks sealed, rounds used, check evidence), then delete loop.md, and stop. The loop is closed.evidence: external ones → this is waiting, not a failure and not a wall. Ensure wall: reads none before ending the turn (only after preflight has established that any earlier wall is resolved): a waiting turn-end with a leftover wall cause would present the same state as simultaneously "a wall the human must resolve" and "a wait owing the human nothing". Increment each such check's waiting ×N with the evidence you observed, consume no replan-round, generate no fix-forward, and end the turn with a report that says plainly: nothing is owed by the human — the drive resumes on the next fg-loop trigger once the external evidence has landed. Then apply the bound: if a check's waiting ×N reaches 2 with last-evidence unchanged, the wait has stalled — set wall: stalled-waiting (Cx) and hand it over (§4). Since no predicate can ever flip a declared-external check to "failed" (declared in INQUIRY.md), this bound is the only thing preventing an indefinite wait, so never skip it.Capability precheck — before the first stop-condition run of a drive (ADR-0016, 2026-08-09). A check whose command cannot execute at all (gh absent, a build tool missing, no permission) fails identically to a check whose code is wrong — so without this gate the drive reads an environment problem as a code problem, spends replan-round on fix-forwards that cannot possibly help, and ends at a no-progress wall that tells the human nothing about the real cause. Gate it before spending, in two layers, and ask the user for nothing (a declared capability list would violate the initial inquiry's lean contract and would duplicate information the check commands already carry):
command -v <name>). Any that do not → halt with wall: blocked-health (<name>) before running a single check.blocked-health only when the command demonstrably never reached the thing under test (executable-not-found, permission denied, and the like). When it is ambiguous, treat it as an ordinary failure. The asymmetry is deliberate: misreading an environment problem as a failure costs a wasted round (today's behavior), while misreading a real failure as an environment problem hides a genuine bug.Like waiting, blocked-health consumes no replan-round and generates no fix-forward — there is nothing in the code to fix. Unlike waiting, it is a wall: it clears only when a human changes the environment (§4).
Two situations produce fix-forward work without a human conversation, both bounded by loop.md, but they use different storage because the active-slot invariant must hold:
verified: failed — in fg-next all this is a hard wall; in fg-loop it is the automated case. The failed task still occupies the only active slot, so repair the same active task in place through fg-run's existing verified: failed branch (apply the bounded fix → fresh run.md → re-verify); do not enqueue a separate backlog plan, which fg-run could not promote while the failed slot is occupied. Before acting, increment replan-round before the repair attempt; if it now exceeds replan-cap, halt. Derive the repair directly from the failing check + its tried:/reflection:, record a synthetic attempt label such as <slug>-repair-rN in that check's tried: ledger, add a marker-only <!-- repaired-by: fg-loop --> comment to the active plan (preserve its slug/task/goal/slices), and route the proposed fix through the same authorized-scope, ADR-conflict, and safety gates below — before applying it, check it against the plan's Related ADRs per PLAN-FORMAT.md's fix-forward ADR rule, and on a conflict halt at fork (ADR conflict — <id>) (§4). PLAN-FORMAT.md's fix-forward eval rule is advisory here, not binding (../fg-run/PLAN-FORMAT.md; ADR 260906-171420 as amended): the rule binds plans that are newly authored, while this path edits an already-run plan under a marker-only, slice-preserving contract — requiring it to add a slice would order it to break that contract. Add the regression check only if it fits inside the bounded repair; otherwise leave it to the retro's eval promotion. Never seal a failed result — ADR-0009 is untouched. (/goal does not stop at verified: failed, so cap/scope/safety must be checked before this in-place repair.)replan-round in loop.md; if it now exceeds replan-cap, halt (wall). Otherwise generate new fix-forward backlog plan(s), one per failing check cluster, strictly inside the authorized replan scope. This path runs only with the active slot empty, so normal plan generation/promotion is valid.Never fix-forward a budget-exhausted halt, and never spend a replan-round on it (ADR-0016, amended 2026-08-19). A spent budget is not a defect in the work — there is no code a fix-forward could change to make it untrue, exactly as with waiting and blocked-health below. It differs from waiting in that it is a wall: the human must decide whether the goal is worth more spend (§4).
Never fix-forward a waiting or blocked-health check (ADR-0016, 2026-08-09). Both paths above act only on a check that is judged failing. A check declared evidence: external that is not passing is waiting (§2) — the drive cannot tell a red result from an unfinished one, so generating a repair would be fixing a problem it has not established exists. A check classified blocked-health is an environment defect, not a code defect. In both cases: no generated plan, no in-place repair, no replan-round spent. waiting ends the turn as a non-wall report; blocked-health halts as a wall. The evidence: external marker is declared during the initial inquiry only — never add or infer it during a drive. A self-declared wait is how an unattended drive would dodge a failure forever, so the declaration is a human decision made before driving, never a runtime one.
Feed Reflexion forward (ADR-0016 2026-06-18, 2nd). Before any fix-forward attempt for a failing check, read that check's tried: labels and reflection: from the ## Check progress ledger first, and make the next approach materially different — seeded by the reflection's "try differently", not a re-run of an already-tried idea. (First failure has no reflection → derive normally.) This applies both to a generated backlog plan and to the verified: failed in-place repair above. If the reflection concludes the real fix needs work outside the authorized replan scope, do not act — surface it as a fork wall early (§4), before burning the cap on in-scope variations that can't succeed.
Reflexion (ADR-0016, 2026-06-18, 2nd). When a fix-forward attempt leaves a check still failing, also write a one-line reflection: under that check — verbalize why the last approach didn't move the evidence and what to try differently next (not a restatement of the failure; a changed direction). This is the working memory that makes the next fix-forward actually different rather than a re-run of the same idea (the Feed Reflexion forward rule above reads it). It is drive-local volatile state — it lives in loop.md, is consumed during the drive, and dies when loop.md is deleted at goal-met; it is not a retro (permanent learning still promotes via the seal's retro → human fg-learn, ADR-0010). First failure of a check has no reflection yet — write one only once there is a tried attempt to reflect on.
Tension wall — fix-forwards trading one check for another (ADR-0016 2026-06-25; scope corrected 2026-06-25, 2nd). Tension is strictly a fix-forward phenomenon: it counts only regressions attributable to fix-forward work (regressed: ×N, which §2 increments only for generated-by: fg-loop plans or repaired-by: fg-loop in-place repairs). A regression from a human-grilled member task during backlog drain is not tension — it is normal multi-task interference, and the drive keeps going (the remaining backlog / eventual fix-forward addresses the now-failing check). When a fix-forward for one check regresses another: lenient + one retry — on the first fix-forward-induced regression, generate the next fix-forward with a hard constraint to satisfy BOTH the target check and the regressed check (fed forward alongside Reflexion, not instead of it). If it regresses again — the same check's regressed: ×N reaches ×2, or two distinct checks have each been regressed by fix-forwards at least once (a ping-pong) — the checks are in genuine tension that in-scope fix-forwards can't reconcile: halt with wall: tension (Cx↔Cy), report the conflicting pair and their last-evidence, and hand the tradeoff to the human. This fires before cap exhaustion, so the human reads "C1↔C2 conflict" instead of a blunt "cap-exhausted". Detection is mechanical (the ledger's fix-forward-attributed pass→fail flip) — unlike the safety gate below, no judgment is involved.
Every generated backlog plan (the active-slot-empty case) is a normal plan: PLAN-FORMAT, forge-slug, next monotonic task: number (ADR-0005), plus a <!-- generated-by: fg-loop --> marker so fg-status and the audit trail show its origin (fg-status renders it as a (loop) origin tag) — and it follows PLAN-FORMAT.md's fix-forward eval rule (persistent regression-check slice + red → green DoD when the failing check is mechanically checkable, a one-line reason when not, plus the <!-- eval: … --> marker that names the regression-check slice or the exemption reason (PLAN-FORMAT.md; checked by forge-plan-lint); ADR 260906-171420) and its fix-forward ADR rule (Related ADRs from the header triage; a fix that would contradict an accepted ADR is not generated — §4's fork wall; like the safety gate below, this check binds every fix-forward attempt, the verified: failed in-place repair included) — and append its slug to loop.md's ## Tasks section at generation time (membership — declared in INQUIRY.md, filtered in §2). The verified: failed path is the explicit exception: it repairs the already-member active task, records an attempt label in the ledger, and adds only the repaired-by: fg-loop provenance marker, so it creates no second task/slug. Work outside the authorized scope is neither generated nor repaired — that is a wall (genuine fork), not a judgment call to make alone.
Safety wall — in-scope but irreversible (ADR-0016 2026-06-25; made universal 2026-06-25, 2nd). This gate is a mandatory precondition for every fix-forward attempt — a generated backlog plan and a verified: failed in-place repair alike (no path skips it). Even within the authorized scope, before applying the attempt, classify its slices/actions against the always-halt action classes in loop.md's Authorized replan scope (declared in INQUIRY.md — the default 7-class set, override/extend per loop). If any would take such an action — prod data mutation/deletion · deploy/release/publish · outbound external comms · irreversible VCS/file destruction · financial/payment · secret/permission change · privacy-data exposure — do not auto-generate or repair: halt with wall: safety (<class>) and hand the one-way door to the human. This is distinct from the fork wall: out-of-scope work is a fork, but an in-scope yet destructive action still halts (the gap the harness permission gate misses under broad permissions). Honest limit: this is a best-effort self-classification by the model, not a guaranteed interception (a Markdown plugin has no static analyzer to enforce it) — its value is that the halt is named in the contract and the /goal stop-allowed set, so the drive has an explicit instruction to stop rather than none.
No-progress early abort: use the persisted ## Check progress count (×N ≥ 2) under §2's ledger rule: consecutive failing observations with unchanged evidence, including explicit rechecks across resumes. A skipped preflight check is not an observation. This count is not the number of repairs: report tried: separately and never claim two attempted fixes when none ran. At the threshold, halt automatic repair and report the evidence, attempts, and any reflection. If an unresolved fork or safety decision already blocks the same check, retain that actionable wall cause while reporting the updated no-progress count; changing its label does not resolve it.
Resolution permits one new attempt, not a counter reset. If an explicit scope or approach decision enables a concrete repair not previously attempted, record that decision and proposed approach in the existing ledger and permit that single bounded attempt despite a retained ×N ≥ 2. This includes a first repair previously blocked by a fork when tried: is empty. Apply all other gates normally. Record consumption of the decision with the attempt's tried: label before executing it, so a later resume cannot reuse it. If verification leaves the evidence unchanged, increment the count and halt at no-progress; a repeated "continue" does not authorize another attempt. Evidence changes use §2's normal counter update rule.
Halt the drive, report where/why/how-to-resume (in the user's language), at any of:
pending); never seal unverified (ADR-0009).fork (ADR conflict — <id>), PLAN-FORMAT.md's fix-forward ADR rule). Consequential branches are the human's. A plan that forge-plan-lint (scripts/forge-plan-lint.sh, run by fg-run before launch) rejects also halts here as fork (plan-lint — <codes>) — except a plan fg-loop itself generated, which it may correct once and re-lint before halting (it authored that file; a human-grilled member plan is never rewritten by the drive).replan-round > replan-cap).always-halt action class (irreversible/destructive/external; the class set in loop.md's Authorized replan scope). Hand the one-way door to the human. Best-effort self-classification, not a guaranteed gate.evidence: external check has been waiting ×2 with unchanged evidence. The external evidence is not arriving; the human decides whether to wait longer, fix the upstream, or drop the check.budget-tokens ceiling is reached (post-hoc) or the remaining budget is below the observed per-task average (pre-flight). Consumes no replan-round and generates no fix-forward (§3): nothing in the code is wrong, the drive simply ran out of the resource it was authorized to spend. Its clear semantics differ from every other wall and must not be "simplified": resume preflight retains the wall until an authorized ceiling increase permits another checkpoint; a bare re-trigger neither resets the wall nor reruns the same exhausted-budget path. The only exit is the human raising budget-tokens — and budget-spent is not reset, exactly as cap-exhausted is resolved by raising replan-cap while replan-round keeps its count. Resetting the accumulator instead would silently discard the drive's cumulative total, which is the one number the ceiling exists to bound.running.md belongs to the active task, but the host's blocking-collect cannot identify or collect one or more recorded handles; this includes workflow: pending, an unavailable same-session handle, a collection error, and work that may still be running in another session. The drive cannot answer fg-run's required confirmation for the human. Set wall: fork (unknown or uncollectable in-flight execution), delete drive.md, and stop.waiting is NOT in this list, and that is the point. A check merely waiting on external evidence asks nothing of the human — no judgment, no action — so reporting it as a wall would recreate exactly the misclassification this state was added to remove (§2). It ends the turn as a non-wall report with wall: at none (§2 — never a leftover cause from an earlier halt), and resumes on the next trigger. It becomes a wall only by stalling (#7 above). Walls #7 and #8 are, like tension and safety, fg-loop-exclusive — they arise from the evidence: external declaration and the capability precheck, neither of which exists in fg-next all, so its wall set is unchanged.
Wall #9 is fg-loop-only for a DIFFERENT reason, and the difference matters (ADR-0016, amended 2026-08-19). Tension, safety, stalled-waiting, and blocked-health cannot occur in fg-next all — it generates no fix-forwards and makes no external/capability declarations. A budget overrun can occur there: it drives unattended and burns the same workflows. budget-exhausted is confined here only because the ceiling lives in loop.md and fg-next all has no contract file to hold one. That is a scope decision, not a structural impossibility — do not cite the sentence above as though it covered this case. The identical exposure remains in fg-next all, deliberately, as separate follow-up work.
On a wall, set loop.md's wall: field to the precise cause, then delete drive.md before stopping — persisting the reason before releasing the Stop hook avoids an unrecorded-wall crash window. fork (<reason>) also carries a refused per-task commit, e.g. fork (commit rejected — pre-commit hook), when driveCommit is on (../fg-next/DRIVE.md Part 3), an unknown or uncollectable running.md, e.g. fork (unknown or uncollectable in-flight execution), and a fix-forward that would contradict an accepted ADR, e.g. fork (ADR conflict — <id>); no separate wall token is minted for any of them — (no-progress (C1) / cap-exhausted / unverifiable-uat (C2) / fork (<reason>) / tension (Cx↔Cy) / safety (<class>) / stalled-waiting (C2) / blocked-health (<capability>) / budget-exhausted) so fg-status and the resume report why it stopped — never a bare "resume fg-loop". loop.md stays on disk (fg-status reports it); the human resolves the wall — possibly re-grilling via fg-ask or widening the scope/cap by editing the inquiry's answers in a short conversation — then fg-loop records that decision and resumes in the same conversation; a later invocation uses the resume preflight rather than treating the trigger as resolution. On goal-met termination — every check passes and no member is left unrun, stale generated members having been discarded (§2) — the handoff's measurements (sealed member done/ paths · auto retro count) are read from loop.md's ## Tasks first, then loop.md is deleted and a final summary is the handoff (statement form — the next step is the user checking the result themselves; fg-learn is only an optional note below the table when members have auto retro logs, per ADR-0010's deferred-promotion model — see Handoff).
fg-loop
│
▼
loop.md exists? ── yes ──▶ resume preflight ── unresolved ──▶ retain wall, request missing decision/evidence
│ └─ resolution established / no wall ──▶ drive
│ no
▼
Initial inquiry (conversation): machine-verifiable checks + replan scope + cap → loop.md, initial plans → backlog/
│
▼
capability precheck: every check command's executable resolves? ── no ─▶ WALL: blocked-health (<name>)
│ yes
▼
DRIVE one task loop at a time:
select next member ─▶ invoke fg-run with its task#/slug (fg-run promotes) ─▶ run ─▶ UAT
│
├─ verified: sealable ─▶ seal (fg-done, unattended retro judgment) ─▶ forge-loop-spend (ONE call per boundary)
│ │ exit 3|4 ─▶ WALL: budget-exhausted
│ │ exit 5 ─▶ WALL: blocked-health (unmeasurable ceiling)
│ │ exit 0 ─▶ run stop-condition checks (below)
│
└─ verified: failed ─▶ replan-round +1 ≤ cap? ── no ─▶ WALL: cap
│ yes
▼
scope + ADR + safety pass? ── no ─▶ WALL: fork / safety
│ yes
▼
mark repaired-by ─▶ in-place fix (fresh run.md) ─▶ back to UAT (re-verify the SAME task, then seal)
run stop-condition checks (top to bottom, first match wins):
a check failed because its command could not execute ─▶ WALL: blocked-health (<name>)
all checks pass + an unrun member is generated-by: fg-loop ─▶ delete those plans, drop their slugs from ## Tasks,
record them on the ledger's discarded: line ─▶ fall through (no generated plan runs after all-pass)
backlog has member tasks (even if all checks pass) ─▶ select next member (continue the drive)
(the boundary meter above already gave exits 3|4|5)
all checks pass (no member left in backlog) ─▶ measure from loop.md (sealed member done/ paths, auto retro count)
─▶ report summary ─▶ DELETE loop.md ─▶ stop (goal met)
backlog empty + only evidence:external checks non-passing ─▶ waiting ×N +1 (no round spent, no fix-forward)
│ ×N ≥ 2 and evidence unchanged ─▶ WALL: stalled-waiting (Cx)
│ otherwise ─▶ end turn as NON-wall report (resume on next trigger)
backlog empty + checks failing ─▶ replan-round +1 ≤ cap? ── no ─▶ WALL: cap
│ yes
▼
scope + ADR + safety pass? ── no ─▶ WALL: fork / safety
│ yes
▼
generate backlog plan(s) ─▶ select next member (continue the drive)
(walls anywhere: unverifiable UAT · genuine fork / out-of-scope fix · unknown/uncollectable running.md · cap exhausted · no progress ×2 · tension (regression ping-pong) · safety (irreversible action) · stalled waiting ×2 · blocked health (uncallable check command, or an unmeasurable ceiling) · budget exhausted (token ceiling reached or predicted))
(waiting on external evidence is NOT a wall — it ends the turn asking nothing of the human)
/goalAt runnable drive entry, use DRIVE.md Part 2 to select the host-supported continuation mechanism. Present a /goal line only when that fallback is applicable and not already active or explained in this conversation. Do not present it while a wall remains unresolved: continuation does not grant scope or waive a check. Without a live continuation mechanism, say once that execution is turn-bounded; keep going as far as the turn allows.
Cross-turn continuation and its conditional /goal fallback are defined in DRIVE.md Part 2. Use the fallback only at runnable drive entry, as specified immediately below. Enumerate the stop-allowed points from THIS loop's walls, not fg-next's: goal-met (all checks pass and no ## Tasks member is left unrun in backlog/) · unverifiable UAT (pending) · genuine fork / out-of-scope fix · an unknown or uncollectable running.md (fg-run 4a case 3) · replan cap exhausted · no progress ×2 · tension (regression ping-pong) · safety (irreversible action class) · stalled waiting ×2 · blocked health (a check command cannot execute, or a declared ceiling cannot be measured) · budget exhausted (the budget-tokens ceiling is reached, or the pre-flight estimate cannot cover another task) · a workflow script approval (human input is physically required). Also list plain waiting as a stop point even though it is not a wall — the drive genuinely cannot proceed until external evidence lands, so a /goal that refused to stop there would spin. Do not list verified: failed as a stop point — in fg-loop it is the automated fix-forward case (§3), and a /goal that halts on it would undo exactly the wall-relaxation this skill exists for. Recommended paste-ready shape (render in the user's language):
"Keep driving fg-loop. Stopping is allowed only at: (1) goal-met — every stop-condition check passes and no loop member plan is left unrun in the backlog; (2) a wall — unverifiable UAT, a genuine fork or out-of-scope fix, an unknown or uncollectable in-flight execution, replan cap exhausted, no progress ×2, tension (checks ping-pong), a safety/irreversible action, stalled waiting ×2, budget exhausted, or a check command that cannot execute (blocked health); (3) waiting on external evidence that has not arrived; or (4) a workflow script approval. On
verified: failed, do not stop — continue with fix-forward."
fg-next all drains the human-grilled backlog and halts at empty state and at verified: failed; it never creates work. fg-loop is the goal-converging superset: it re-checks a goal at empty state and may generate bounded fix-forward work, and failed is its automated case. The tension and safety walls (§3 and this section) are fg-loop-exclusive — both arise only from generated fix-forwards, which fg-next all never produces, so they do not ripple into fg-next's wall set (the two lanes share only the /goal mechanism, not this wall pair).fg-next seal with a human present, so fg-done may ask its one promotion question; fg-loop seals unattended — fg-done's retro judgment skips the retro or writes an auto retro log, and promotions wait for a human in fg-learn's batch promotion. The optional adversarial review (fg-adversarial-review, ADR-0018) is likewise never run in the drive — it needs a human to judge which findings are real and worth fixing.Where this sits in "loop engineering" terms (maker/checker · deployment levels). This lane is the "recursive goal" of loop engineering — define a purpose; the AI iterates with sub-agents, verification, and external state until the goal is met or it hands off to you — pinned stricter: "the AI thinks it's done" is never a stop condition here, only the recorded machine-verifiable checks. The maker/checker split maps cleanly: fg-run's workflow sub-agents are the maker; the per-task UAT is a self-administered checker, but the machine-verifiable stop-condition checks are the independent, objective checker — a grep/test/build outcome is not subject to maker bias, so an over-optimistic UAT is caught when a stop check still fails and triggers a fix-forward (§3). That is why no separate verifier sub-agent runs in the drive: the mechanical checks already gate, and a redundant verifier would add complexity without closing a real hole. The three forge lanes are the L1→L2→L3 rollout (report → assisted → unattended) — fg-status (L1, observe) · fg-next (L2, assisted) · fg-loop / fg-next all (L3, unattended) — and loop.md's Check-progress ledger + Reflexion is the durable memory/state spine that survives a stateless resume.
During the drive, no delegated table reaches the user — fg-loop suppresses it. fg-run/fg-done cannot detect their caller, so instruct every step you invoke not to render its handoff table; fg-loop renders exactly one, here, for its own terminal step (the wall, or goal-met). This is the same active suppression the drive already applies to the delegated seal summary (DRIVE.md Part 1, ADR-0032), for the same reason: relaying a delegated Next step row while the drive is already taking that step is the "keeps telling me to run it, never seals" stall, and a table reads as an instruction, so relaying one is worse than relaying the prose was.
The terminal report is the handoff, rendered as the handoff table per ../fg-next/HANDOFF.md — the single definition of its shape; never restate that layout here. Statement form — no "shall I continue?" (ADR-0015).
Fill it from loop.md, never from memory:
loop.md's ## Tasks before deleting it (the membership dies with the file), under the resolved forge root: sealed member done/ paths — for each member slug, the done/*/ folder whose plan.md carries that exact forge-slug marker (match the marker, not the folder-name suffix: *-cache-fix would also catch docs-cache-fix); a member slug with no matching done/*/plan.md gets no path — leave it out of How to start and name it below the table as having no sealed archive, never construct a path for it; auto retro count — how many of those sealed members are auto-retro candidates by fg-learn's rule (../fg-learn/SKILL.md, "Auto retros not yet reviewed"): read the folder's STATUS.md retro: field and count it only when it names a file whose first line is the <!-- auto-retro: … --> marker (a skipped (…) value never counts). Just did = tasks sealed · rounds used · all checks passing (the per-check evidence itself is list-shaped and goes below the table — see below) · loop.md deleted (the loop is closed); Next step = the user checks the result themselves along its real usage path — §2 declares goal-met only once no member is left unrun, so nothing remains to run or seal; How to start = when .claude/skills/verify-<app>/ exists (fg-verify), verify-<app> and the feature-map entries the sealed plans' DoD named, otherwise those DoDs (<done path>/plan.md from the measurement) — one line; Alternative = start a fix task with fg-ask (/forge:fg-ask). fg-learn is never a cell here: a deferred promotion is optional, and presenting it as the next step reads as an error the loop left behind.Just did = the precise saved wall and round N/cap; Next step = the concrete decision or evidence still missing; How to start = supply that decision/evidence in this conversation (name it, not a bare /forge:fg-loop); Alternative = fg-ask only when the goal/checks need redesign. If a decision is already unambiguous, apply the resume preflight and continue instead of emitting another handoff. Do not offer baseline exceptions as equivalent to preserving the original checks: changing a check requires an explicit, faithful goal decision and never waives failed task verification.The evidence is list-shaped, so it goes below the table as bullets (HANDOFF.md, "List-shaped content goes below the table", which names fg-loop for exactly this). Both termini emit it — which lines depends on the terminus:
×N, regressed: ×N, last-evidence, and reflection:, plus the tried: slugs. That detail is why the wall happened — it must not be compressed into a cell, and it must not be dropped.Just did says the drive is waiting on external evidence and that nothing is owed by the human; Next step is re-triggering fg-loop once the evidence has landed; How to start = /forge:fg-loop. Below it, one line per waiting check with its waiting ×N and last-evidence. Do not phrase this as a wall or as a problem to resolve — that misclassification is what §2's waiting state exists to remove.budget-spent · budget-tokens · the pre-flight avg/remaining when that was the trigger, plus how many member tasks were sealed for that spend. Say plainly that no check is broken and nothing needs fixing — the drive spent its authorized budget — so the decision is whether the goal is worth raising budget-tokens for. Do not render failing-check lines here; there may be none.last-evidence — the stop checks' passing evidence, the command output actually observed, which the ledger records for passing checks too (§2); it shows the checks passed, not how to use the result. Read it out of loop.md and render it before deleting the file (§2's goal-met order is measure and report, then delete): the deletion destroys the ledger, so evidence never shown is evidence no longer recoverable, and an unverifiable "done" is precisely what this lane forbids — only the recorded machine-verifiable checks may stop it, never "the AI thinks it's done" (ADR-0016). Close with one line only when the auto retro count is above zero: that count and an optional batch promotion with fg-learn (/forge:fg-learn). At zero — e.g. every seal recorded retro: skipped (judged: …) — do not mention fg-learn. Also below the table, and only here (never repeated in Just did): one line with the count and slugs from the ledger's discarded: line when §2 discarded stale generated members, and one line naming each member slug the measurement found no sealed archive for. Omit either line when it would be empty..forge/loop.md — the goal contract (volatile, owned by fg-loop; deleted on goal-met termination, kept on a wall and on a waiting turn-end). The waiting ×N state and the optional evidence: external declaration live inside existing sections (the check list and the Check-progress ledger) — no new top-level field was added. The spend ceiling did add two top-level fields, budget-tokens and budget-spent · since:, because spend is a drive-level quantity with no per-check home (rationale in INQUIRY.md) — budget-spent/since are written by the forge-loop-spend twin, not by this prose..forge/backlog/*.md plans — at the initial inquiry and as <!-- generated-by: fg-loop --> fix-forward plans during the active-slot-empty replan case.<!-- generated-by: fg-loop --> backlog plans it created, once every check passes (§2) — removing their slugs from ## Tasks and recording them on the ledger's discarded: line. Human-grilled plans are never deleted.verified: failed repair, adds only <!-- repaired-by: fg-loop --> to the active plan for provenance/tension attribution; it preserves the plan's slug, task number, goal, and slices.retro: skipped line, or an auto retro log with the unreviewed note).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
goal-loop, bounded-replan, unattended-drive, task-automation
npx claudepluginhub gyuha/forge --plugin forge25 skills in this plugin
/fg-adversarial-reviewOptional adversarial review between fg-run and the seal (fg-done) — a reviewer assumes the result is WRONG and hunts for evidence across six lenses (failure points, hidden assumptions, misread requirements, security/perf/data-loss, unexpected misuse, weak decisions), fanning out as parallel subagents; fix-needed findings become a fix-forward plan on your approval. Outside the loop, never a seal gate, always skipped in fg-next all / fg-loop. Use in contexts like 'adversarial review', '적대적 리뷰', '이 결과 공격적으로 검토', '허점 찾아줘', 'red team this'./fg-agendaA decision queue for foggy work — outside the forge loop. Settles the destination with you, grills breadth-first to surface what must be decided, and keeps it in .forge/agenda.md (destination · decided · open questions · fog · out of scope), resolving one question at a time via fg-ask until the way is clear, then deleting itself. The agent finds the decisions; you answer them. Use in contexts like 'forge agenda', '의제', '결정 대기열', '뭘 결정해야 하는지 정리해줘', '어디서 시작할지 모르겠다'.Other plugins' skills for the same job
/fg-agentsGenerates a project's domain agents — conversational grilling derives the recurring roles, then writes standard Claude Code subagent cards to .claude/agents/<role>.md (each `description` carrying a "when to use" so fg-run can dispatch a matching role as agentType). Cards load only at session start, so RESTART the session after generating them before fg-run can use them. On-demand utility outside the loop. Use in contexts like 'forge agents', '도메인 에이전트 만들어', '에이전트 팀 구성', 'create project agents', 'domain agents', 'agent roles'.