Library · Automation: browser, screen and schedules

Loop vs Scheduled Tasks: when to use which

Builder45 minUpdated: October 2026
41 of 105 in the library

Time: about 20 min theory + 25 min practice

The gist

There are two ways to run a recurring task in Claude Code, and they're like a bicycle and a car. A bicycle works great for a trip to the store around the corner. A car is a must for a trip to another city. Pick the right vehicle.

Key concepts

  • /loop: live loops inside your current Claude Code session
  • Scheduled Tasks: long-lived schedules outside the session: cloud Routines, tasks in the desktop app, an external cron service like Trigger.dev
  • The rule for choosing: time horizon + whether you need to be present
  • Catch-up runs: what happens to runs that were missed

As of October 2026, Routines are a research preview: behavior and limits may change. Current features and versions: What's current.


Theory

/loop: live loops

🎨 Picture this: a security guard who walks the floors every ten minutes, as long as he's on shift. He clocks in, walks around, looks. He goes home, and the rounds stop. /loop works exactly the same way: it's active while you're at the terminal and stops when you close the session.

The /loop command runs a recurring action right inside your current Claude Code session.

Syntax:

Code
/loop [interval] [prompt]

You can put the interval before the prompt (10m) or after it in words ("every 2 hours"). Units: s, m, h, d. Seconds get rounded up to a minute. If you don't give an interval, Claude picks the pause between checks itself, anywhere from one minute to an hour. Plain /loop runs a built-in maintenance prompt: finish anything left unfinished, look at the pull request, review comments and failed checks.

Examples:

Type this into the chat
/loop 10m Check whether there are new emails from client client@example.com and show a short summary

/loop 5m Run pytest and show the test status

/loop 1h Check the deploy status on Trigger.dev and tell me if any errors show up

How it works under the hood:

  • Claude Code keeps the session active
  • Every N minutes it queues the prompt you gave: it runs between your turns, not in the middle of a reply
  • The prompt has access to all the session's tools
  • The result is printed in the terminal
  • You see updates in real time

What /loop is like

Lifespan: 7 days max

A recurring /loop task deletes itself 7 days after it was created: it fires one last time and disappears. This protects you from forgotten loops. On top of that, the loop is tied to the Claude Code session: if you close the terminal, the loop stops. Need it for longer than a week? Use a schedule outside the session (below).

Requires an open terminal

It's a live session. Claude Code has to be running. Not suitable for "set it and forget it."

No catch-up

If a run time passes while Claude is busy with a long reply or the computer is asleep, missed iterations don't pile up: the task fires once when Claude is free and then continues on schedule.

Real-time help from the agent

The main advantage: the agent sees what's happening and can react. If it spots something odd while checking email, it can make a decision right there instead of just noting it.

When it's ideal:

  • Monitoring during the workday: checking the inbox every 10 minutes from 9 a.m. to 6 p.m.
  • Tracking the status of a deploy that takes 2-3 hours
  • A development sprint on a specific feature over a few days with hourly checks
  • Live test monitoring while you work

Scheduled Tasks: long-lived schedules

🎨 Picture this: an alarm clock you set once, and it rings on its own even if you've fallen asleep. A Scheduled Task is an alarm clock in the cloud: set it up, forget about it, and get a report every Friday. Your computer can be off, you can be on vacation, and the task still runs.

There are three kinds of schedules outside the session in Claude Code:

  • Routines: a task in Anthropic's cloud made of a prompt, repositories and connected services (connectors). It runs on a schedule, on an HTTP request or on a GitHub event. It works while your computer is off. You create one at claude.ai/code/routines or with the /schedule command. Requires the Pro plan or higher; status: research preview. The minimum interval is 1 hour.
  • Tasks in the desktop app: they run on your machine with access to local files. They work as long as the app is open and the computer isn't asleep. The minimum interval is 1 minute.
  • An external cron service, for example Trigger.dev or Cloudflare Workers cron: you write the code yourself, and the platform runs it on a schedule.

Below, an external service shows how a schedule looks in code. For Claude Code itself, try the built-in routines first.

How to set it up with Trigger.dev:

typescript
// src/trigger/weekly-report.ts
// The import depends on the SDK version: check the trigger.dev docs
import { schedules } from "@trigger.dev/sdk";

