ai-dict.orgThe directory of the best AI tools
← Directory

AI automation

Loop engineering: tasks that run themselves Advanced

Level: BeginnerSteps: 8Updated July 2026

In short

Instead of prompting the AI step by step, you give it a measurable goal – and it works in loops: execute, self-check, improve, until the goal is reached. With Claude Code this already works in the free quota for small tasks; on the Pro plan, longer loops run that, for example, keep improving code until all tests pass.

Free

CClaude Code
  1. Install Claude Code (runs in the terminal) and sign in with a paid Claude plan.
  2. For a task with a clear finish line, use the /goal command and describe what 'done' looks like concretely (ideally measurable, e.g. by character count or a checklist).
  3. Claude then works round after round, checks after each round whether the goal is reached and stops automatically once it is met.
  4. For tasks without a finish line that you just want to re-check, use /loop with an interval (e.g. every 30 minutes). Press Esc to stop a waiting loop.
Example prompt

/goal Every blog post in the /posts folder has a meta description under 160 characters and a title under 60 characters. After each file, output the character count so I can confirm, and don't touch the body text. Stop when every file passes, or after 25 files.

Limits: You start the loop by hand and watch the first run. Unverified goals lead to mistakes – the goal must be phrased so the AI can check its own work.

Premium / Automated

CClaude Code
  1. Hand the loop a full 'charter': goal, where the work is, how it checks itself, how it remembers (a state file) and when it stops.
  2. Create a skill file (folder .claude/skills/) that captures your project knowledge – so every run starts with context.
  3. Separate the build and check steps: one agent does the task, a second checks it independently. This makes loops trustworthy enough to run unattended.
  4. Add connectors (mail, task board, Google Drive) so 'find the work' reaches real tools, and start the loop on a schedule in the background.
Example prompt

You run as a loop, not a single answer. GOAL: [describe the finished state in 1-2 sentences, measurable]. WHERE THE WORK IS: [e.g. 'Read TODO.md and treat every open item as a task']. HOW YOU WORK: always finish one item completely; adopt existing conventions; for decisions only I can make (money, deleting, contacting), stop and add it to a 'needs my decision' list. HOW YOU CHECK: [e.g. re-read the file and confirm against the goal] – proof, not confidence, max. 3 attempts per item, otherwise log as blocked. HOW YOU REMEMBER: keep a LOOP-STATE.md and read it first at the start of each run. WHEN YOU STOP: when everything is done or blocked, or after [N] items; then a short report.

Added value: Runs on a schedule and unattended, remembers progress via the state file and picks up on the next run where it left off. Caution: loops use more than simple prompts – start with small amounts ([N] items per run).

Frequently asked questions

Who is loop engineering suitable for?

For anyone working with code or clearly verifiable tasks – including beginners with basic programming knowledge. The key is a measurable goal ("all tests pass", "error X disappears") against which the AI can check itself.

How does the AI know when it's done?

By the defined success criterion: a test run, an error message, a target value. After each round it checks the criterion and stops as soon as it's met – which is why a cleanly formulated goal matters more than a perfect prompt.

Can the loop run forever and rack up costs?

Always set an upper bound ("maximum 5 rounds") – then the loop stops even if the goal is unreachable. In the free quota the usage limit adds another cap; on a plan you keep an eye on the rounds.