Loop Engineering Guides
Practical guides on Loop Engineering: what it is, how to build a first loop, how to use checkers, how to validate each run, and how to keep repeated agent work safe and budget-aware.
Loop Engineering is the practice of designing a controlled outer cycle around model-driven work. The cycle gives an AI agent a clear goal, bounded context, independent evidence, a budget, durable memory, and explicit decisions to stop, retry, or escalate, so repeated work remains verifiable, reviewable, and under human control.
Start with one small loop you can personally review. Pick one discovery source, one outcome, one validation step, one checker, one stop rule, and one place to save the run note.
Use this four-part design loop before you automate: state the hypothesis, run the smallest useful version, collect validation evidence, then decide what to change before the next pass.
Waterfall engineering asks you to design the full workflow before feedback. Loop Engineering asks you to run a small, bounded cycle, verify the result, and let evidence shape the next cycle.
A methodology skill packages a human method into repeatable agent instructions: when to use it, when not to use it, the steps to follow, and the quality checks that keep the output honest.
Validation is not just running a command. A good loop records the expected evidence, the actual evidence, whether the hypothesis passed, what failed, and what should change before the next run.
Token-rich loops pass large context into every iteration. Token-poor loops pass summaries, retrieved memory, or scoped observations to reduce cost.
Safe loops define hard stop rules before execution: max iterations, budget caps, repeated failure limits, and human approval gates.
When a validation metric becomes the target, an agent may optimize the metric instead of the real goal. Good loop design adds boundaries against shortcuts.
Closed loops have clear validation and stop rules. Open loops explore uncertain tasks and need stronger human supervision.
Long-running loops need memory strategy: what to keep, what to summarize, what to retrieve, and what to forget.
Context Engineering focuses on what information an agent receives. Loop Engineering focuses on how the agent iterates, validates, stops, and reports.
An agent harness is the system that validates, authorizes, executes, records, and returns observations for the actions a model proposes. Loop engineering decides how that harness iterates: the goal, validation, stop rule, budget, and feedback.
Worktree orchestrators run several coding agents at once, each in an isolated git worktree, so parallel work does not collide. They differ in supported agents, diff/review UX, merge flow, and license.
Both keep an agent working toward a goal with validation and a stop condition. Claude Code /goal frames a single goal with explicit boundaries and a max-iteration line; Codex /goal frames an objective with a “Done when” block and explicit stop conditions. The structure differs more than the intent.
AGENTS.md holds durable project rules and validation commands. SKILL.md packages a reusable workflow with triggers and steps. RALPH.md is an experimental loop definition for Ralphify-style runtimes. They are complementary, not competing.
continuous-claude runs an autonomous agent loop with cost, time, and iteration caps. A GitHub Actions workflow runs your validation on a schedule or trigger but does not run an autonomous agent. Use Actions to validate; use continuous-claude (with caps and human approval) to iterate.
All three keep a Claude Code session running between prompts. /goal starts the next turn when the previous finishes and stops when a fast model confirms your condition is met. /loop re-runs on a time interval. A Stop hook fires after every turn and stops when your own script or prompt decides.