What is the /loop
command in Claude Code and how can you use it?
How do you use the /loop command
The /loop command is one tool in Claude that helps you schedule things see https://code.claude.com/docs/en/scheduled-tasks [1]
Lets give it a quick test
|
> /loop 1m Tell me the time in MST, EST,
and UTC |
What is this going to
do?
It’s going to run this
prompt every minute
It just keeps running
every minute.
I can still interact with Claude while this is running
|
> What is the temperature in Tokyo
please access web sites to get this info |
Now while you are interacting with Claude
The loop command is syntactic sugar for a crontool built into Claude (which I will not go over here). But simply put it will run a prompt or a skill on a schedule.
You can still interact with Claude the /loop task you set run in the background.
To stop it you can give it a prompt to stop it like
|
>
stop the loop |
The loop it not a perfect cron job. It will not run at the set intervals… It will try to run when it should but if Claude is currently thinking and its due to run it will respond immediately after Claude is done thinking.
Now its important to
know that even if the current loop is delayed it will not shift the loops. So for example if you say 30m and you start
it exactly at 1:00 PM. It will run at
1:30 PM , 2:00 PM, 2:30PM etc.
And if at 1:30 PM it gets delayed by 5 min due to Claude thinking it will not
push out the next loop to 2:05 PM it will still be 2:00 PM (unless Claude is
thinking then too)
Looping with an end in mind
You can also tell it to loop until…
So I could run something like this.
|
> /loop 1m Tell me the time in MST, EST,
and UTC for 5 times and each time tell me which iteration I am on |
It ran 5 times and stopped.
Other ideas you could
do…
|
> /loop 10m /review-pr 1234 > /loop 5m check deployment status > /loop 2h give me a quick health report of the project: - Open PRs and their status - Failing CI jobs - Stale branches - Recent test failures |
Also you do not have to put in a time. You can let Claude figure out a good interval so
|
> /loop check the deploy |
I ran this, as a test, with no timer set
|
> /loop 1m Tell me the time in MST, EST,
and UTC |
It thought about it and decided to set the interval to 60 seconds based on what I had done before.
Can I change the interval while its running? Let me try
|
> Change the loop to 5 min |
Looks like it worked,
but it could not change it until after the next loop. 😊 Nice!
Get a list of active loops
If you want to know which loops are running just ask it
|
> List my active loops |
Nice!
That is it for /loops a pretty useful basic tool. However, this has gotten me thinking I need
to research more about cron scheduling in Claude.
References
[1] Automation Run prompts on a
schedule
https://code.claude.com/docs/en/scheduled-tasks
Accessed 05/2026
No comments:
Post a Comment