Setting Up Scheduled Tasks with /loop for Recurring Monitoring in Claude Code

Use the /loop skill in Claude Code to create session-scoped cron jobs that auto-expire after 3 days, with commands like /loop 5m "check status" and cancellation via cron cancel <job-id>.

The shanraisshan/claude-code-best-practice repository documents a powerful built-in skill for automating recurring workflows. Setting up scheduled tasks with /loop for recurring monitoring allows you to run commands at fixed intervals without leaving your Claude Code session, making it ideal for deployment checks, periodic reporting, or continuous integration monitoring.

How the /loop Skill Works

The /loop skill is implemented as a wrapper around an internal CronCreate tool, as detailed in implementation/claude-scheduled-tasks-implementation.md. When you invoke /loop <interval> "<command>", the system translates your interval into a standard cron expression and registers a background job.

The parsing logic converts shorthand like 1m into */1 * * * *, with one minute being the minimum granularity. Each job created through this mechanism is session-scoped, meaning it resides only in memory and automatically disappears when your Claude Code session terminates. For safety, all recurring jobs enforce a hard 3-day auto-expiration limit to prevent runaway background processes.

Command Execution Flow

When a scheduled tick fires, the command executes in a separate subprocess. The output streams back to Claude as a standard user prompt, which triggers the normal hook event lifecycle—including UserPromptSubmit, Stop, and sound notifications. This design ensures that scheduled tasks integrate seamlessly with existing Claude Code workflows and side-effects.

Creating Recurring Monitoring Tasks

To start monitoring, use the /loop command followed by an interval and the command string. Intervals support minute-level granularity using the m suffix.

Monitor system status every minute:

/loop 1m "date"

Run a Claude skill every 5 minutes:

/loop 5m /simplify

Check deployment status every 10 minutes:

/loop 10m "check deploy status"

Each invocation returns a unique job ID that you will need for cancellation. The repository's README.md references these examples in the "Scheduled Tasks" section as canonical patterns for recurring monitoring.

Managing and Canceling Jobs

Although jobs auto-expire after 72 hours, you can manually terminate them earlier using the cron cancel command followed by the job ID displayed at creation time.

cron cancel abc123

This immediate cancellation removes the job from the session's in-memory cron table. According to the implementation guide in implementation/claude-scheduled-tasks-implementation.md, no cleanup is required on your filesystem because the scheduler never persists jobs to disk.

Configuration and Limitations

Administrators can disable the scheduled task functionality entirely by setting the environment variable defined in best-practice/claude-settings.md. Set CLAUDE_CODE_DISABLE_CRON to globally prevent the CronCreate tool from accepting new jobs.

Key constraints to remember:

  • Session-bound: Jobs vanish when you close Claude Code
  • 3-day maximum: Hard limit prevents indefinite scheduling
  • One-minute floor: Sub-minute intervals are not supported
  • Subprocess isolation: Each tick spawns a new process

Summary

  • The /loop skill creates temporary cron jobs via the internal CronCreate tool
  • Jobs auto-expire after 3 days and disappear when the session ends
  • Use /loop <interval>m "<command>" to schedule recurring monitoring
  • Cancel active jobs manually with cron cancel <job-id>
  • Disable globally via CLAUDE_CODE_DISABLE_CRON in best-practice/claude-settings.md

Frequently Asked Questions

How long can a /loop task run in Claude Code?

All /loop tasks automatically expire after 3 days (72 hours) as a safety mechanism to prevent runaway processes, regardless of whether the Claude Code session remains active.

What happens to my scheduled tasks when I close Claude Code?

Because jobs are session-scoped and stored only in memory, they immediately terminate and disappear when your Claude Code session ends. They do not persist across restarts.

Can I schedule tasks to run more frequently than every minute?

No. The /loop skill enforces a one-minute minimum granularity. Intervals like 30s are not supported, as the cron translation logic in implementation/claude-scheduled-tasks-implementation.md maps inputs to standard cron expressions with minute-level precision.

How do I disable scheduled tasks entirely in my Claude Code environment?

Set the CLAUDE_CODE_DISABLE_CRON environment variable documented in best-practice/claude-settings.md. When this flag is present, the CronCreate tool will reject all new /loop requests.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →