|
| 1 | +--- |
| 2 | +title: "What is loop engineering" |
| 3 | +description: "Designing the system that prompts an agent — and where loop.js fits in the practice" |
| 4 | +--- |
| 5 | + |
| 6 | +**Loop engineering** is the practice of designing the system that prompts an AI agent — |
| 7 | +instead of prompting it turn by turn. You define a goal, a way for the agent to find and do |
| 8 | +work, a way to verify the result, and a stop condition; the loop does the iterating. The |
| 9 | +term spread in mid-2026, after Claude Code's creator described his own workflow as "loops |
| 10 | +that prompt Claude" — by then coding agents were reliable enough at long-horizon work that |
| 11 | +the scarce skill had moved from writing prompts to designing the system that writes them. |
| 12 | + |
| 13 | +## The elements of a loop |
| 14 | + |
| 15 | +Every serious agent loop answers five questions: |
| 16 | + |
| 17 | +| Question | loop.js answer | |
| 18 | +| --------------------- | --------------------------------------------------------------------- | |
| 19 | +| What is the work? | a **Goal** — set once, judged every Round | |
| 20 | +| How does it iterate? | **Rounds** — each starts with fresh context and reads memory from disk | |
| 21 | +| Who says it's done? | a separate, skeptical **Verify** agent — never the worker itself | |
| 22 | +| When does it stop? | when the Loop **settles** (bar met, or judged impossible) — limits are guards, never goals | |
| 23 | +| What re-triggers it? | any real scheduler — `loop cron` installs Entries into crontab, launchd, Task Scheduler, or Modal | |
| 24 | + |
| 25 | +## Where loop.js stands in the practice |
| 26 | + |
| 27 | +The simplest loops — shell scripts and minimal runners in the |
| 28 | +[ralph-loop](https://ralphloops.io/) tradition — re-prompt an agent with fresh context until |
| 29 | +a script check passes or a human stops it. That shape is powerful, and loop.js keeps its |
| 30 | +core insight (fresh context per iteration, state on disk). What loop.js adds is the |
| 31 | +**verdict**: |
| 32 | + |
| 33 | +- **Writer ≠ grader.** A self-grading agent passes its own work; the better the model, the |
| 34 | + more confidently it does so. Verify runs as a separate agent, read-only by permission — |
| 35 | + not by prompt discipline. |
| 36 | +- **Digest-first, escalate when suspicious.** The judge reads the worker's handoff digest |
| 37 | + and can escalate — inspect the work tree, run the build, read the transcript — instead of |
| 38 | + rubber-stamping a summary. |
| 39 | +- **A "not yet" must say why.** The verdict's `reason` is mandatory and feeds the next |
| 40 | + Round, so iteration converges instead of retrying blind. |
| 41 | +- **Impossible is an answer.** A Goal that can never pass settles as a give-up instead of |
| 42 | + burning budget to the cap. |
| 43 | +- **Guards, declared.** Rounds, dollars, and per-Round wall clock bound the loop; a |
| 44 | + schedule Entry declares its own lifetime (`--until settled | forever`, capped). |
| 45 | + |
| 46 | +## Try it |
| 47 | + |
| 48 | +```sh |
| 49 | +npm create @loop.js@latest my-loop |
| 50 | +cd my-loop && npm install |
| 51 | +loop run |
| 52 | +``` |
| 53 | + |
| 54 | +<Card title="Quickstart" icon="rocket" href="/quickstart"> |
| 55 | + From empty directory to a settled Goal. |
| 56 | +</Card> |
0 commit comments