export const weeklyYoutubeReport = schedules.task({
  id: "weekly-youtube-report",
  cron: "0 9 * * 5",  // Every Friday at 09:00
  
  run: async (payload) => {
    // Collect YouTube stats for the week
    const stats = await fetchYoutubeStats({ period: "7d" });
    
    // Generate a report with Claude
    const report = await generateReport(stats);
    
    // Send it to a messenger (Telegram in this example; Slack or email work the same way)
    await sendToTelegram(report);
    
    return { completed: true };
  }
});

Cron syntax: quick reference:

Type this into the chat
Format: minutes hours day_of_month month day_of_week
        (0-59)  (0-23) (1-31)      (1-12) (0-7, 0 and 7 = Sunday)
Cron expression What it does Typical use
*/5 * * * * Every 5 minutes Email monitoring
0 * * * * Every hour on the hour Checking deploy status
0 8 * * 1-5 Mon-Fri at 08:00 Daily Brief
0 9 * * 5 Every Friday at 09:00 Weekly report
0 10 1 * * The 1st of the month at 10:00 Monthly financial report
0 3 * * * Every day at 03:00 Nightly backup
*/30 9-18 * * 1-5 Every 30 min from 9 to 18, Mon-Fri Business-hours monitoring
0 0 * * 0 Every Sunday at midnight Weekly cleanup

A visual editor to check your work: crontab.guru. Type in an expression and see the schedule in plain English.


What Scheduled Tasks are like

Long-lived: months and years

Set it up once, and it runs continuously until you stop it. It's a system feature, not a situational one.

No open terminal needed

Routines and external services run in the cloud. Your computer can be off and the task will still run. Tasks in the desktop app are the exception: they need the app running and the computer awake.

Catch-up depends on the tool

🎨 Picture this: a mail carrier back from sick leave who doesn't bring all the mail that piled up, just one summary for the most recent missed day. That's how a task in the desktop app behaves.

If the computer was asleep at run time, when it wakes up the app checks the last 7 days and does one catch-up run for the most recent missed time, discarding the rest. A daily task that missed six days will run once. So add a safeguard to the prompt: "Look only at today's commits." For an external cron service, check its documentation to see whether it catches up on misses. For critical operations (reports, backups), don't rely on catch-up: check the result.

No live reaction

An external cron service runs an algorithm you described in advance. If something doesn't go to plan, the task will record it in the logs but can't react flexibly the way a live agent can. A Claude Code routine is closer to an agent: it starts a full session and works things out from the prompt. But during the run you're not around and nobody is there to approve actions, so the prompt has to be self-contained and the permissions minimal.

When it's ideal:

  • A weekly report on a YouTube channel every Friday
  • Daily monitoring of competitors and news
  • A monthly financial report on the first of the month
  • Regular data backups
  • Any task that should run "on its own"

Comparison table

Criterion /loop Routine (cloud) Desktop app task
Where it runs your computer Anthropic's cloud your computer
Lifespan up to 7 days until you turn it off until you delete it
Requires an open session YES NO NO
Requires the computer to be on YES NO YES (app open)
Catch-up of missed runs NO not needed, your computer isn't involved one run for the last 7 days
Access to local files YES NO (a fresh clone of the repository) YES
Minimum interval 1 minute 1 hour 1 minute
Setup seconds a few minutes a few minutes
Cost subscription limits subscription limits subscription limits
Best for situational monitoring regular operations without your computer regular operations with local files

An external cron service (Trigger.dev and the like) fits when you need your own code and your own interface. It's counted separately: it has its own billing and its own rules. Terms for routines and plans change: What's current.


The rule for choosing

🎨 Picture this: choosing between a floodlight and a flashlight. The floodlight (Scheduled Tasks) is powerful, fixed in place and shines on its own. The flashlight (/loop) is in your hand, you point it where you need it, but only while you're holding it. To light up the yard permanently, use the floodlight. For a walk at night, the flashlight.

Answer two questions:

1. How long will this run?

  • A few hours or days (up to 7) → /loop
  • Weeks, months, permanently → Scheduled Tasks

