🚀Publish FREEJoin WriterDock's early community of writers.Start Writing — It's Free

Claude Code Scheduled Tasks and /loop: Run Prompts on a Timer

Suraj Kumar

Suraj Kumar

November 3, 2026

Some jobs are not one-time. You want Claude to check whether a deployment finished, keep an eye on a pull request, or remind you to do something at three o'clock. After this lesson you will know how to make Claude repeat a prompt on a timer, how to set a reminder, how to read the time format Claude uses, how to stop a loop, and which kind of scheduling to pick when you need something that survives a closed laptop. This lesson finishes Module 5.

Scheduling at a glance

Claude Code has three ways to run work on a schedule:

A comparison of cloud scheduled tasks, desktop scheduled tasks and /loop across where they run, whether your computer must be on, whether a session must stay open, whether they can read local files, and the shortest interval

  • Cloud scheduled tasks run on Anthropic's servers, so they keep going when your computer is off. They start from a fresh copy of your repository and cannot read your local files. They can also trigger on API calls or GitHub events.
  • Desktop scheduled tasks run on your computer through the desktop app. They can read your local files and tools.
  • /loop runs inside an open Claude Code session. It is the quickest way to poll for something while you work.

A fourth option is a scheduled GitHub Actions workflow, which you met in lesson 23. This lesson focuses on /loop and the scheduling tools in your session.

Repeat a prompt with /loop

/loop is a built-in skill. Both the interval and the prompt are optional, and what you give it decides how it behaves:

You typeExampleWhat happens
An interval and a prompt/loop 5m check the deployThe prompt runs on a fixed schedule
A prompt only/loop check the deployClaude chooses the interval each time
An interval only, or nothing/loopA built-in maintenance prompt runs, or your own loop.md

A fixed interval

Put the interval first as a short token, or last as a clause such as every 2 hours:

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

The units are s for seconds, m for minutes, h for hours and d for days. Claude converts it to a cron expression, a standard way to describe a schedule, schedules it, and confirms the timing and a task ID. Seconds are rounded up to the nearest minute, because cron works in minutes. An interval that does not fit cleanly, such as 7m or 90m, is rounded to the nearest one that does, and Claude tells you what it picked.

You can also loop a skill from lesson 16:

text
1/loop 20m /review-pr 1234

A scheduled run can only use skills that Claude is allowed to invoke on its own. Built-in commands such as /permissions, /model and /clear, skills marked disable-model-invocation: true, and MCP prompts reach Claude as plain text instead of running.

Let Claude choose the interval

If you leave the interval out, Claude picks a delay between one minute and one hour after each iteration, based on what it saw. It waits briefly while a build is finishing and longer when nothing is pending. It prints the delay and the reason at the end of each run:

text
1/loop check whether CI passed and address any review comments

When the Monitor tool is available, Claude may use it instead of polling. Monitor runs a background script and streams each line of output back, which is often more responsive and uses fewer tokens than re-running a prompt on a timer.

The built-in maintenance prompt

A bare /loop, with no prompt, runs a built-in maintenance routine. On each pass, in order, Claude:

  1. Continues any unfinished work from the conversation.
  2. Tends to the current branch's pull request: review comments, failed CI runs and merge conflicts.
  3. Runs cleanup passes, such as bug hunts or simplification, when nothing else is pending.

Claude does not start new projects outside that scope. Irreversible actions such as pushing or deleting go ahead only when they continue something you already authorized in the conversation.

Write your own default with loop.md

To replace the built-in routine, create a loop.md file. Put it at .claude/loop.md for a project, or ~/.claude/loop.md for every project. The project file wins if both exist. It is plain markdown, written as if you were typing the prompt yourself:

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

Edits take effect on the next iteration, so you can refine it while a loop runs. A loop.md is used only by a bare /loop. When you give a prompt on the command line, the file is ignored. Content beyond 25,000 bytes is cut off.

Stop a loop

How you stop it depends on how it was started:

  • A self-paced loop (no interval): press Esc while it is waiting for its next run, or Ctrl + C while Claude is idle. A Pending wakeup cancelled notice confirms it will not fire again. Claude can also end one itself once the task is done.
  • A fixed-interval loop: ask Claude to cancel it, for example cancel the deploy check loop. Esc and Ctrl + C do not stop it.

A loop you never cancel ends on its own after seven days.

One-time reminders

For a single reminder, just say what you want in words:

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

Claude schedules a one-time task that deletes itself after it runs, and confirms when it will fire.

See and cancel your tasks

Ask in plain language:

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

