The shift from prompting Claude to building agent loops that prompt Claude for you — five components, a complete loop charter template, and the honest caveats about when not to loop.
This guide is reviewed for clarity, service accuracy, and AI-search readability. The next quarterly content review is tracked internally before unsupported metrics or client proof are added.
From Prompting to Loop Engineering
For the past few years, the top AI skill was writing a good prompt. The problem is that prompting keeps you in the room. You type, you wait, you correct, you type again. You're holding the agent's hand for every step.
A loop replaces you in that seat. You hand it one goal, and it finds the work, does it, checks itself, records what it finished, and repeats until the goal is done. The Head of Claude Code at Anthropic described his own workflow: "I don't prompt Claude anymore. I have loops running that prompt Claude and figure out what to do. My job is to write loops." That shift — from issuing instructions to designing systems that issue instructions — is loop engineering.
What a Loop Actually Is
Every loop, regardless of complexity, runs the same five-beat cycle:
- Find the work: the loop discovers what needs doing — open tasks in a list, failing tests, unanswered emails, items in a queue
- Do it: the agent works one item at a time, the same way you would have prompted it manually
- Check itself: a verification step decides whether the work is actually done and correct, not just generated
- Remember: the loop writes down what it finished so it never redoes completed work and can resume where it left off
- Go again: it repeats until there is nothing left, then stops or surfaces a report
The Five Components of a Claude Code Loop
Each component maps to a specific Claude Code feature:
- Automations: what makes the loop run on a schedule instead of when you type. Run Claude headlessly:
claude -p 'your loop prompt'— or ask Claude Code to schedule a recurring task. Scheduled runs are how the loop works while you sleep. - Worktrees: git worktrees give each agent its own isolated copy of your project so two agents can work in parallel without overwriting each other. In Claude Code, just ask: "do this in a separate worktree."
- Skills: markdown files in
.claude/skills/that hold the knowledge you keep re-explaining — project structure, rules, output formats. Write it once and every loop run starts already knowing your project. - Connectors: MCP integrations that let the agent touch real tools — email, task tracker, Google Drive, database. Without connectors, a loop can only work on local files. Add them with
claude mcp add. - Sub-agents: the agent that does the work should not be the agent that grades it. Define separate agents in
.claude/agents/so a builder agent works and a reviewer agent independently checks it.
The Loop Charter — A Ready-to-Paste Template
You do not need to write code to start. Fill in the brackets and paste this into Claude Code:
promptYou are running as a loop, not answering a single prompt. Here is your charter: GOAL [Describe the finished state in one or two sentences. Be specific about what DONE looks like.] HOW TO FIND THE WORK [Tell it where the work lives. Examples: 'Scan the /pages folder for files missing updated pricing.' / 'Read TODO.md and treat every unchecked item as a task.'] HOW TO DO THE WORK - Work on ONE item at a time. Finish it completely before starting the next. - Follow the project conventions you find in existing files. Match style, don't invent new patterns. - If an item requires a decision only I can make (spending money, deleting things, contacting a person), STOP on that item, add it to a 'needs decision' list, and move on to the next item. HOW TO CHECK YOURSELF After each item, verify it before marking it done: [Pick what fits: 'run the tests' / 're-read the file and confirm it meets the goal' / 'take a screenshot and confirm it looks right.'] If verification fails, fix it and verify again. Maximum 3 attempts per item, then log it as blocked and move on. HOW TO REMEMBER Keep a file called LOOP-STATE.md. After every item, update it with: item name, status (done / blocked / needs decision), what you changed, and anything the next run needs to know. Read this file FIRST at the start of every run so you never redo finished work. WHEN TO STOP Stop when: (a) every item is done or logged as blocked, or (b) you have completed [N] items this run. Then give me a short report: what got done, what is blocked, what needs my decision. Begin by reading LOOP-STATE.md if it exists, then find the work.
Why the State File Is Not Optional
The LOOP-STATE.md file is what turns ten separate runs into one continuous employee. Without it, every run starts from zero. With it, you can run the same charter on a schedule and the loop always picks up exactly where it left off.
This is especially important for long-running work — processing a backlog, cleaning up a folder, sending a sequence of follow-ups. The state file is the loop's memory.
When NOT to Loop
Loops are not free and not for everything:
- One-off tasks do not need loops: if the work is a single answer — write this email, summarize this doc — a prompt is faster and cheaper. Loops earn their setup cost on repeating or multi-item work.
- Loops burn more usage than prompts: a loop that checks itself and retries runs multiple agent turns per item. Start with small batches — the '[N] items per run' line in the charter exists for exactly this reason.
- Verification is the whole game: if you cannot describe how the loop should check its own work, the task is not ready to be a loop yet. Keep it as a prompt until you can define a concrete pass/fail condition.
Frequently Asked Questions
- How is a loop different from a Claude Code skill? A skill is a set of reusable instructions for a specific task. A loop is a system that runs a skill repeatedly until a goal is reached. Skills are building blocks; loops are the engine.
- Can I run multiple loops at the same time? Yes, using worktrees. Each loop gets its own isolated copy of the project. Without worktrees, two loops running simultaneously will overwrite each other's work.
- What is the most common reason a loop fails? A goal that cannot be verified. If Claude cannot check whether an item is actually done — because the definition of 'done' is vague — the loop will stop acting like a loop and start acting like a single prompt that happens to run multiple times.
