Claude Code Scheduled Tasks

Complete Beginner-Friendly Chapter — Run Prompts on a Schedule
Big idea: Scheduled tasks let Claude Code run a prompt automatically at a later time or repeatedly on a schedule. They are useful for polling deployments, watching a pull request, checking a long-running build, or creating a one-time reminder.
Important: Scheduled tasks described in this chapter are session-scoped unless you use a durable alternative such as Cloud Routines, Desktop scheduled tasks, or GitHub Actions.

1. What Are Scheduled Tasks?

A scheduled task tells Claude Code: “Run this prompt later or run it repeatedly.”

The current Claude Code documentation describes two closely related ways to do this inside a session:

  • /loop — the quickest way to repeat a prompt while the session stays open.
  • Scheduled tasks / cron tools — tasks Claude can create, list, and cancel, including one-time reminders.
PromptScheduleWaitClaude runsResult

2. Why Scheduled Tasks Are Useful

Deployment polling: “Check whether the deployment finished.”
PR babysitting: “Check CI and review comments every 10 minutes.”
Build monitoring: “Check the long-running integration build.”
Reminder: “Remind me at 3 PM to push the release branch.”
Maintenance: Repeatedly continue unfinished work or perform cleanup passes.

3. The Three Scheduling Options

OptionRuns onMachine must be on?Open session?Local files?Minimum interval
CloudCloud / Anthropic-managed by defaultNoNoNo — fresh clone1 hour
DesktopYour machineYesNoYes1 minute
/loopYour machineYesYesYes1 minute
Rule of thumb: Use Cloud scheduling when the work should run reliably without your computer. Use Desktop scheduling when local files/tools are required. Use /loop for quick polling during an active session.

4. The Fastest Method: /loop

/loop is a bundled skill designed for repeated work.

4.1 Fixed interval + prompt

/loop 5m check if the deployment finished and tell me what happened

This asks Claude to run the prompt repeatedly on a fixed cadence.

4.2 Prompt only

/loop check the deploy

When no interval is supplied, Claude dynamically chooses the delay between iterations.

4.3 Bare /loop

/loop

A bare /loop uses the built-in maintenance prompt, or your custom loop.md if one exists.

4.4 Run a skill repeatedly

/loop 20m /review-pr 1234

A scheduled fire can invoke skills only when Claude is allowed to invoke them on its own.

5. Fixed Intervals

You can write the interval before the prompt or as a natural-language clause.

ExampleMeaning
/loop 5m check the deployRun every 5 minutes.
/loop 30m check CIRun every 30 minutes.
/loop 2h check the PRRun every 2 hours.
/loop check CI every 2 hoursInterval can also appear as a clause.

Supported interval units are:

s = secondsm = minutesh = hoursd = days
Seconds are rounded up to the nearest minute because cron has one-minute granularity. Intervals that do not map cleanly to cron, such as 7m or 90m, are rounded to a suitable interval and Claude tells you what it selected.

6. Dynamic /loop Scheduling

If you omit the interval, Claude chooses a delay dynamically after each iteration.

The delay is between 1 minute and 1 hour, based on what Claude observes.

  • Shorter waits when a build is finishing.
  • Shorter waits when a PR is active.
  • Longer waits when nothing is pending.
/loop check whether CI passed and address any review comments

After each iteration Claude reports the chosen delay and why it selected it.

If the Monitor tool is available, Claude may use it for a dynamic loop. Monitor can run a background script and stream output instead of repeatedly polling, which can be more responsive and token-efficient.

7. The Built-In Maintenance Prompt

When you run:

/loop

Claude uses a built-in maintenance prompt unless you provide a custom loop.md.

The maintenance behavior works roughly in this order:

  1. Continue unfinished work from the conversation.
  2. Tend to the current branch's pull request — review comments, failed CI, and merge conflicts.
  3. When nothing else is pending, perform cleanup such as bug hunts or simplification.