Behind the scenes Claude uses three tools: CronCreate to schedule a task, CronList to list tasks with their IDs and next run times, and CronDelete to cancel one by its 8-character ID. A session can hold up to 50 scheduled tasks.

Reading a cron expression

A cron expression broken into five fields: minute, hour, day of month, month and day of week, with the example 0 9 * * 1-5 meaning weekdays at 9am, and four more examples

A cron expression has five fields: minute, hour, day of the month, month and day of the week. An asterisk means "every". A step such as */15 means every 15, a range such as 1-5 means one through five, and a comma separates a list.

ExampleMeaning
*/5 * * * *Every 5 minutes
0 * * * *Every hour on the hour
0 9 * * *Every day at 9am
0 9 * * 1-5Weekdays at 9am
30 14 15 3 *March 15 at 2:30pm

Day of the week runs from 0 or 7 for Sunday to 6 for Saturday. Times use your local time zone, so 0 9 * * * means 9am wherever you run Claude Code, not UTC. Extended symbols such as L, W and ?, and names like MON, are not supported. You rarely need to write these yourself, since Claude does it from your plain-language request.

How and when tasks fire

  • Between your turns. The scheduler checks every second for due tasks. A scheduled prompt runs between your turns, never in the middle of a response. If Claude is busy when a task comes due, it waits until the current turn ends.
  • Jitter. A task can run a little later than its schedule, because Claude Code spreads runs out so many sessions do not hit the API at the same instant. A recurring task runs late by up to half the gap to its next run, and at most 30 minutes. A task every five minutes is the exception, and runs 15 seconds sooner than five minutes after the last one, at 4 minutes 45 seconds.
  • One-time tasks on the hour. A one-time task set for :00 or :30 can run up to 90 seconds early. If timing matters, use an odd minute, such as 3 9 * * * in place of 0 9 * * *.
  • Seven-day expiry. A recurring task fires one last time seven days after it was created, then deletes itself. This limits how long a forgotten loop can run. For anything that needs to last longer, use a cloud or desktop scheduled task.

Limits to remember

  • Tasks fire only while Claude Code is running and idle. Closing the terminal stops them. Backgrounding the session lets /loop tasks keep running without a terminal.
  • There is no catch-up. If a scheduled time passes while Claude is busy, the task fires once when Claude becomes idle, not once for each missed run.
  • When you resume with claude --resume or claude --continue, Claude Code restores tasks created with the scheduling tools, except expired ones and one-time tasks whose time has passed. A self-paced /loop is not restored, so run /loop again.
  • Missed runs while the session was closed are not replayed.
  • To turn scheduling off entirely, set CLAUDE_CODE_DISABLE_CRON=1. The cron tools and /loop then become unavailable, and any scheduled tasks stop firing.

If you need something that runs without your session or your computer, use a cloud scheduled task, a desktop scheduled task or a GitHub Actions schedule trigger.

Related features

/goal keeps Claude working turn after turn toward a condition, rather than on a timer. Channels let events such as a CI failure push into your session directly, which avoids polling. Both are covered in the official documentation.

Mistakes beginners make

  1. Expecting a loop to survive closing the terminal. It only runs while Claude Code is running. Use cloud or desktop tasks for that.
  2. Trying to stop a fixed-interval loop with Esc. Ask Claude to cancel it instead.
  3. Looping a built-in command. Commands like /permissions arrive as plain text and do not run.
  4. Forgetting the seven-day limit. A loop ends after a week, so recreate it if you still need it.
  5. Scheduling for exactly on the hour when timing matters. Pick an odd minute.
  6. Polling when you could be told. For events, a Monitor, a channel or a CI trigger can react instead of checking repeatedly.

Quick recap

  • /loop repeats a prompt on a fixed interval, or at a pace Claude chooses. A bare /loop runs a maintenance routine, or your loop.md.
  • Ask in plain words for one-time reminders, and to list or cancel tasks.
  • Cron expressions have five fields. Times use your local time zone.
  • Tasks run only while Claude Code is open and idle, with jitter, no catch-up, and a seven-day expiry for recurring ones.
  • Use cloud or desktop scheduled tasks, or GitHub Actions, for work that must survive your session.

Try it yourself

In your claude-practice folder, start Claude Code and run /loop 5m tell me how many files are in this folder. Wait for two runs, then ask "what scheduled tasks do I have?" and note its ID. Ask Claude to cancel it. Then try a one-time reminder: in 3 minutes, tell me to take a break. Finally, ask Claude to explain the cron expression it used in the earlier loop.

Module 5 is complete. Next lesson, the start of Module 6: cost and token efficiency.