Cover art for How Claude Code's Slash Loop Really Works
Episode 6820 manual-script

How Claude Code's Slash Loop Really Works

A five-minute slash loop fires at four minutes forty-five seconds to keep the prompt cache warm before it expires.

20:17 Transcript

0:00
0:00
Episode Details
Episode ID
MWP-7024
Published
Duration
20:17
Audio
Direct link
Pipeline
V5.37
TTS Engine
omnivoice
Script Writing Agent
Claude Sonnet 5.5

AI-Generated Content: This podcast is created using AI personas. Please verify any important information independently.

The prompt

The prompt that started this episode, as sent in (production notes for the hosts removed).

A deep dive on agent loops in Claude Code: the /loop command as the latest Claude Code documentation describes it. How do you use it, can you run a loop with your own custom prompt, and everything else about it: intervals, self-paced mode, loop.md, lifecycle and limits, and where it sits next to /schedule and /goal.

Claude Code includes slash loop, a bundled skill for scheduling recurring automated tasks. Users can specify fixed cron-based intervals, which enforce a one-minute minimum, or omit the interval entirely. When omitted, Claude dynamically paces itself between one minute and one hour using ScheduleWakeup, enabling self-termination once a task concludes. Omitting the prompt entirely triggers a default maintenance routine that can be overridden with a loop.md file. Because Claude Code rereads loop.md on every iteration, instructions can be adjusted dynamically during active runs. Tasks run only while the session remains active and idle, with recurring schedules expiring after thirty days. To optimize prompt caching, five-minute loops intentionally fire after four minutes and forty-five seconds.

Mentions

  • Anthropic AI safety company behind Claude
  • Channels Event-driven alternative to polling in docs
  • Claude Code Anthropic's agentic coding CLI tool
  • GitHub Actions CI/CD and automation platform
  • Haiku Fast model judging goal completion
  • MCP Protocol whose prompts don't fire in loops
  • Monitor tool Background command watcher feeding output lines
  • ScheduleWakeup Internal tool for self-paced loop delays

Downloads

Episode Audio

Download the full episode as an MP3 file

Download MP3
Transcript (TXT)

Plain text transcript file

Episode Book (PDF)

The episode's record — date, duration, models, sources — with the full transcript

#6820: How Claude Code's Slash Loop Really Works

