Fable 5: A Beginner's Guide to Loop Engineering

@aiedge_
ENGLISCHvor 1 Tag · 03. Juli 2026
251K
220
35
6
768

TL;DR

This guide introduces loop engineering, a method where AI agents self-iterate to complete complex tasks like research and coding without manual intervention.

Loop engineering is the biggest shift in AI prompting we've ever seen.

Pair it with Fable 5, and you'll have AI agents working for you while you sleep, building anything you could think of.

This guide teaches you exactly how to get started.

A layman's guide to loop engineering & how the average person can take advantage of /loop.

Contents

  • wtf is a Loop?
  • Loop Anatomy 101
  • Prompting 101
  • /loop Pro Tips

wtf is a Loop?

TL;DR

Loop engineering is essentially a way for agents to prompt themselves and avoid manual iterations.

Before loop engineering: You prompt AI → It responds → You iterate → Repeat

With loop engineering: You design a loop → Agent comes back with a finalized result (agent completes all the research, back-and-forth, etc.)

The person who actually built Claude Code (Boris Cherny) put it plainly:

"I don't prompt Claude anymore. I have loops running that prompt Claude. My job is just to write loops."

This is the single biggest shift in prompting AI we've ever seen.

For now, that's all you need to know. What's more important is loop anatomy and how to actually take advantage of this shift to unlock AI productivity.

Loop Anatomy 101

AI Edge - inline image

Loop Anatomy 101

For this guide, I'll reference Claude Code, but these principles apply to most AI tools and frameworks.

Every loop in Claude Code has the same six working parts.

Master these, and you'll be able to build anything.

1. Trigger (Automations)

The trigger is what starts the loop.

In Claude Code, you trigger agentic loop automations with /schedule and /loop (more on prompting later).

/loop runs on a specified interval; without an interval, it self-paces based on output.

2. Execution Layer

This is where Claude actually does the work.

It reads the current state, takes action, and produces outputs.

No manual input is needed - just watch Claude work.

3. The Verifier

This is where you give Claude a checkpoint.

Things like: Tests, a build, a screenshot to compare.

Using a verification layer helps ensure Claude is actually on the right track and not producing slop.

You can use the /goal command, which takes things a step further by running a separate fast model to grade the work after every turn.

4. Stop Rules

Every loop needs two types of stop conditions:

  1. Success stopping (all tests pass, task complete)
  2. Failure stopping (retry count exceeded, unrecoverable error).

You can also add stop rules, such as a token budget, which can help manage AI spend.

text
1Make these explicit in your instructions, not implicit:
2You have a maximum of 20 attempts. If all tests pass, report "TASK_COMPLETE" and stop.
3If you encounter an error you cannot resolve after 3 retries, report "TASK_FAILED: [reason]" and stop.

5. Memory (Progress File)

Keeping a markdown file of Claude's progress is generally good practice.

A simple log of what's been done so you can check its work and go back if needed.

6. Skills (CLAUDE.md)

Skills are saved instruction sets that freeze project knowledge so the agent doesn't re-learn the same context every session.

Your CLAUDE.md file is what gives the loop its personality and sets its constraints for every run.

Tip: Keep it short. A bloated rules file gets paid for on every single beat of the loop.

Put all six together, and the optimal loop structure looks like this:

text
1TRIGGER → every 15min / on PR comment / on CI failure
2DOER → Claude works the task
3CHECKER → separate model grades the output
4STOP → all tests green, or 10 iterations, or $5 spent
5MEMORY → progress.md updated each run
6SKILLS → CLAUDE.md read on every session start

Prompting 101 (putting things together)

Writing /loop prompts are not the same as regular prompting. You need a slight mental shift when loop engineering.

When you prompt Claude normally, you're simply writing an instruction/task.

When you're designing a loop, you're writing a final condition that must be met.

Example

Prompt (single turn):

text
1Fix the failing tests in the auth module.

Goal condition (loop):

text
1/loop all tests in the auth module pass and coverage is above 80%

A prompt tells Claude what to do, while a goal condition tells Claude when to stop.