Claude does not start unrelated new initiatives. Irreversible actions such as pushing or deleting proceed only when they continue something the existing transcript already authorized.

8. Customize /loop with loop.md

You can replace the default maintenance prompt with your own instructions.

Claude Code checks these locations:

FileScope
.claude/loop.mdProject-level. Takes precedence.
~/.claude/loop.mdUser-level. Applies to projects without a project-level file.

Example:

Check the release/next PR. If CI is red, pull the failing
job log, diagnose, and push a minimal fix. If new review
comments have arrived, address each one and resolve the
thread. If everything is green and quiet, say so in one line.

The file is plain Markdown. You write it as if you were typing the /loop prompt directly.

Edits to loop.md take effect on the next iteration. Keep the file concise; content beyond 25,000 bytes is truncated.

9. How to Stop a /loop

For a self-paced /loop waiting for its next iteration, press Esc.

There is an important distinction:

Task typeEscCancellation behavior
Self-paced /loopStops the pending wakeup.Claude can also stop itself when complete.
Task created by asking Claude directlyNot affected.Cancel/delete the scheduled task.

If an iteration finishes without rescheduling or stopping, Claude Code schedules a fallback wakeup of about 20 minutes and ends the loop if the next iteration also does not reschedule.

10. One-Time Reminders

For a one-shot reminder, use natural language instead of /loop.

remind me at 3pm to push the release branch
in 45 minutes, check whether the integration tests passed

Claude schedules a single-fire task that deletes itself after running.

11. Manage Scheduled Tasks

You can manage tasks using natural language.

what scheduled tasks do I have?
cancel the deploy check job

Under the hood, Claude Code uses three cron tools:

ToolPurpose
CronCreateCreate a scheduled task. It accepts a 5-field cron expression, prompt, and recurrence/one-shot behavior.
CronListList scheduled tasks with IDs, schedules, and prompts.
CronDeleteCancel a task by ID.

Each scheduled task has an 8-character ID. A session can contain up to 50 scheduled tasks at once.

12. What Happens When a Task Fires?

Scheduler checks Task becomes due Queued low priority Claude becomes idle Prompt runs
  • The scheduler checks every second for due tasks.
  • Scheduled prompts are queued at low priority.
  • A task fires between turns, not while Claude is in the middle of a response.
  • If Claude is busy, the task waits until the current turn ends.
  • Times are interpreted in the local timezone.
For example, 0 9 * * * means 9:00 AM in the local timezone where Claude Code is running — not UTC.

13. Jitter: Why the Exact Minute Can Move

Claude Code adds deterministic timing offsets to reduce many sessions hitting the API at exactly the same wall-clock moment.

TaskJitter behavior
Recurring taskMay fire up to 30 minutes after the scheduled time, or up to half the interval for jobs more frequent than hourly.
One-shot at :00 or :30May fire up to 90 seconds early.

The offset is derived from the task ID, so the same task gets the same offset.

If exact timing matters, choose a minute that is not :00 or :30. For example, use 3 9 * * * instead of 0 9 * * *.

14. Seven-Day Expiry

Recurring session-scoped tasks automatically expire 7 days after creation.

The task fires one final time and then deletes itself.

This prevents a forgotten recurring task from running forever. If you need something to last longer, recreate it before expiry or use a durable scheduling system such as Routines or Desktop scheduled tasks.

15. Cron Expression Basics

CronCreate accepts a standard five-field cron expression:

minute hour day-of-month month day-of-week
ExpressionMeaning
*/5 * * * *Every 5 minutes
0 * * * *Every hour on the hour
7 * * * *Every hour at 7 minutes past
0 9 * * *Every day at 9 AM local time
0 9 * * 1-5Weekdays at 9 AM local time
30 14 15 3 *March 15 at 2:30 PM local time

Supported field syntax

  • * — wildcard
  • 5 — single value
  • */15 — step
  • 1-5 — range
  • 1,15,30 — list

Day-of-week uses 0 or 7 for Sunday through 6 for Saturday.

