Loop engineering
How to keep an AI agent working while you are away from the desk: one Claude Code session on /loop, fed by your voice notes, reporting to your inbox. Every step, the exact prompt, and what breaks.
What is loop engineering?
Loop engineering is designing the loop an AI agent runs in: where its work comes from, how often it checks for more, what it may do on its own, how it proves the work happened, and how you answer it when it needs you.
Prompt engineering is about getting one good answer. In a normal AI workflow you are the loop: you type, wait, read, and type again, and the work stops the moment you walk away. Loop engineering takes you out of the waiting. The agent keeps running, you hand it work from wherever you are, and you show up only for decisions.
| Prompt engineering | Loop engineering | |
|---|---|---|
| Unit of work | One answer | A system that keeps producing finished work |
| Who keeps it moving | You, typing the next message | The loop, on a timer |
| Where you are | At the keyboard, watching | Anywhere, reading email |
| What you tune | Wording of the prompt | Inbox, cadence, permissions, proof of work |
| How it fails | A bad answer you can see | Silent misses, unless the loop proves its work |
The six parts of every loop
Every agent loop that works has the same six parts. If one is missing, the loop quietly falls back to you sitting at the keyboard. Here is each part, and what I use for it.
Inbox
Where work enters. It must be reachable from anywhere, because tasks show up when you are away from the desk.
MineContextli voice notes with the label "claude".
Trigger
What wakes the agent up. A fixed interval, a self-paced check, or a schedule in the cloud.
MineClaude Code /loop every 10 minutes.
Worker
One long-running session that keeps its memory of every task, so a later reply lands on the right job.
MineOne Claude Code session on a computer that stays on.
Record
Where the detail lives: the request, decisions, file names, commands. Written before the work starts.
MineA ticket per task in the team tracker.
Report
How results reach you. Short, plain English, and only for things that need your eyes.
MineEmail: done, needs approval, or a question.
Reply
How you answer without sitting down. If replying is slow, the loop stalls on you.
MineAnother labeled voice note.
Set it up, step by step
What you need: Claude Code on a paid Claude plan, a computer that can stay on, the Contextli app on your phone, and an email connector. A ticket tracker such as ClickUp or Jira is optional. Plan on about 20 minutes, most of it signing in.
- 01
Pick one label that means âdo thisâ
In Contextli, dictate a task and add the label
claudeto it. That label is your agentâs inbox. Everything you dictate without it stays a normal note that no agent touches, so you can still think out loud.Use a verb-like label, not a topic. A label called âideasâ tells the agent what you were thinking about. A label called âclaudeâ tells it to act.
- 02
Connect Contextli to Claude Code (once)
On the computer that will stay on, run this in a terminal:
claude mcp add --transport http contextli https://mcp.contextli.com/mcp
Open Claude Code, type
/mcp, choose contextli and sign in with your Contextli email and the 6-digit code it sends you. The agent can now list, filter and label your notes. Using Codex or another MCP client? Add the same address as an MCP server there. - 03
Connect where the results go
Add an email connector (for example Gmail) so the agent can write to you. The loop only works if you read its output away from the desk, and email is the one inbox you already check on your phone.
Optional but worth it: connect ClickUp, Jira or Linear, so each task gets a ticket that holds the technical detail and your email stays short.
- 04
Start the loop
Start a fresh Claude Code session, so every connector is loaded, and paste the prompt. Keep this one session for everything: because it has been running the whole time, a later âmake that button biggerâ lands on the right task.
/loop 10m Check Contextli for notes labeled "claude" that don't have the label "claude-queued". For each one, oldest first: 1. Add the label "claude-queued" so it never runs twice. 2. Log it: create a ticket (or add a line to loop-log.md) with the request in my words and what done looks like. 3. Do the work. Record progress on the ticket. 4. Email me only when it's done, needs my approval, or you have a question. Plain English, with a link or proof of the result. 5. If a note is feedback on an earlier task, apply it to that task. Ask me before anything you can't undo: deleting data, spending money, publishing, or emailing anyone except me.
- 05
Keep the computer awake
The loop runs inside your session, so the machine must stay on and the session open. On a Mac, run
caffeinate -iin a separate terminal tab and keep the lid open (or use a desktop). On Windows, set sleep to âneverâ while plugged in. - 06
Test it in one minute
Dictate
Email me the word hello., add the labelclaude, and put your phone away. If âhelloâ lands in your inbox within about 10 minutes, the loop works. From then on: talk, label, walk away, read email when you have a minute.
The /loop command, explained
/loop is a built-in Claude Code command that runs a prompt, or another slash command, on a repeating interval inside your current session. It is what turns a one-off request into a loop.
Syntax
/loop 10m <prompt>runs the prompt every 10 minutes.- Units are
s,m,handd. The minimum is one minute; odd intervals are rounded and Claude tells you the real cadence. /loop <prompt>with no interval is self-paced: Claude picks each next delay, from one minute to one hour.- It can repeat another slash command too:
/loop 20m /your-command.
Behavior worth knowing
- Session-scoped. Close the terminal or start a new conversation and the loop stops.
- Expires after 7 days. Recurring loops delete themselves a week after you create them. Put ârestart the loopâ on your Monday list.
- Waits its turn. A check never interrupts work in progress; it runs when the current turn ends.
- Can drift. Runs may land a few minutes off the exact interval, so never build on precise timing.
- To stop it, ask Claude to cancel the loop, or press Esc while a self-paced loop is waiting.
When /loop is the wrong tool
/loop needs your session open on a machine that is awake. That is perfect for hands-on work with your own files and tools. For anything that must run with the laptop closed, use one of the other ways Claude Code runs on a schedule:
| Option | Runs on | Laptop closed? | Best for |
|---|---|---|---|
| /loop in Claude Code | Your open session | No. Close the session and it stops. Recurring loops expire after 7 days. | Hands-on work with your local files and tools, checked every few minutes. |
| Desktop scheduled tasks | Claude desktop app on your machine | Machine must be on, no open session needed | Daily or hourly jobs on your own computer. |
| Routines (/schedule) | Anthropic's cloud | Yes, laptop can be closed. Hourly at most. | Reports and checks that do not need your local machine. |
| GitHub Actions or cron + claude -p | CI or a server | Yes | Team workflows tied to a repo, run headless. |
How often should the loop check?
Cadence is a trade between how fast a task starts and how much each empty check costs. Ten minutes is the right default for a voice inbox: a note you dictate in the car is picked up before you have parked, and a quiet hour costs six short checks.
Go shorter (2 to 5 minutes) only while you are actively going back and forth with the agent. Go longer (30 minutes to an hour) overnight or for work that can wait until morning.
Fixed
/loop 10m
Predictable. Best when tasks arrive all day.
Self-paced
/loop <prompt>
Claude checks more often while things are happening and backs off when quiet.
Back-off by rule
in the prompt
Tell it: every 5 min while I am sending tasks, 15 after 20 quiet minutes, 30 after that.
Why voice is the input
A loop is only as good as its inbox, and the best tasks arrive at the worst moments: in the car, on a walk, halfway through a meeting about something else. If capturing a task means finding a keyboard, most of them never reach the agent.
You capture the task when you have it
Say it the second it occurs to you. The idea does not have to survive the drive home.
Spoken briefs are richer
Speaking is roughly three times faster than typing on a phone, so you include the why, the constraints and the example you would have cut when typing.
Labels route the work
"claude" goes to Claude Code, "codex" to a Codex session, anything unlabeled stays yours. Choosing the agent is one tap.
Replies take seconds
When the agent asks a question, you answer by dictating another labeled note. Nobody waits for you to reach a desk.
How dictation speeds up prompting: say the outcome, not the steps. âThe language switcher on that screen is clutter, remove itâ does more than a dictated spec, because the agent fills in the steps and the ticket records them. When you do need detail, talk through it once; a two-minute ramble with context beats a one-line typed prompt every time. The speed figure above comes from a Stanford study of speech versus typing on phones.
How you know the loop did the work
An unattended loop fails silently. Nothing throws an error when a note is skipped or a result sits in a terminal nobody reads. A loop that says âdoneâ without proof is worse than no loop, because you stop checking. Build the proof in:
- Mark on pickup, not on finish. The agent adds
claude-queuedthe moment it takes a note. Its query is âlabeled claude, without claude-queuedâ, so nothing is missed and nothing runs twice. - Never filter by date. Mine once asked for ânotes sinceâ a timestamp; the filter returned nothing while two new notes were waiting. The label check has no such gap.
- Ticket before work. The request is written down in your words before anything changes, so there is always a record to compare the result against.
- Report in the same run. Every finished task is emailed in the check that finished it. Results left in the chat window are results you never see.
- Proof in the report. A link to the live page, a screenshot, the ticket id. âDeployedâ is a claim; a link you can tap is evidence.
- Track what was handled by id. Never by âunreadâ. If you open a reply on your phone first, an unread filter silently hides it from the loop.
What the agent may do alone
The question that matters more than any prompt wording is what the loop may do without asking. Write it into the prompt as a short list. Mine:
- Anything reversible: drafts, code on a branch, research, reports.
- Fixes it can verify itself, with proof in the email.
- Asking me a question by email instead of waiting.
- Deleting data, or anything that cannot be undone.
- Changing prices, or spending more than a few dollars on paid APIs.
- Publishing, posting, or emailing anyone except me.
- Anything that touches passwords or keys. It never prints them.
What I learned running one every day
I run my companies with one of these loops. Here is what it actually handles, and the lessons that cost me something to learn.
"A friend can't sign in on the iPhone app. Find out why."
Audited the sign-in setup, ruled out a bug on our side, and emailed me the one log it still needed.
"Approved, ship it."
Published a report I had already reviewed, checked the live page, and emailed me the link.
"These drafts are good, but nobody could copy the workflow from them. Redo them."
Rewrote the whole batch and sent it back for review. I never opened a doc.
"Put this new customer on the Pro plan."
Set it up in the billing dashboard and replied with what changed.
- Plain English or it does not get read. Agents write updates for engineers. One line in the prompt, âtechnical detail goes in the ticket, email me plain Englishâ, turned walls of file names into decisions I can clear on my phone.
- One inbox for replies. Feedback arrives as a voice note or an email reply. The loop checks both, and a rule tells it to apply feedback to the earlier task rather than start a new one.
- Cap the helpers. The loop can spin up helper agents for big jobs. More than three at once and they start stepping on each otherâs files.
- Money needs a ceiling. After one batch job spent far more on API calls than I expected, the rule became: anything that will cost more than a few dollars emails me an estimate first.
- Restart weekly. Recurring loops expire after seven days. A loop that quietly stopped on day eight looks exactly like a quiet week.
âThe real test: can you say what got handled today without opening the laptop once? If not, it is not a loop yet. It is a faster notepad.â
Prompt library
Swap in your own label, tracker and inbox. Each one runs as-is once Contextli and an email connector are connected.
/loop 10m Check Contextli for notes labeled "claude" that don't have the label "claude-queued". For each one, oldest first: 1. Add the label "claude-queued" so it never runs twice. 2. Log it: create a ticket (or add a line to loop-log.md) with the request in my words and what done looks like. 3. Do the work. Record progress on the ticket. 4. Email me only when it's done, needs my approval, or you have a question. Plain English, with a link or proof of the result. 5. If a note is feedback on an earlier task, apply it to that task. Ask me before anything you can't undo: deleting data, spending money, publishing, or emailing anyone except me.
/loop Check Contextli for new notes labeled "claude" (no "claude-queued" label yet) and handle them the same way. Check more often while I'm sending tasks, less often when it's quiet.
/loop 15m Check Contextli for notes labeled "claude" without "claude-queued". Tag each one, then write what it asks for (a client follow-up, a proposal, a weekly update) and email me the draft. Never send anything to anyone except me.
Questions people ask
What is loop engineering?
Loop engineering is designing the loop an AI agent runs in: where its work comes from, how often it checks, what it may do on its own, how it proves the work happened, and how you answer it. Prompt engineering improves one answer. Loop engineering builds a system that keeps producing finished work while you are away.
What does /loop do in Claude Code?
/loop runs a prompt or slash command on a repeating interval inside your current Claude Code session, for example /loop 10m followed by your prompt. Intervals can be in seconds, minutes, hours or days, with a minimum of one minute. If you leave the interval out, Claude chooses the next delay itself, between one minute and one hour, based on how busy things are.
How long does a Claude Code /loop keep running?
A /loop lives inside the session that created it, so closing the terminal or starting a new conversation stops it. Recurring loops also expire seven days after you create them. Restart the loop once a week, or move checks that must survive a closed laptop to a cloud routine.
Does my computer have to stay on?
For /loop, yes: the session runs on your machine, so it must stay awake with the session open. On a Mac, running caffeinate -i in a terminal keeps it from sleeping. If you need the loop to run with the laptop closed, use a cloud routine instead, which can run at most once an hour.
Why use voice notes as the inbox?
Tasks show up when you are driving, walking or between meetings, not at the desk. A dictated note captures the task, the reason and the constraints in about 30 seconds, and a label decides which agent handles it. The same channel works for replies, so you never have to sit down to unblock the agent.
Does this work with Codex, Cursor or ChatGPT?
The Contextli connector is a standard MCP server at https://mcp.contextli.com/mcp, so any MCP client can read your labeled notes, including Codex, Cursor and ChatGPT. The always-on part needs an agent that can run on a timer, such as Claude Code with /loop or a scheduled task.
Is it safe to let an agent run unattended?
It is as safe as the rules you give it. Only act on notes with one specific label, mark each note as picked up so nothing runs twice, log every task before starting, and require approval for anything irreversible: deleting data, spending money, publishing, or emailing anyone except you.
How much does a loop cost to run?
Each check is a short turn that uses your Claude plan like any other message, and a quiet check costs very little. Longer intervals use less. A 10 minute interval is a good default for personal work; use self-paced mode if your tasks arrive in bursts.
Do I need to be a developer?
No, but you need to open a terminal once to install Claude Code and paste two commands. After that the whole loop is run by talking into your phone and reading email. Claude Code handles plenty of non-code work: drafts, research, reports and follow-ups.
Your loop is only as fast as the way work gets into it.
Contextli turns what you say into clean, labeled notes on your phone and computer, and connects to Claude, Codex and any MCP client. Say the task, add the label, and let the loop take it from there.