2. Will you be at the computer?

  • Yes, actively working → /loop (you see what's happening and can step in)
  • No, you want to "set it and forget it" → Scheduled Tasks: a routine in the cloud, or a desktop app task if you need local files

Examples of the rule:

"I want to watch the deploy status while it runs (2 hours)" → /loop: short period, you're at the computer

"I want a weekly project report every Friday" → Scheduled Task: regular, doesn't require you to be there

"I want to check my inbox every 10 minutes during the workday" → It depends: if just for today → /loop. If forever → Scheduled Task

"I want to keep an eye on competitors for three days while I prepare a pitch" → /loop: limited time, active work


Combining them

In complex systems, both approaches are used together:

Code
Scheduled Task (a cloud routine or Trigger.dev):
→ Every weekday at 08:30 it runs the Daily Brief
→ Runs continuously, needs no attention

/loop (during the workday):
→ When you're expecting an important email, start a /loop for 4 hours
→ The agent checks every 5 minutes and tells you right away when it arrives
→ This complements the regular schedule, it doesn't replace it

Practice

Assignment: Set up /loop for live monitoring

  1. Pick something you want to monitor right now:

    • A file that's supposed to change (for example, a log file)
    • A directory where new files are supposed to appear
    • The output of a command (for example, git status)
  2. Start /loop:

    Type this into the chat
    /loop 3m Check the contents of the ~/Downloads folder and list the files added in the last 10 minutes
  3. Watch 3-4 iterations. Add a file to Downloads and see how the agent spots it.

  4. Stop the loop: ask Claude to "cancel this check" (asking "what scheduled tasks do I have?" shows the list). If you started /loop without an interval, pressing Esc is enough. Otherwise the loop will delete itself after 7 days.

  5. Bonus: Describe the same task as a schedule outside the session. Option A: a routine via /schedule (requires the Pro plan or higher; after creating it, check the result at claude.ai/code/routines). Option B: a configuration for Trigger.dev (you can skip deploying: just write the code and understand the cron syntax)


Template: Scheduled Tasks configuration

An example set of schedules for a productive freelancer (using an external cron service; you could set up the same set as three routines):

typescript
// schedules.ts: all cron tasks in one file

// Morning Daily Brief: Mon-Fri at 08:00
export const dailyBrief = schedules.task({
  id: "daily-brief",
  cron: "0 8 * * 1-5",
  run: async () => {
    const [emails, meetings, tasks] = await Promise.all([
      getUnreadEmails({ since: "12h" }),
      getTodayMeetings(),
      getOpenTasks({ priority: "high" })
    ]);
    const brief = await generateBrief(emails, meetings, tasks);
    await sendToTelegram(brief);
  }
});

// Weekly report: Friday 17:00
export const weeklyReport = schedules.task({
  id: "weekly-report",
  cron: "0 17 * * 5",
  run: async () => {
    const stats = await getWeeklyStats();
    const report = await generateWeeklyReport(stats);
    await sendToTelegram(report);
  }
});

// Backup: every day at 03:00
export const nightlyBackup = schedules.task({
  id: "nightly-backup",
  cron: "0 3 * * *",
  run: async () => {
    await backupDatabase();
    await sendToTelegram("✅ Backup complete");
  }
});

In this template sendToTelegram is just a helper name: swap in whatever channel you actually use (Slack, email, SMS).


Tools and resources

  • /loop: a built-in Claude Code command (a bundled skill)
  • Routines: cloud routines at claude.ai/code/routines or via /schedule (research preview, Pro and up)
  • Desktop app tasks: the Code tab, Routines section, Local option
  • Documentation: Run prompts on a schedule and Routines
  • Trigger.dev: a platform for Scheduled Tasks and workflows (an external service)
  • Cron syntax reference: a visual editor for cron expressions, crontab.guru
  • Skill: anthropic-skills:schedule: help with setting up schedules

Key takeaways

/loop is the bicycle: quick to start, good for situations where you're nearby. Scheduled Tasks are the car: longer to set up, but it drives itself while you're busy with other things. What happens to a missed run isn't a detail, it's a key property: /loop doesn't catch up, a desktop app task does one catch-up run, and a cloud routine doesn't depend on your computer at all. For critical operations (financial reports, backups), check the result instead of hoping for a catch-up. The rule for choosing: time horizon + whether you need to be present. Two questions, one answer.


  • Deploying to Cloudflare: Cloudflare Workers cron triggers as an alternative to Trigger.dev for serverless schedules
  • AI Executive Assistant: Scheduled Tasks power all four of the assistant's workflows (email, meetings, brief, tasks)

Next lesson

→ First clients: trust map and warm conversations

The mark stays in this browser only and is never sent anywhere. My progress