The anatomy of a good goal condition

Every strong /loop prompt has three things:

  1. A verifiable end state
  2. A scope constraint (what files, what folders, what tasks)
  3. A stop rule (max iterations or budget)

Here's the template:

/loop [verifiable end state/time], only touching [scope], stop after [X] constraints, use [X] Skills, use verifier agents for [x] checkpoint, and keep a memory file of all your work.

This is the base /loop structure that every beginner should use to get great results without overcomplicating things.

CLAUDE.md

Think of your CLAUDE.md as the briefing document your loop reads before it starts every a run.

Be sure to include everything you'd normally repeat in a prompt, your stack, your rules, your preferences, etc.

Again, keep it short. Every extra line of bloated context costs tokens.

Putting everything together (an example research brief /loop):

text
1CLAUDE.md (set once):
2Research style: comprehensive, cited, no fluff
3Output format: markdown with clear headers
4Never create files outside /research
5Preferred sources: primary sources, reputable publications, official data
6Max budget per session: $3
7Skill (set once):
8/skill verify-research: before marking any section complete, confirm
9every major claim has a source, every section has at least 3 supporting
10data points, and there are no obvious gaps. Never hand back thin research.
11The loop:
12/loop every 30 minutes,
13
14only touching /research/brief.md,
15
16stop after 10 iterations or if the same search query appears
173 times in a row without new information surfacing,
18
19use the verify-research skill after each section is drafted,
20
21use a verifier agent to check source quality and coverage
22completeness at the halfway point and before final submission,
23
24and keep a memory file at /research/progress.md that logs
25what sections are done, what sources have been used,
26and what angles still need coverage — read it at the start
27of every run and update it at the end.
28
29Topic: [your topic here]
30
31Every principle in one place. The loop runs on a timer, stays scoped to one file, stops itself on stall or budget, uses a saved skill as the quality gate, spins up a separate verifier at two checkpoints, and keeps a persistent memory file so each run picks up exactly where the last one stopped.

/loop Pro Tips

A section of /loop pro tips to get you started

  • Start with /goal before /loop: It's the same behavior, but easier to reason about as a beginner.
  • Spend more time on the deliverable: When designing loops, focus on what you want the end goal to look like - everything else is pretty much noise.
  • Match the effort level to the task: Your default reasoning effort should be high. Only use xHigh, Max & Ultracode for complex builds.
  • Subagents: Each subagent starts with a fresh context window. Take advantage of deploying subagents within loops.
  • Always cap: Make it a habit to set a hard iteration limit and a dollar budget before every run.
  • Run /compact manually before long sessions: When the context window approaches its limit, the SDK automatically compacts. You can also trigger it early with /compact.
  • Loops work for way more than code: You can use /loop for all tasks. Feel free to be creative and use loops for writing, research, and unconventional non-coding tasks.

Closing

I hope you've found this /loop guide valuable.

If you did, be sure to follow me @aiedge_ - I post AI articles just like this one 2-3x/week.

If you enjoy written AI content, feel free to subscribe to my free newsletter here:

https://newsletter.aiedgehq.co/

AI Edge - inline image

https://newsletter.aiedgehq.co/

100% free, no spam ever & unsub anytime.

Lastly, if you can, please follow my new clips account where I post short clips discussing trending AI/market topics - I'm sure you'll get a lot of value💙

https://x.com/DeutscherClips/status/2072924183861018957

Turn one viral article into a full content workflow

Collect the source, decode the pattern, create assets, draft the story, and distribute from one AI workspace.

Explore YouMind
Für Creator

Verwandle dein Markdown in einen sauberen 𝕏-Artikel

Wenn du eigene Langtexte veröffentlichst, wird die 𝕏-Formatierung von Bildern, Tabellen und Codeblöcken mühsam. YouMind macht aus einem ganzen Markdown-Entwurf einen sauberen, sofort postbaren 𝕏-Artikel.

Markdown zu 𝕏 testen

Mehr Muster zum Entschlüsseln

Aktuelle virale Artikel

Mehr virale Artikel entdecken