Claude Code /loop: Background Scheduling for Dev Monitoring
Claude Code's /loop command schedules prompts to run in the background at flexible intervals (e.g., every 5m) for monitoring deploys/PRs, with low-priority execution, 3-day auto-expiry, and up to 50 tasks per session.
Set Up Recurring and One-Off Tasks Effortlessly
Use the built-in /loop command to schedule any prompt or slash command on repeat without installing extras. Syntax is flexible: place interval first (/loop 5m check deployment status) or last (/loop check build every 2h). Defaults to 10m if unspecified. Supported units: s, m, h, d—seconds round to nearest minute, uneven intervals (e.g., 7m, 90m) adjust to clean cron equivalents, with Claude confirming the exact cadence and job ID.
Loop other commands too: /loop 20m /pr-review auto-runs PR checks every 20 minutes. For one-offs, say "Remind me at 3pm to push release" or "In 45m, check integration tests"—Claude parses time in your local timezone, schedules, runs once, then self-deletes.
Full cron control available: standard 5-field expressions like * * * * * (every minute), */5 * * * * (every 5m), or 9 * * 1-5 (9am weekdays). Up to 50 tasks per session.
Non-Interruptive Execution with Built-in Safeguards
Tasks queue at low priority, firing every second-check between your turns—never mid-response. If busy, they wait until idle, skipping multiples (no catch-up for missed fires). Local timezone handling avoids UTC confusion; jitter prevents thundering herd: recurring tasks delay up to 10% of period (max 15m, consistent per ID), one-shots up to 90s early at :00/:30—avoid by scheduling off-peak minutes (e.g., 9:03 * * * *).
Recurring tasks auto-expire after 3 days with a final run, preventing forgotten infinite loops. Manage via natural language: "List scheduled tasks" shows all with 8-char IDs; "Cancel deploy-check job" removes it. Underlying tools: cron-create, cron-list, cron-delete. Disable entirely with env var CLAUDE_CODE_DISABLE_CRON=1 for CI.
Session-Scoped for Daily Wins, Not Production Criticals
Perfect for short-term monitoring (deploy babysitting, build checks) while coding—tasks survive idle but vanish on terminal close/restart. For durable/long-running needs (>3 days, survives restarts), switch to GitHub Actions (schedule triggers) or desktop tasks. Trade-off: session-only keeps it lightweight and safe, delivering QoL boost like hands-free "check every 10m and notify" without workflow disruption.