Corn
Picture it. You've pushed a branch, CI is grinding away, and every ten minutes you tab over and type the same sentence into Claude Code. Is it green yet. Is it green yet. Daniel wants the proper way out of that, which is slash loop, as the latest documentation describes it. How you drive it, whether you can hand it your own prompt, and whatever else is hiding in there. Last time, in Running an Agentic Loop to Drain a Queue, slash loop got two lines and a verdict. Today it gets the whole episode.
Herman
Two lines and a verdict, and the verdict was "a clock". I stand by it. But a clock is the right tool for a surprising number of jobs, and it has more dials than people notice. First fact: slash loop is not a built-in command. It's a bundled skill, shipped inside Claude Code, and that matters later because skills have rules about which other skills they're allowed to call.
Corn
A prompt wearing a command's coat.
Herman
Pretty much. And both of its arguments are optional, which gives you three shapes. Interval plus a prompt is the plain one: "slash loop five minutes, check whether the deploy finished". Fixed schedule. Prompt with no interval is the interesting one, because then Claude chooses the gap itself. And with no prompt at all you get a built-in maintenance routine, or your own, which we'll get to.
Corn
Start with the plain one. What can I actually type for the interval?
Herman
You can lead with it, like thirty minutes, or trail it as a clause, "every two hours". Units are seconds, minutes, hours and days. Seconds round up to a minute, because underneath this is cron, and cron doesn't do anything finer than a minute. Minimum is one minute.
Corn
So "slash loop thirty seconds" is a lie.
Herman
A polite one. It becomes one minute. And intervals that don't divide cleanly, say seven minutes or ninety minutes, get rounded to the nearest clean cron step, and Claude tells you what it picked. So it does turn your interval into a real cron expression, schedules it, and reports back the cadence and a job ID.
Corn
Which means the seven minutes I asked for might be eight.
Herman
Might be ten, who knows. If the number matters, pick one that divides evenly. Fifteen, thirty, an hour.
Corn
Fine. Now the one I actually want to understand. No interval. Who's in charge of the clock then?
Herman
Claude. After every iteration it looks at what it saw and picks a delay somewhere between one minute and one hour, and it prints the delay and the reason at the end of the turn. Something like "build still running, checking again in four minutes". Under the hood it uses a tool called ScheduleWakeup, and the docs are blunt that you don't call that yourself. It shows up in the task list as a pending one-shot.
Corn
I'm not sure I want a model deciding how patient I am.
Herman
That's the trade, but think about what it buys you. With a fixed interval you pick one number for a job whose length you don't know. A build that finishes in six minutes, or in forty. Self-paced, Claude can check quickly while something's moving and back off when it's stuck. And it can end the loop on its own. When the work is done, it cancels its own wakeup. A fixed schedule never does that.
Corn
Hm. A fixed schedule sits there checking a finished build forever.
Herman
Until it expires, yes. Which is also why the omit-the-interval version is the one I'd reach for first. There's even a cousin of it. If you ask for a dynamic loop, Claude may skip polling altogether and use the Monitor tool, which runs a background command and feeds each line of output back to it as it appears. No clock at all. Each watch has a deadline, five minutes by default, thirty at the most.
Corn
So I'm handing over the stopwatch.
Herman
Would you trust it, though? Hand it your build and let it decide when to look?
Corn
For a build, yes. Worst case it looks too often and I lose a few cents. For a deploy to production I'd want a number I chose, so I could say why it looked when it did.
Herman
That's a fair line to draw. Fixed for anything you'd have to explain afterwards.
Corn
That sounds like it ought to be the answer to my queue episode, then.
Herman
Closer, anyway. For watching a log or a build, it's often cheaper than polling, my guess is because nothing wakes the model until something actually happens. For work that needs many turns of judgment, you still want a different tool. We'll get to the neighbours.
Corn
Now bare slash loop. Nothing after it. Does it just sit there?
Herman
It runs a maintenance prompt, in a fixed order. Continue any unfinished work. Then tend the pull request on your branch, so review comments, failed CI, merge conflicts. Then cleanup passes, bug hunts, simplification. All of it through the normal permission checks, so it can't do anything it couldn't do if you asked it by hand.
Corn
A tidy-up butler.
Herman
But you can replace the butler. Drop a file called loop dot md into the dot claude folder of your project, or into your home dot claude folder, and bare slash loop runs that instead. Project file wins over the user one. It's plain Markdown, and it's one default prompt, not a list of tasks. And the part I like: it's read again on every iteration, so you can edit it while the loop is running and the next pass picks up the change.
Corn
So I tune it live. Notice the build is slow, tell it to look at the test log too, save the file.
Herman
Yes. Limit of twenty-five thousand bytes, anything past that is cut. And if you type a prompt on the command line, loop dot md is ignored entirely. It only ever serves the bare form.
Corn
Daniel's real question, though. Can I loop my own prompt?
Herman
Yes, and there are two ways. Free text, which is just a sentence. Or a skill or slash command as the payload. "Slash loop twenty minutes slash review pr" followed by a pull request number, say. Each time it fires, it runs that skill.
Corn
Any slash command?
Herman
No, and this is the gotcha I'd flag. Only skills Claude is allowed to invoke on its own will fire. Built-in commands like permissions, model or clear don't. Skills marked as not invokable by the model don't, and that includes some bundled ones. MCP prompts don't. In all those cases the text just arrives as a plain message, and you get no error.
Corn
So it quietly does something else.
Herman
It quietly asks Claude to please consider the words "slash model". Which, you know, it'll give an opinion on.
Corn
Herman, did you just make a joke?
Herman
I make one every episode. You're just usually asleep.
Corn
Then what makes a good loop prompt? Because I'd guess the bad ones are the ones that say "keep an eye on things".
Herman
Same guess. Each iteration is a fresh pass, so the prompt has to carry everything. Say what to check, say what counts as good, and say what to do when nothing has changed. The docs' own loop dot md example does this: if CI is red, do this. If it's green and nothing's new, say so in one line. That last clause is the difference between a loop you can live with and a transcript you scroll through for an hour.
Corn
Quiet should be cheap and short.
Herman
And the prompt should say what finishes the job. "Stop looping when the pull request is merged" is a sentence a self-paced loop can actually act on. Corn, what would you put in yours? If you were setting one up this afternoon.
Corn
Honestly, something dull. "Check whether the release workflow finished. If it failed, show me the first failing step. If it passed, say passed and stop." Three sentences, and the last one's the exit.
Herman
That's a better prompt than most I've seen. The stop condition's in there.
Corn
Typed out, it's slash loop, space, then that sentence. No interval, so Claude paces itself. It starts, tells me the first delay and why, and waits.
Herman
And ten minutes in you notice it keeps reporting the same thing in three paragraphs.
Corn
Then I tell it, in plain words, to say only what changed. It doesn't need a new loop for that, does it?
Herman
For a typed prompt, I'd restart it. The loop dot md file is the one that updates live, because it's reread every pass. A prompt you typed on the command line is baked into the schedule. So there's a reason to put a long-running loop's instructions in the file and run it bare. Edit, save, done.
Corn
Slightly annoying that the version with the most convenience is the one you can't tweak.
Herman
Convenience for the first minute, yes. After that it's the file.
Corn
Well, let's hear from your mother. Mum, are you there?
Dorothy
Hello dear, it's your mother. It's Dorothy's Kitchen. I'm going to tell you about porridge, plain porridge, and I want you to take it seriously.
Herman
Mum! I'm taking it very seriously.
Dorothy
You need oats, and water, and a pinch of salt, and that is all. No sugar, sweetheart, not while I'm talking.
Corn
Is it the rolled oats, Mum, or the pinhead?
Dorothy
Now. You put the oats in the pot with the water and you stir. And you keep stirring, because the moment you turn your back it catches, and then it's all over, and there's a smell in the kitchen for a week.
Herman
Does the stirring have to be continuous?
Dorothy
The salt goes in at the end, and the butter goes in last of all, and the butter can turn on you if the pan's too hot. Things have gone wrong before. I would rather not say how.
Corn
Mum, hot as in medium heat, or hot hot?
Dorothy
Anyway. I had a nice bit of toast with mine this morning, and I've put the washing out, so mind you bring it in if it rains. Bye now, dear.
Herman
Lovely. Where were we, the cron side of this.
Corn
Lifecycle. How long does one of these actually live?
Herman
Not as long as you'd hope. Everything's tied to your session. Tasks only fire while Claude Code is running and idle. Close the terminal and they stop. Background the session and they carry on. If you come back with the resume or continue flags, it restores tasks that haven't expired, though not any fires you missed while it was shut, and a self-paced loop may need you to run slash loop again.
Corn
And the expiry. I've seen a few blog posts say seven days.
Herman
Those are stale. Recurring tasks now expire thirty days after you create them. On the last day one fires a final time and then it's deleted. Tasks created on older versions keep their old seven-day life. Also, there's a ceiling of fifty scheduled tasks per session, and each gets an eight-character ID.
Corn
Fifty. I've never been that organised, or that nervous.
Herman
Do you leave a loop running overnight with the lid closed, in practice? Would you trust it to still be there?
Corn
No. A loop on my laptop is a loop on a laptop that sleeps. If I need it at three in the morning it's not a loop job at all.
Herman
Timing has rules too. The scheduler checks every second, but it queues your prompt at low priority and only fires between turns, never in the middle of a response. If Claude is busy when a run comes due, it fires once when it's idle. No catch-up for each missed interval, so a half-hour of busyness doesn't give you six runs in a row.
Corn
Good. And I assume it isn't to-the-second punctual.
Herman
Recurring tasks run late by up to half the gap before the next one, capped at thirty minutes. A ten-minute loop might be up to five minutes late. An hourly one, up to thirty. It's deliberate scatter, so that everybody's loops don't hit the servers at the top of the hour.
Corn
And the five-minute loop?
Herman
That's the exception, and it's a nice one. Slash loop five minutes fires four minutes and forty-five seconds after the previous run, not five. Prompt caching has a five-minute lifetime. Fire at four forty-five and the conversation context is still warm, so you're not paying to re-read everything.
Corn
Fifteen seconds of margin for the cache. Somebody did the maths.
Herman
And it implies a cost point: a six-minute loop might be more expensive than a five-minute one, since the cache has gone cold by the time it runs. My guess, but that's how the mechanism reads.
Corn
Does it mind if I'm typing at the time? I'm usually in there editing something when it's due.
Herman
It waits for your turn to finish. Fires queue behind whatever's happening and run between turns. My guess is it feels like a message that arrives while you're busy, no more than that, and it won't interrupt a response halfway.
Corn
Fine by me. A loop that talks over me would be a short loop. Now stopping: I'll hit Escape.
Herman
Depends which kind you started. Self-paced, pressing Escape on an empty prompt while it's waiting cancels the pending wakeup, and you'll see a message saying so. A fixed-interval loop ignores Escape and Control-C both.
Corn
Of course it does.
Herman
You ask Claude. "Cancel the deploy check loop." Behind that are three tools. One creates a schedule from a five-field cron expression, one lists your tasks with their IDs and next run times, one deletes by ID. You can just say "what scheduled tasks do I have". And if you want the whole scheduler gone, there's an environment variable that disables it, along with slash loop.
Corn
So where does this stop being the right tool? Because a laptop-lid-closed loop is not much of a loop.
Herman
Right at the session boundary. If it has to run while the machine is off, you want the cloud version, which is what the slash schedule command now creates. They renamed routines to cloud scheduled tasks. It runs on Anthropic's infrastructure, from a fresh clone of your repo, laptop off. Triggers can be schedules, an API call or a GitHub event. The catch is a minimum interval of one hour.
Corn
So no every-five-minutes there.
Herman
No. For event-driven work the docs point you at Channels instead of polling. And if you want an unattended job you own, a GitHub Actions schedule trigger is the route they name.
Corn
And slash goal. People mix those up.
Herman
Different trigger. Slash loop starts a turn on a clock. Slash goal starts a turn when the last one ends. You write a completion condition, and after each turn a small fast model, Haiku by default, judges: met, not yet, or impossible. Evaluation tokens are billed on top. One goal per session. Tell it "or stop after twenty turns" and it won't run away.
Corn
So goal is for "keep working until it's done", loop is for "look again later".
Herman
A migration you're pushing through is a goal. Watching whether something somebody else is doing has finished, that's a loop.
Corn
What about the anti-patterns? I can think of two. Looping something that needs thinking, and looping something that needs to happen.
Herman
Add a third: looping without an exit. A fixed loop with a vague prompt is the most expensive way to produce the sentence "nothing changed". Docs' own list of good uses is short and honest. Poll a deployment. Babysit a pull request. Check a long build. A one-time reminder, which you can do by saying "in forty-five minutes, check whether the integration tests passed".
Corn
Reminders. I'd have put that last, and it might be my favourite.
Hilbert
...the whole eleven days, and Quigley's Alsatian was the only reason it worked. Duchess. Not mine, she was next door, but I'd come to an arrangement with him. Two pounds a week and a bag of Winalot over the wall on Fridays, and in return she barks at the van. The modem was ninety-nine pounds, mail order, from a firm in Reading. It said delivery in five to ten working days. I went to the front door every ten minutes. A kitchen timer on the hall table, wound by hand. Corn, you had a pop on the "p" in "polling" just now, I'll take it out. Anyway, Duchess barked at the van, but she also barked at the cat, the milkman and Quigley's own post, so I still had to go and look. I kept a ledger on the hall table. Pencil, because the hall was cold and the biro skipped. Van, cat, cat, van, child. Eleven days.
Herman
So the dog was a notification channel with a lot of noise on it. Every bark was a trigger, and then you still had to go and look, because a bark told you something happened and not what.
Hilbert
Four minutes forty-five seconds. That's clever, that is. Leaving the margin like that.
Corn
The timer was the clock and Duchess was the event, and you ran both, so you paid for both. The dog could have been the only one, if she'd been better at her job.
Hilbert
She wasn't. But the van came at ten past four every day. Eleven out of eleven. And the timer ran twenty minutes slow, that's the correction. I never wound it right.
Corn
So you were out at the door at four every day for a week and a half, whatever the timer said.
Hilbert
From the third day. Before that I wasn't looking at the ledger.
Herman
Which means the first two days were costing you something like a hundred checks, and the rest were nearly free.
Hilbert
Call it that. The hundred was mostly the cat.
Corn
Reasonable. Which leaves the question Daniel started with, the one nobody's landed yet. What should the first loop on your machine actually be?
Herman
One that's cheap when nothing's happening. I'd start self-paced, with a prompt that says what finished looks like, and let it work out how often to look. Late and rarely beats early and often, I think, for most jobs people actually have.
Corn
The van comes at ten past four. Check at four.
Herman
And if the thing you're waiting on has no ten past four, that's what the self-paced mode is for. It watches a few times, notices the pattern, and eases off.
Corn
Maybe. I'd bet it still checks the cat.
Herman
The cat is a risk.
Corn
Thanks to Hilbert Flumingtop for producing this one.
Herman
This has been My Weird Prompts. You'll find every episode at my weird prompts dot com.
Corn
We'll be back soon.

This episode was generated with AI assistance. Hosts Herman and Corn are AI personalities. It may contain errors: disclaimer · report an error