How I Automate My Own Work With Agent Loops
Repetitive work does not need me, it needs a reliable loop that never forgets a step. Here is how I use Claude Code loops, scheduled cloud agents, and autonomous loops to run the boring parts of my work, and where I stop them.
Melkon Hovhannisyan automates repetitive work with three kinds of agent loop. A fixed-interval loop runs a task on a timer (in Claude Code, /loop 5m /some-command) for things like watching a deploy. A self-paced loop runs without an interval and lets the model choose its own cadence based on what it is waiting for. A scheduled cloud agent runs a bounded task unattended on a cron schedule, such as triaging pull requests every morning. Every loop he ships is idempotent (safe to repeat), bounded (it always knows when to stop), observable (each run leaves a trace), and escalates genuine exceptions to a human. He automates a task only after running it manually long enough to understand its edge cases.
Why I automate with loops
Most of my work is judgement: architecture decisions, tradeoffs, knowing which problem is actually worth solving this week. But a surprising amount of it is not. It is the same coordination, the same checks, the same small reports, repeated on a schedule. That work does not need me. It needs a reliable loop that never forgets a step and never gets bored on the fourth repetition.
A loop, in the sense I mean here, is an agent running the same task over and over: on a timer, on its own judgement of pace, or on a fixed schedule in the cloud. I lean on three of them every day. The rest of this article is how I set them up and, just as important, where I stop them.
The three loops I actually use
The first is a fixed-interval loop: a task that runs every N minutes inside a live session. The second is a self-paced loop: the same idea, but the model decides how long to wait before the next run based on what it is waiting for. The third is a scheduled cloud agent: a bounded task that runs unattended on a cron schedule, with no terminal open at all.
Each one trades immediacy for autonomy. A fixed-interval loop is right there in front of me and easy to interrupt. A scheduled agent runs while I sleep but has to be trusted to finish on its own. Picking the right one is mostly about how closely I need to watch the work while it happens.
Running a loop in a live session
The simplest loops live in a session I have open. When I need to watch something that changes on its own, a deploy finishing, a CI run going green, a queue draining, I put it on a fixed interval. In Claude Code the command is /loop with an interval and a slash command or prompt:
/loop 5m /babysit-prsThat runs the task every five minutes until I stop it. The one rule that matters here is to match the interval to how fast the state actually changes. Polling a deploy every thirty seconds when it takes eight minutes just burns work for no new information. If the thing I am watching updates every few minutes, I check every few minutes, not every few seconds.
Sometimes I do not know the right interval in advance, or it changes as the task progresses. For that I drop the interval entirely and let the model pace itself, scheduling its own next wake-up based on what it is waiting for:
/loop monitor the staging deploy and tell me the moment it finishesThe useful instinct here is to think in cache windows, not round numbers. A wait under five minutes keeps the working context warm, so it is cheap to check back often while something is actively moving. A longer wait pays to reload context, so it is worth it only when there is genuinely nothing to do until then. The mistake is the middle: waiting exactly five minutes pays the reload cost without buying much idle time. So I either check back quickly or commit to a real pause, and let the loop decide which.
Scheduling agents in the cloud
The loops above live in a session I have open. The work that runs while I am asleep is different: it goes to a scheduled cloud agent, a routine on a cron schedule that runs unattended. A morning pull-request triage, an overnight summary of new errors, a weekly dependency check. I do not have to be there, and there is no terminal to keep open.
A scheduled agent only works if the task is crisp and bounded, and if it has a clear place to put its output. Vague instructions plus no audience produces work nobody reads. So each routine answers two questions before I schedule it: what exactly is done when this finishes, and where does the result land, a Slack message, a draft email, a file I will see in the morning. If I cannot answer both, it is not ready to be a loop yet.
The principles that keep a loop safe
Automation that runs without me watching is only as good as the guardrails around it. Five rules carry almost all the weight.
Idempotent: every run must be safe to repeat. I design the task so a double-run does not double-charge, double-post, or double-anything. The loop should be able to run twice by accident and leave the world in the same state.
Bounded: every loop needs a stopping condition or a sane fallback, or it spins forever. A loop that waits on an event also gets a maximum it will wait, so a stuck dependency does not turn into an infinite poll.
Escalate exceptions: the loop handles the routine and pings a human for the genuinely unusual. This is the same pattern my Plain Freight agents use to run shipments, the machine owns the ninety percent that is predictable, and a person gets the ten percent that is not.
Observable: a loop you cannot see is a loop you cannot trust. Each run leaves a trace, a message, a log line, a status, so I can reconstruct what it did without rerunning it.
Manual first: I run a task by hand until I understand its edge cases, then I wrap it in a loop. Automating a process I do not yet understand just automates the mistakes faster.
Where the loop ends and I begin
The line I draw is simple. Loops own the repeatable, I own the judgement. A loop can chase a deploy, summarise overnight errors, and nudge a stuck pull request without me. It cannot decide whether a tradeoff is worth making, whether a risk is acceptable, or which of three problems deserves my week. That is taste, and taste does not loop.
Done well, this is leverage, not laziness. Every repetitive step I hand to a reliable loop is an hour I get back for the work that actually needs a human. The goal was never to remove myself from the work. It was to remove myself from the parts of it that never needed me in the first place.
Key Takeaways
An agent loop is an AI agent running the same task repeatedly: on a timer, on its own pace, or on a cloud schedule.
Use a fixed-interval loop (/loop 5m /command in Claude Code) to watch things that change on their own, like a deploy or CI.
Match the interval to how fast the state changes; polling faster than that just burns work for no new information.
Use a self-paced loop when you do not know the interval, and think in cache windows rather than round numbers of minutes.
Use a scheduled cloud agent for unattended recurring jobs, but only when the task is bounded and its output has a clear home.
Keep every loop idempotent, bounded, observable, and willing to escalate genuine exceptions to a human.
Run a task manually until you understand its edge cases before you automate it, or you just automate the mistakes.
Loops own the repeatable work; judgement, tradeoffs, and priorities stay with you.
Frequently asked questions
What is an agent loop?
An agent loop is an AI agent running the same task repeatedly: on a fixed timer, on its own judgement of pace, or on a schedule in the cloud. Instead of asking the model to do something once, you give it a task and a cadence, and it keeps running until a stopping condition is met. It suits repetitive coordination work that needs reliability more than judgement.
How do I run a task on a loop in Claude Code?
Use the /loop command. Give it an interval and a prompt or slash command, for example /loop 5m /babysit-prs to run every five minutes. Omit the interval (/loop followed by a plain instruction) to let the model pace itself and pick its own next wake-up time. Omit the call entirely and the loop ends.
What is the difference between a loop and a scheduled cloud agent?
A loop runs inside a live session and is best for short, active polling, such as watching a deploy or a CI run. A scheduled cloud agent (a cron routine) runs unattended without your terminal open and is best for recurring background jobs, such as a morning pull-request triage or an overnight error summary. Loops trade autonomy for immediacy; scheduled agents trade immediacy for autonomy.
How do you stop an automated loop from doing damage?
Four rules. Make every run idempotent so a double-run does not double-charge or double-post. Make every loop bounded with a stopping condition or a sane fallback interval. Make every run observable so it leaves a trace you can read. And have the loop handle only the routine, escalating anything genuinely unusual to a human instead of guessing.
When should you not automate a task with a loop?
When you do not yet understand its edge cases, or when it needs real judgement. Automating a process you have never run by hand just automates the mistakes. Loops should own repeatable, low-judgement work; decisions about tradeoffs, risk, and priorities stay with a person.
Related articles
Comments
Be the first to comment.