Extended cron syntax such as L, W, ?, and aliases such as MON or JAN are not supported.

16. Day-of-Month + Day-of-Week Behavior

When both the day-of-month and day-of-week fields are constrained, a date matches if either field matches. This follows standard vixie-cron semantics.

17. Session Scope — The Most Important Concept

Scheduled tasks belong to the current Claude Code session/conversation.

Current sessionCreate taskTask lives hereNew sessionOld session tasks don't carry over normally

Tasks can be restored when you resume a session with --resume or --continue, subject to the documented exceptions.

SituationWhat happens
Claude Code is running and idleTasks can fire.
Terminal/session closesSession-scoped tasks stop firing.
Claude is busyDue task waits until the current turn ends.
Missed multiple intervalsNo catch-up for every missed fire; it fires once when Claude becomes idle.
--resume / --continueSome CronCreate tasks are restored if still valid.
Self-paced /loopNot restored; start it again.

18. No Catch-Up Behavior

Suppose you schedule a task every 10 minutes, but Claude is busy for 35 minutes.

What you might expect: 3 missed executions run afterward.
What actually happens: The task fires once when Claude becomes idle. Missed intervals are not replayed individually.

19. /loop vs CronCreate

Feature/loopScheduled task via CronCreate
Quick interactive setupExcellentUsually indirect / via Claude
Repeat promptYesYes
One-time reminderNot the primary methodYes
Natural-language managementYesYes
Task IDManaged as loop/task8-character ID
Long-term persistenceNo; seven-day session scheduling limits applySame session-scoped constraints

20. When NOT to Use Scheduled Tasks

Need event-driven behavior?
Use Channels when an external system can push an event into a running session instead of repeatedly polling.
Need work to keep moving toward a condition?
Use /goal rather than repeatedly running a fixed prompt.
Need durable unattended automation?
Use Routines, Desktop scheduled tasks, or GitHub Actions.

21. Scheduled Tasks vs Channels vs Goals

FeatureScheduled TasksChannelsGoals
TriggerTime interval / clockExternal eventProgress toward a condition
Typical usePoll CI, PR, deploymentReceive Telegram/Discord/etc. eventKeep working until condition is reached
PollingYesNo — event-drivenNot the main idea
Best mental model“Check again later.”“Tell me when something happens.”“Keep going until this is true.”

22. Practical Examples for Developers

Example A — Deployment Check

/loop 10m check whether the staging deployment finished.
If it failed, inspect the failure and summarize the likely cause.

Example B — Pull Request Watch

/loop 15m check the current PR for new review comments,
failed CI, or merge conflicts. Tell me only if something changed.

Example C — Integration Tests

in 45 minutes, check whether the integration tests passed

Example D — Daily Local Development Check

/loop 1d inspect the current branch for unfinished work
and summarize anything that still needs attention

23. Next.js / Frontend Workflow Example

/loop 10m check the staging frontend deployment.
If the build failed, inspect the build output and identify
the first actionable error.

This can be useful when you are actively working on a frontend deployment and want Claude Code to periodically check progress.

24. Spring Boot Backend Workflow Example

/loop 10m check whether the Spring Boot deployment is healthy.
Inspect the available logs and report startup failures,
database connection errors, or failing health checks.
Scheduled tasks are a scheduling mechanism. They do not automatically turn Claude into an always-on production monitoring system. For durable production automation, use an appropriate external scheduler or CI system.

25. Disable Scheduled Tasks

You can disable the scheduler entirely with:

CLAUDE_CODE_DISABLE_CRON=1

When disabled:

  • Cron tools are unavailable.
  • /loop becomes unavailable.
  • Already scheduled tasks stop firing.

26. Common Mistakes

MistakeWhy it is a problemBetter approach
Assuming tasks run after closing the terminalSession-scoped tasks need Claude Code running.Use Desktop/Cloud/Routines/GitHub Actions for durable work.
Expecting exact :00 timingScheduler jitter can shift execution.Use a non-:00/:30 minute when timing matters.
Expecting missed runs to catch upMissed intervals are not replayed individually.Design the prompt to check current state.
Creating an endless loopRecurring tasks expire after seven days.Recreate or use durable scheduling.
Using polling for an eventRepeated prompts can waste tokens.Prefer Channels when an external event can be pushed.
Using /loop for a conditionFixed polling is not always the best model.Consider /goal.

27. Best Practices

  1. Make prompts state-aware: ask Claude to inspect the current state instead of assuming every run is a new task.
  2. Prefer event-driven automation: if an external system can notify Claude directly, avoid unnecessary polling.
  3. Use clear stop conditions: tell Claude what “done” means.
  4. Keep recurring prompts focused: avoid asking the loop to start unrelated initiatives.
  5. Remember the seven-day limit: session-scoped recurring tasks are not a permanent scheduler.
  6. Choose the right scheduler: local work, cloud work, and CI automation have different requirements.

28. Quick Decision Tree

Do I need to run something repeatedly?
→ Yes → Can it be a quick active-session poll? → Use /loop.
Do I need a one-time reminder?
→ Describe it naturally: “remind me at 3pm …”
Must it survive independently of my session?
→ Use Cloud Routines, Desktop scheduled tasks, or GitHub Actions.
Can another system push the event?
→ Consider Channels instead of polling.
Should Claude keep working until a condition becomes true?
→ Consider /goal.

29. Interview / Revision Questions

  1. What problem do Claude Code scheduled tasks solve?
  2. What is the difference between /loop and a one-time reminder?
  3. What happens when you run a bare /loop?
  4. How does dynamic interval selection work?
  5. What is loop.md?
  6. Where can loop.md be located?
  7. What are CronCreate, CronList, and CronDelete?
  8. What is the maximum number of scheduled tasks in a session?
  9. What is cron jitter?
  10. How long do recurring session-scoped tasks live?
  11. What happens if Claude is busy when a scheduled task becomes due?
  12. Does Claude replay every missed interval?
  13. What happens when a new conversation starts?
  14. When should you use Channels instead of polling?
  15. When should you use Routines, Desktop scheduled tasks, or GitHub Actions?

30. Practice Exercises

Exercise 1: Create a loop that checks a deployment every 10 minutes.
Exercise 2: Create a one-time reminder for 30 minutes later.
Exercise 3: Create a loop.md for monitoring a release PR.
Exercise 4: Write cron expressions for daily 9 AM, weekdays 9 AM, and every 15 minutes.
Exercise 5: Decide whether Scheduled Tasks, Channels, Goals, or GitHub Actions is the best fit for five real-world automation scenarios.

31. Cheat Sheet

NeedUse
Repeat every 5 minutes/loop 5m <prompt>
Let Claude choose the interval/loop <prompt>
Default maintenance loop/loop
Custom default loop.claude/loop.md or ~/.claude/loop.md
One-time reminderNatural language: “remind me …”
List tasks“what scheduled tasks do I have?”
Cancel a task“cancel the … job”
Disable schedulerCLAUDE_CODE_DISABLE_CRON=1
Durable cloud scheduleCloud Routines
Durable local scheduleDesktop scheduled tasks
CI scheduleGitHub Actions
External event triggerChannels
Work toward a condition/goal

32. Memory Map

/loop Fixed or dynamic interval One-shot reminder CronCreate CronList CronDelete Local timezone Jitter 7-day expiry Session scoped Routines for durable cloud work Channels for events Goals for conditions

33. Final Takeaway

Remember this:

Scheduled Tasks = “Run this prompt later or repeatedly.”
/loop = the fastest active-session polling mechanism.
Natural-language reminders = one-time tasks.
Cron tools = the underlying scheduling interface.
Jitter = timing may move slightly.
Seven-day expiry = recurring session tasks are temporary.
Channels = better when an external event can push information.
Goals = better when Claude should keep working toward a condition.
Routines/Desktop/GitHub Actions = better for durable unattended scheduling.