Claude Code /loop Is Insanely Useful (5 Ways I Use It)

Study Guide

Overview

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.

What Is the /loop Command?

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.

Basic Syntax

  • Recurring task: /loop [interval] [prompt or command]
  • With custom commands: /loop [interval] /custom-command [parameters]
  • One-time reminder: /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.

Important Limitations

  • Maximum of 50 cron jobs per session
  • Jobs automatically expire after 3 days
  • Jobs are session-bound — closing the terminal or shutting down your machine stops all jobs
  • For persistent scheduled tasks, the Claude Desktop app's CoWork > Schedule Tasks feature is more appropriate
  • Uses your local time zone for scheduling

Managing Cron Jobs

  • List jobs: Ask Claude to "list all current cron jobs"
  • Update a job: Provide the job ID and new schedule — Claude cancels the old job and creates a new one
  • Cancel a job: Provide the job ID and ask Claude to cancel it

Each cron job receives a unique ID that you can reference for updates or cancellation.

Five Practical Use Cases

1. Auto-Update Memory Files (CLAUDE.md)

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.

2. Auto-Update Public Documentation

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.

3. Test Suite Watchdog

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.

4. UI Design System Enforcement

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.

5. Automated Pull Request Review

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.

Pro Tip: Init Loops Custom Command

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.

Key Takeaways

  • The /loop command transforms Claude Code from an on-demand assistant into an always-on development partner
  • Best suited for tasks you know you should do but often forget: updating docs, running tests, reviewing PRs
  • Separate terminal sessions per job can help organize output, but all jobs can run in a single session
  • Combine with custom slash commands and sub-agents for powerful automated workflows
  • Use an init-loops custom command to quickly restore your automation setup each session
YouTube