The /loop command in Claude Code is a scheduling tool that lets you run prompts automatically on a recurring interval or as one-time reminders. Under the hood, it creates cron jobs that execute within your Claude Code session, enabling hands-off automation of repetitive development tasks.
According to the Claude documentation, /loop is a scheduling tool that can run prompts repeatedly, check statuses, or set one-time reminders using Claude Code sessions. It works by assigning a cron job management tool to the agent, which Claude uses to create and manage scheduled tasks.
/loop [interval] [prompt or command]/loop [interval] /custom-command [parameters]/loop [time] [reminder message]Intervals can be natural language like "every 5 minutes," "every 2 hours," or even complex schedules like "every weekday at 9 AM." Claude intelligently interprets these into proper cron specifications.
Each cron job receives a unique ID that you can reference for updates or cancellation.
Keep your CLAUDE.md or agents.md files current without manual intervention. As you add features throughout the day, the scheduled job scans the codebase and updates the memory file accordingly.
Example: /loop every 30 minutes Ensure the CLAUDE.md file is up to date. Scan the codebase for any new features and update accordingly.
Similar to memory file updates, but focused on user-facing documentation. If your app includes a docs page, this keeps it synchronized with actual application features — solving the common problem of documentation falling behind code changes.
Example: /loop every 2 hours Review the codebase for new features and update the public-facing documentation accordingly.
Automatically run your test suite on a schedule and have Claude address any failures. This catches regressions without requiring you to remember to run tests after every change. You can also ask Claude to add new tests as functionality is added.
Example: /loop every 2 hours Please execute the test suite and address any issues.
Pair /loop with a custom slash command and a sub-agent to periodically audit your UI against a design system. The presenter uses a design system folder with component specs, foundation rules, and pattern guidelines, then a reviewer agent checks alignment.
Example: /loop every hour /review-refactor-ui
This invokes a custom command that triggers a UI design system reviewer sub-agent, ensuring new features stay visually consistent with the rest of the application.
Use /loop to periodically pull open PRs via the GitHub CLI, spawn deep-dive agents for each one, check for merge conflicts, assess safety, and generate a written report identifying low-hanging fruit — PRs that are safe to merge immediately.
Example: /loop every 5 minutes Use the GitHub CLI to pull all open pull requests. Kick off a deep dive agent for each PR. Check for merge conflicts, determine if safe to merge, and write a report to pull-request-report.md.
Rather than manually setting up each cron job every session, create a custom command file (e.g., .claude/commands/init-loops.md) containing all your loop commands. Then run /init-loops once at the start of each session to spin up all your automated jobs in a single prompt.
This also makes it easy to update or remove jobs — everything is managed in one file rather than scattered across terminal sessions.
/loop command transforms Claude Code from an on-demand assistant into an always-on development partner