loop

Executes gated brainstorm-plan-build-review-improve cycles with durable resumable state and stop conditions.

Updated May 31, 2026
One-click install
npx skills add https://github.com/AlexanderNarbaev/agi --skill loop-alexandernarbaev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: loop
Source: https://github.com/AlexanderNarbaev/agi/tree/main/.opencode/skills/loop
Command: npx skills add https://github.com/AlexanderNarbaev/agi --skill loop-alexandernarbaev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Running a multi-phase engineering objective end to end often loses state on interruption, lets the same context that wrote code approve it, and loops without clear stop criteria. This Skill enforces a gated, resumable, compounding loop with independent review and explicit stop conditions. ## Core Features & Use Cases - Gated five-phase cycle: Runs BRAINSTORM → PLAN → BUILD → REVIEW → IMPROVE with entry and exit gates backed by concrete evidence, delegating to existing mode skills like plan, execute, critic-gate, and phase-wrap. - Generator/verifier separation: Independent reviewer and critic contexts approve the actual diff; any post-approval edit invalidates the approval and triggers re-review. - Durable resumable state: Loop control state persists under .swarm/loop/<run-id>/state.json with validation, retention pruning, and resume support, so interrupted runs continue without losing work. - Defense-in-depth stop conditions: Stops on objective met, cycle budget, plateau, oscillation, unrecoverable error, or explicit user request, and captures learnings so each cycle compounds. - Use Case: Ask the agent to add rate limiting to a public API with max 3 cycles in checkpoint mode; the loop writes a spec, plans, implements, independently reviews the diff, captures learnings, and stops when the success criteria pass. ## Quick Start Run the loop mode with an objective like "add rate limiting to the public API" and let it iterate through gated cycles until the success criteria are met or a stop condition fires.

Frequently Asked Questions about loop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a multi-cycle engineering task with gated review phases?

Invoke MODE: LOOP with an objective, max_cycles (1-5, default 3), and autonomy level. The loop runs brainstorm, plan, build, review, and improve phases, pausing at each gate in checkpoint mode or proceeding automatically in auto mode while still enforcing all hard stops.

What is the difference between checkpoint and auto autonomy modes?

Checkpoint mode pauses at every phase gate and before each new cycle for explicit user approval. Auto mode proceeds without prompting but still enforces mandatory review and critic gates plus all hard stop conditions; it reduces prompts, never verification.

Can a loop run resume after the session is interrupted?

Yes. Loop control state persists in .swarm/loop/<run-id>/state.json with cycle, phase, and gate outcomes. Resuming validates required fields, prints a progress summary, and continues from the recorded phase; corrupted state stops with a clear error.

Why does the loop require a separate reviewer and critic for code changes?

The coder context that writes a change must never be the only context approving it. An independent reviewer examines the actual diff for bugs and regressions, a separate critic challenges weak evidence, and any edit after approval invalidates that approval.

When does the loop stop iterating?

The loop stops when the objective's success criteria are met, the cycle budget is exhausted, a cycle produces no qualifying progress, a prior change is reverted (oscillation), an unrecoverable error occurs, or the user explicitly stops it.