Claude Code /loop: Run Recurring Tasks on Autopilot
Source: Dev.to
Overview
/loopschedules recurring prompts in Claude Code sessions without requiring cron jobs or separate monitoring tools.- Syntax supports flexible interval placement: leading (
/loop 5m task), trailing (task every 2h), or defaults to 10 minutes. - Loops auto‑expire after 7 days as a safety mechanism to prevent indefinite API‑credit consumption.
/loopruns within the active session context, giving Claude access to the codebase, git history, and tools for intelligent problem‑solving.- One‑line setup requires no script writing, configuration, or permission management—unlike traditional cron jobs.
Claude Code keeps shipping features that blur the line between coding assistant and development infrastructure. The latest one that changed how I work is /loop—a session‑scoped scheduler that lets you run any prompt or command on a recurring interval, right inside your terminal.
If you’ve ever left a terminal tab open just to keep checking whether a build passed, a deploy went through, or a PR got approved—this is the feature you didn’t know you needed.
What /loop Actually Does
The /loop command schedules a recurring prompt inside your active Claude Code session. You give it an interval and a task, and Claude fires that prompt automatically in the background while you keep working.
“
/loop 5m make sure this PR passes CI.” — Noah Zweben, Claude Code (Anthropic)
That one line sets up a recurring check every five minutes. No cron tab. No separate monitoring tool. Just Claude watching your CI pipeline while you move on to the next thing.
Syntax and Defaults
The syntax is deliberately simple. You can put the interval at the beginning, at the end, or omit it entirely.
| Style | Example |
|---|---|
| Leading interval | /loop 5m check if the deployment finished |
| Trailing interval | /loop check the build every 2h |
| No interval (defaults to 10 min) | /loop check the build |
Supported units:
s– secondsm– minutesh– hoursd– days
You can also loop over other Claude Code commands. For example:
/loop 20m /review-pr 1234runs a PR review every 20 minutes. Any slash command or skill can be the target.
How Long Do Loops Run?
Recurring tasks run for up to 7 days before auto‑expiring. The task fires one final time, then deletes itself. This safety bound prevents a forgotten loop from running indefinitely and burning through API credits.
- Need longer? Cancel and recreate the loop before it expires.
- Need durability? Use Claude Code’s Desktop scheduled tasks or GitHub Actions workflows with schedule triggers—these survive restarts and run without an active terminal.
How It Differs from Cron Jobs
| Aspect | Cron Job | /loop |
|---|---|---|
| Execution context | Isolated script, no awareness of your current codebase or session state. | Runs inside an active Claude Code session, with full access to the project tree, git history, open PRs, and all session tools (bash, file editing, web search, etc.). |
| Setup effort | Write script, configure crontab, handle logging, manage permissions. | One line typed into your terminal. |
| Intelligence | Executes blindly. | Claude can read error logs, identify problems, propose fixes, or even apply them. |
Practical Use Cases
| Use case | Example /loop command |
|---|---|
| Monitor CI/CD builds | /loop 5m check if the CI build passed and summarize any failures |
| Watch for PR updates | /loop 15m check PR #42 for new comments or review requests |
| Poll deployment status | /loop 3m check the Vercel deployment status for the latest commit |
| Run periodic code‑quality checks | /loop 1h run the linter on changed files and report any new warnings |
| Check server health | /loop 10m curl the health endpoint and let me know if anything looks wrong |
| Monitor error rates | /loop 30m check the error logs for the last 30 minutes and summarize any new patterns |
| Babysit webhook integrations | /loop 5m check the webhook logs for any failed deliveries (e.g., after updating a Shopify webhook handler) |
Tips for Effective Loops
- Keep the prompt focused. One thing per loop yields reliable results. If you need multiple checks, create multiple loops.
- Choose appropriate intervals. Match the interval to the expected pace of the thing you’re watching (e.g., 3‑5 min for active deploys, 15‑30 min for PR reviews, 1 h for code‑quality sweeps).
- Remember it is session‑scoped. Closing your terminal kills all loops. Keep the session alive for important loops, or migrate to a durable scheduler (Desktop tasks, GitHub Actions) if you need persistence.
Claude Code’s /loop brings the power of a scheduler directly into your development workflow, letting you stay focused while the assistant handles the repetitive monitoring tasks.
My Setup
I run RAXXO Studios as a one‑person operation—a Next.js SaaS app, a Shopify store with over 100 products, and a content pipeline. That means I am deploying, monitoring, and debugging across multiple systems simultaneously.
Most‑used loop
A simple Vercel deploy watcher:
/loop 3m check the latest Vercel deployment and tell me if it succeeded or failedI kick it off after pushing to my dev environment and forget about it. Claude pings me when it is done or when something breaks.
Second most common loop
Webhook monitoring after I change any API endpoint.
Shopify webhooks can fail silently, and a 5‑minute loop checking delivery status has saved me from shipping broken integrations to production more than once.
/loop is not a replacement for proper monitoring infrastructure, but for a solo developer who needs to keep multiple plates spinning, it is the fastest way to add a set of eyes on something without leaving your terminal.
This article contains affiliate links. If you sign up through them, I earn a small commission at no extra cost to you.