Loop Engineering tutorial

Design a loop that finds the work, hands it to an agent, checks it, records it and knows when to stop. You stay the engineer who gives the verdict.

Start the course

Course contents

First Loop

  1. From Prompting to Loops — Stop being the person who types every prompt. See the reason, act, observe cycle of one agent, then put a loop around it with four parts: a trigger, an agent, a verifier and a stop rule.
  2. State — The loop's memory outside the conversation. Watch a loop with no state file do the same ticket twice, then give it a state.md file that it reads first and writes last.
  3. Maker vs Checker — The writer never grades itself. Watch a self-graded loop approve four broken fixes, then add a checker subagent with its own rubric that runs the tests.
  4. Stop Rules — Goal conditions, iteration caps and no-progress detection. Watch a runaway loop burn its budget on a flaky test, then write the three rules that make every loop end.
  5. Triggers — Goal loops vs cadence loops, hooks and CI. Watch a goal loop miss the failures that arrive tomorrow, then turn it into a daily triage loop that stays quiet on empty days.
  6. Skills Inside the Loop — Plus your v1 export. Move 300 pasted lines of instructions into a triage skill, watch the tokens per turn drop by more than half, then export your first loop pack for Claude Code, Codex or Cursor.

Loops at Scale

  1. Worktrees and Parallel Loops — Two agents edit the same file at the same time and one fix is lost. Give each agent its own worktree, land the lanes through a merge queue, and see why your review time is the real limit.
  2. Connectors — The loop acts on real tools. A loop that only says "here is the fix" changes nothing. Attach a tracker, CI and chat, and make it open a PR, link the ticket, and post only after CI is green.
  3. Cost, Rate and Blast-Radius Budgets — Watch a loop spend a whole day's tokens on one flaky test and run a command on production. Set per-run and per-day token budgets, a rate limit, and the paths and commands the loop may touch.
  4. The Outer Loop — Triage inbox, escalation and human review. Unclear and unsafe tickets must land in the inbox, not get "fixed". Then you read the evidence and give the verdict.
  5. Capstone — Loop pack for your project, plus export. Build one loop with every part of the course, run it on the full 20-ticket backlog, then export it for Claude Code, Codex or Cursor.

Reference

  1. Cheat Sheet — One page to come back to: the four parts, a full loop.yaml template, loop commands in Claude Code, Codex and Cursor, state, skill and checker templates, stop rules, budgets, an emergency stop, rollback, security for untrusted tickets, loop health numbers and an error index for every linter and lab message.