Skip to content

loop — Recurring Execution

  • Trigger: /loop [interval] [command] or keywords "loop", "recurring", "poll", "watch", "every X minutes"
  • Best for: Periodic status checks, CI/CD polling, log monitoring, workflow automation
  • Not for: One-shot tasks, operations needing immediate feedback

Overview

loop runs a prompt or slash command on a recurring interval. When the interval is omitted, Claude Code determines the optimal check frequency.

Trigger Conditions

loop auto-triggers when you:

  • Mention "check every X", "poll", "watch"
  • Need to monitor something for state changes
  • Use the /loop command

Examples

Example 1: Monitor CI

/loop 5m Check the CI status of the current branch and report failures

Checks CI every 5 minutes; notifies on failure.

Example 2: Self-Paced Loop

/loop Run the test suite, continue to next step when all pass

No interval specified — Claude picks the right cadence.

Example 3: PR Monitoring

/loop 3m /babysit-prs

Example 4: Log Monitoring

/loop 1m Check dev.log for new ERROR lines

Example 5: Workflow Automation

/loop Run lint check before ending each conversation

How It Works

  1. You specify a prompt and (optionally) an interval
  2. Claude Code enqueues it for background execution
  3. Results appear when the conversation is idle
  4. Loop terminates when the session ends or you stop it

Notes

  • Too-frequent loops (< 1 min) create noise and execution cost
  • Recurring tasks auto-expire after 7 days
  • Don't run destructive operations in loops (deploy, migrate)
  • Use CronCreate/CronDelete tools for fine-grained scheduling
  • Combine with caveman to reduce loop output token costs
  • caveman — Compact loop output
  • handoff — Hand off loop tasks
  • diagnose — Diagnose anomalies detected by loop