Sandbox
@invincible04/awesome-loop-engineering

Loop engineering chapters, prompts, and skill for agent workflows

This repo explains loop engineering in plain language and shows how to build it for your own workflow. It combines long-form docs, an annotated source list, reusable prompt files, a portable skill, and a runnable Python example.

57 stars6 forksHTMLUpdated 2mo ago
Who it's for

Builders who want to design loops that prompt, verify, and re-run their coding agents.

What it delivers

You can stop hand-cranking the same prompts and set up a loop that discovers work, checks results, and keeps going on its own.

What it does

Loop engineering chapters

`docs/` contains 13 chapters covering the idea, lineage, loop anatomy, stop conditions, memory, risks, security, and evaluation.

Copy-paste prompts

`prompts/` includes ready-made prompts for `/goal`, `/loop`, automations, maker/checker sub-agents, verification rubrics, and loop contracts.

Portable agent skill

`skill/loop-engineering/` is a skill that interviews you about your workflow and scaffolds a loop contract and files for it.

Runnable Python example

`examples/runnable/` shows the loop machinery in code, including engine, budget, memory, verifier, and stop conditions.

Annotated reading list

`reading-list.md` gathers the source material behind loop engineering with notes and context.

How to get it

  1. 1Install it with one command — it asks which agent you use and where to put it
    npx github:invincible04/awesome-loop-engineering
  2. 2Or copy the folder yourself (a skill is just a folder with a SKILL.md)
    cp -r skill/loop-engineering .claude/skills/loop-engineering   # Claude Code
    cp -r skill/loop-engineering .opencode/skills/loop-engineering  # OpenCode
  3. 3examples/runnable/ is a dependency-free Python implementation of the loop machinery —…
    cd examples/runnable
    python -m loop_cookbook                    # watch a maker/checker loop converge and stop
    python -m unittest discover -s tests -v    # 10 tests, standard library only

README

Loop Engineering: build the loop that prompts your agents

Awesome Loop Engineering

Learn loop engineering: the practice of designing systems that prompt, check,
remember, and re-run AI coding agents for you, instead of prompting them by hand, turn after turn.

MIT License Read it online Agent skill included PRs welcome Awesome

Website  ·  Learn  ·  Prompts  ·  Build your own loop  ·  Cheat sheet


This is a teaching repo, not a link dump. It has four parts:

  1. Learn — in-depth, plain-language chapters that explain loop engineering from first principles.
  2. Read — a large, annotated reading list (~100 sources): the essays that named the field, the papers it stands on, the evals/observability canon, the talks, and the skeptics.
  3. Practice — a library of real, copy-paste loop prompts (Ralph loops, /goal and /loop commands, Codex automations, maker/checker sub-agents, verifier rubrics, and full loop contracts).
  4. Build — a portable agent skill that walks you through designing and scaffolding a loop for your own workflow, plus a small runnable example in plain Python.

Fast paths:


What is loop engineering, in one paragraph

For two years, getting work out of a coding agent meant writing a prompt, reading the reply, and typing the next prompt — you held the tool the whole time. Loop engineering replaces you as the thing that prompts the agent. You build a small system that discovers work, hands it to an agent, checks the result with a separate verifier, writes down what's done, decides what's next, and re-runs on a schedule. As Addy Osmani put it in the essay that named the field (June 2026): "Build the loop. But build it like someone who intends to stay the engineer, not just the person who presses go."

The two quotes that kicked it off:

"You shouldn't be prompting coding agents anymore. You should be designing loops that prompt your agents." — Peter Steinberger

"I don't prompt Claude anymore. I have loops running. They're the ones prompting Claude and figuring out what to do. My job is to write loops." — Boris Cherny, creator of Claude Code

Who this is for

  • You use a coding agent daily (Claude Code, Codex, Cursor) and you're tired of being its full-time hand-cranker.
  • You keep re-typing the same prompts ("fix the failing tests", "triage the new issues") and suspect a machine should be doing the typing.
  • You want the leverage without losing the plot — to automate the inner loop while staying the engineer who owns verification, comprehension, and intent.

No prior "agent" theory required. If you can write a shell while loop and read a diff, you can start.

Where it sits: the lineage

Loop engineering is the newest floor in a four-story stack. Each layer makes the one below it more useful:

LayerThe question it answers
Prompt engineeringWhat should I say to the model?
Context engineering (Karpathy)What state and knowledge should the model see?
Harness engineeringWhat tools, permissions, tests, and sandboxes should surround one agent run?
Loop engineeringWhat recurring system should discover, delegate, verify, persist, and re-run — when the human is no longer in the inner loop?

Prompt, context, and harness make one run better. The loop makes recurring work reliable, observable, and governable. → Full explanation in docs/02 — The Lineage.

The shape of a loop

Objective
  │
  ▼
Trigger / cadence            ← an automation fires the loop (the "heartbeat")
  ▼
Discover / intake work       ← read CI failures, issues, alerts, a task list
  ▼
Delegate to an agent         ← the "maker" proposes a change
  ▼
Act in an isolated workspace ← a git worktree, so parallel agents don't collide
  ▼
Verify with a SEPARATE checker  ← tests, lint, an independent reviewer agent (the "/goal")
  ├── fail → feed the evidence back and retry
  └── pass → persist state, then decide what's next
  ▼
Repeat — or stop on: goal met · budget spent · stalled · needs-a-human

A loop is not a cron job. A cron job repeats blindly; a loop discovers, verifies, persists, and decides what's next — and stops for an honest reason. → docs/03 — Anatomy of a Loop.

Start here (a reading path)

In a hurry? The Cheat Sheet is the whole field on one page, and the FAQ clears up the common confusions. Otherwise, read in order:

  1. docs/01 — What Is Loop Engineering — the idea, plainly.
  2. docs/02 — The Lineage — prompt → context → harness → loop.
  3. docs/03 — Anatomy of a Loop — the lifecycle and the "loop contract."
  4. docs/04 — The Five Building Blocks — automations, worktrees, skills, connectors, sub-agents (+ memory).
  5. Build your own: run the loop-engineering skill, or copy a prompt from prompts/ into Claude Code, Codex, Cursor, or OpenCode, or follow the hands-on docs/10 guide.
  6. Go deeper: verification, memory, stacking loops.
  7. Stay honest: token economics and the risks.
  8. Steal the lessons: Field Notes — 13 cross-cutting things that took everyone else a while to learn.

The docs (learn it in depth)

#ChapterWhat you'll learn
01What Is Loop EngineeringThe core idea and why it appeared in 2026
02The LineagePrompt → Context → Harness → Loop
03Anatomy of a LoopThe lifecycle + the 11-part loop contract
04The Five Building BlocksAutomations · Worktrees · Skills · Connectors · Sub-agents · Memory
05Stop Conditions & Verification/loop vs /goal, maker/checker, LLM-as-judge
06Memory & StateRalph, session-as-event-log, brain/hands/session
07Stacking LoopsLoopcraft, the 4-loop stack, going UP vs DOWN
08Token EconomicsO(N²) cost, the 4×/15× figures, budgets, the orchestration tax
09Risks & the Debt TrilogyComprehension, cognitive, and intent debt; cognitive surrender
10Building Loops in Claude Code, Codex, Cursor & OpenCodeHands-on: claude -p, codex exec, cursor-agent, opencode run, the brakes per tool
11Case StudiesReal loops with real numbers — and the loops that bit back
12Security & Failure ModesReward hacking, the lethal trifecta, doom loops, the threat catalog
13Evaluating the LoopEvals as the regression suite, trajectory vs outcome, proving the verifier
00When Not to Build a LoopThe decision rule: when a loop is the wrong tool
GlossaryEvery term in one place
Field NotesHard-won synthesis: 13 cross-cutting lessons
Cheat SheetThe whole field distilled to one page
FAQThe questions everyone asks first

Practice (copy-paste loop prompts)

The prompts/ library collects real prompts you can adapt today:

  • Ralph loops — the while :; do cat PROMPT.md \| agent; done technique and its refined descendants.
  • /goal & /loop — Claude Code stop-condition and cadence prompts.
  • Automations — OpenAI Codex scheduled-automation prompts (triage, CI repair, PR babysitting).
  • Sub-agents (maker/checker) — explorer, implementer, and independent-verifier skills.
  • Verification rubrics — LLM-as-judge graders that return PASS/FAIL with evidence.
  • Loop contracts — full specs (PR babysitter, CI repair, incident response, dependency triage, PR review, doc-drift repair, flaky-test hunt).

Build a loop for your own workflow (the skill)

The loop-engineering skill is a portable agent skill you can drop into Claude Code, Codex, Cursor, or OpenCode. Point your agent at it and it will interview you about the work you keep doing by hand, fill in an 11-part loop contract, choose honest stop conditions and budgets, and scaffold the files so you finish with a loop you can actually run — and trust.

Install it with one command — it asks which agent you use and where to put it:

npx github:invincible04/awesome-loop-engineering

Or copy the folder yourself (a skill is just a folder with a SKILL.md):

cp -r skill/loop-engineering .claude/skills/loop-engineering   # Claude Code
cp -r skill/loop-engineering .opencode/skills/loop-engineering  # OpenCode

Then ask your agent: "Use the loop-engineering skill to help me design a loop for <the thing you keep doing by hand>." See skill/loop-engineering/README.md for every install path and tool.

A runnable example

examples/runnable/ is a dependency-free Python implementation of the loop machinery — engine, budget, memory, a separate verifier, and the four honest stop conditions — with a test suite. Read it to see the ideas execute, not just described.

cd examples/runnable
python -m loop_cookbook                    # watch a maker/checker loop converge and stop
python -m unittest discover -s tests -v    # 10 tests, standard library only

Contributing

New chapters, sources, and (especially) real attributed prompts are welcome — see CONTRIBUTING.md. Released under the MIT License: use anything here freely.

Spread the loop

If this helped you stop hand-cranking your agents, star the repo and pass it on. The best way to share it is the one-page website — it teaches the whole idea in a single scroll.

A note on dates: loop engineering is young (the term took off in June 2026). Perishable claims — token multipliers, tool features, model behavior — carry an "as of" note, because they expire. What changed between revisions is tracked in the CHANGELOG. Corrections via PR are very welcome.

Files in the repo

Repository payload18 top-level entries
  • .github
  • assets
  • docs
  • examples
  • prompts
  • site
  • skill
  • .DS_Store
  • .gitignore
  • CHANGELOG.md
  • CHEATSHEET.md
  • CONTRIBUTING.md
  • FAQ.md
  • FIELD-NOTES.md
  • LICENSE
  • package.json
  • reading-list.md
  • README.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tutorials & guides

shareAI-lab/
learn-claude-code

Bash is all you need - A nano claude code–like 「agent harness」, built from 0 to 1

77k
luongnv89/
claude-howto
luongnv89/claude-howtoTutorials & Guides

A visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.

41k
agentskills/
agentskills
agentskills/agentskillsTutorials & Guides

Specification and documentation for Agent Skills

25k