Scheduled and unattended

What a loop or a scheduled task costs in Claude Code while you are away

A loop or a scheduled task in Claude Code costs one full turn on every firing, and a turn sends the whole conversation to the model. A scheduled task is a prompt that Claude Code runs again by itself on a timer, with `/loop` or the cron tools. Anthropic's cost page, read on 4 October 2026, says a scheduled task fires on its interval even while the session is idle, sending your full context each time. The same page lists three more ways a session starts a turn with nobody typing: a goal check-in, a message from another of your sessions, and the short request behind a prompt suggestion. This page says how often each one fires, what Anthropic's documentation says it sends, and which setting stops it.

Published October 4, 2026. Editorial.

Key takeaways

  • A scheduled task in Claude Code fires on its interval even while the session is idle and sends the full context each time, by Anthropic's cost page read on 4 October 2026.
  • A recurring task expires 7 days after creation, fires one final time and deletes itself; a self-paced loop stops when you press Esc or when Claude ends it.
  • The Loops rows in /usage list the heaviest scheduled tasks with their firing rate, run count, total and per-run tokens, and require Claude Code v2.1.242 or later.
  • Claude Code starts at most three idle goal check-ins per goal between your prompts since v2.1.246, and CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0 turns check-ins off.
  • A message from another session starts a new turn when this session is idle and counts like a prompt you type; crossSessionInbound set to hold keeps it undelivered.

Claude Code is Anthropic's coding tool: you type a request in a terminal, and an AI model reads files, runs commands and edits code for you. Everything the model reads and writes is counted in tokens, which are pieces of text, and every request sends the context window, which is the full set of text the model reads on that request. A scheduled task is a prompt that Claude Code runs again by itself, on a timer, with no new message from you. Each firing is a turn, and a turn sends the whole conversation.

This page is part of the guide to the cost of agents and unattended runs in Claude Code. It covers every way a session starts a turn without you typing one: /loop and the cron tools (cron is the name of the timer system), goal check-ins, messages from your other sessions, prompt suggestions, and Desktop scheduled tasks. For each, it states how often it fires, what Anthropic's documentation says it sends, and which setting stops it. Everything here comes from Anthropic's documentation, read on 4 October 2026.

What /loop and the cron tools do

/loop is a bundled skill, which is a packaged set of instructions Claude Code ships with, and it runs a prompt on repeat while the session stays open. What you type after it decides the form [1]:

  • An interval and a prompt, such as /loop 5m check if the deployment finished, runs the prompt on a fixed schedule. Claude converts the interval to a cron expression, which is a five-field text pattern for times, and confirms the schedule and job ID. Units are s, m, h and d. Seconds round up to the nearest minute, and an interval such as 7m or 90m rounds to the nearest interval that maps to a clean cron step.
  • A prompt with no interval runs at an interval Claude chooses. After each iteration Claude picks a delay between one minute and one hour, based on what it observed, and prints the delay and the reason.
  • No prompt, as in /loop typed with nothing after it, runs a built-in maintenance prompt that continues unfinished work, handles the current branch's pull request (review comments, failed automated check runs, merge conflicts), and runs cleanup passes when nothing else is pending. A loop.md file in .claude/ or ~/.claude/ replaces that prompt, and content beyond 25,000 bytes is truncated.

You can also schedule a one-time reminder in plain words, such as "in 45 minutes, check whether the integration tests passed", and Claude schedules a single-fire task that deletes itself after running [1]. All of these use three tools: CronCreate schedules a task, CronList lists tasks with their IDs, schedules and prompts, and CronDelete cancels one by its 8-character ID. A session can hold up to 50 scheduled tasks at once [1].

Every firing sends the full context

Anthropic's cost page states the cost rule in one line. In its list of reasons usage climbs in a long session, it says a scheduled task "fires on its interval even while the session is idle, sending your full context each time" [2]. The page on why usage rises in a long session covers the other items in that list; this page covers the timer.

How the scheduler fires matters for the count. Anthropic says it checks every second for due tasks and adds them to a low-priority queue, and a scheduled prompt fires between your turns. If Claude is busy when a task comes due, the prompt waits until the current turn ends. There is no catch-up: when a task's time passes while Claude is on a long request, it fires once when Claude becomes idle, however many intervals were missed [1]. The scheduler also adds a deterministic offset, which Anthropic calls jitter, so that every session does not reach the API at the same moment. A recurring task fires up to 30 minutes after its scheduled time, or up to half the interval for tasks that run more often than hourly, and a one-shot task set for :00 or :30 fires up to 90 seconds early. The offset comes from the task ID, so one task always gets the same offset [1].

An invented example, using only arithmetic on Anthropic's statements: a session with /loop 5m left idle for 2 hours fires 12 times an hour (60 divided by 5) and 24 times in total, and each of those 24 turns sends the whole conversation. The constant offset shifts each firing and leaves the count unchanged. If the conversation already holds a long day of work, each firing re-reads all of it, at the cached rate while the prompt cache is warm. The prompt cache is the store of request text the service has already processed, billed at a lower rate when a request reuses it, and Anthropic's cost page says the first message after a break longer than the cache lifetime misses the cache and reprocesses the full context [2]. On our reading of that rule, a loop whose interval is longer than the cache lifetime meets it on every firing. The page on the five-minute and one-hour cache lifetimes gives the lifetimes.

You can see the count after the fact. On a Pro, Max, Team or Enterprise plan, /usage shows a Loops section: a row for each of the heaviest /loop or other scheduled tasks that ran recently, ordered by total tokens, with a count of the rest. Each row reports how often the task fires, how many times it ran, its total and per-run tokens, and when it last ran. Claude Code identifies a row by the task's prompt, so a loop you stop and re-create stays one row. The rows require Claude Code v2.1.242 or later, the d and w keys switch between the last 24 hours and the last 7 days, and Anthropic describes the figures as approximate and computed from local session history on this machine [2]. The page on how to read /usage and /context covers the rest of that screen.

How a loop ends

A loop ends in one of five ways, by Anthropic's documentation [1]:

  1. Expiry. A recurring task expires 7 days after creation. It fires one final time, then deletes itself. Anthropic says this bounds how long a forgotten loop can run.
  2. Esc. Pressing Esc while a self-paced loop waits for its next iteration clears the pending wakeup, which is the next planned firing. Tasks you scheduled by asking Claude directly are unaffected by Esc and stay until you delete them.
  3. Claude stops it. In self-paced mode Claude can end the loop itself by calling the ScheduleWakeup tool with stop: true. If an iteration ends without rescheduling or stopping, Claude Code schedules one fallback wakeup, which Anthropic puts at 20 minutes later, and ends the loop when that iteration does not reschedule either.
  4. Cancellation. A fixed-interval loop runs until you cancel it with CronDelete, or by asking Claude to cancel it, or until the 7 days elapse.
  5. The session ends. Tasks fire only while Claude Code is running and idle. Closing the terminal or letting the session exit stops them. Moving the session to the background instead, so it keeps running without a terminal, moves /loop tasks over with it, and the firings continue.

Two more facts bound a loop. Setting CLAUDE_CODE_DISABLE_CRON=1 in the environment disables the scheduler entirely: the cron tools and /loop become unavailable and already-scheduled tasks stop firing, including tasks already running mid-session [7]. And when you resume a session with --resume or --continue, Claude Code restores the tasks made with CronCreate, except expired recurring tasks and one-shot tasks whose time has passed; a self-paced loop is restored only when you run /loop again [1].

For watching something instead of checking it again on a timer (polling), Anthropic names a cheaper tool. In a session where the Monitor tool is available, Claude may use it directly when you ask for a dynamic loop. Monitor runs a background script and streams each output line back to Claude, which, in Anthropic's words, avoids polling altogether and is often more token-efficient and responsive than re-running a prompt on an interval [1].

Goal check-ins

/goal sets a completion condition and Claude keeps working toward it without you prompting each step; after each turn a model checks whether the condition holds [3]. The evaluation itself runs on the small fast model configured for your provider, and Anthropic describes its tokens as typically negligible compared with main-turn spend [3].

The cost that matters while you are away is the check-in. When a subagent, which is a second copy of Claude working on one task in its own context, or a background shell command is still running when a turn ends, Claude Code skips the evaluation for that turn. Once background work has kept the goal waiting for 30 minutes, a check-in is due: Claude Code lists the running tasks and asks Claude to read their output, keep waiting if they are progressing, and fix or stop any that are stuck. After the first check-in Claude Code waits twice as long before each later one, up to four times the first interval, which with the default means 1 hour after the first, then every 2 hours [3].

A check-in is delivered in one of two ways. At the end of the next turn that finishes with the work still running, which in a non-interactive session started with -p is the only way. Or, in an interactive session, while the session is idle, where Claude Code starts a turn on its own to deliver it. Anthropic's cost page says each such turn sends your full context [2]. Claude Code starts at most three idle check-ins per goal between your prompts, and in the third one says that idle check-ins are paused until you send another prompt. Before v2.1.246 idle check-ins were uncapped; idle check-ins require v2.1.236 or later, and check-ins at all require v2.1.234 or later [3].

The control is CLAUDE_CODE_GOAL_CHECKIN_MINUTES. Its default is 30, it takes whole minutes up to 10,080 (one week), Claude Code treats any other value as unset, and 0 turns check-ins off, which also turns off the automatic retries Claude Code makes after a goal turn fails on an error that tends to clear on its own [7][3]. Anthropic also suggests a turn or time clause in the condition itself, such as "or stop after 20 turns", to bound how long a goal runs [3].

Messages from your other sessions

Claude Code can deliver a message from another of your sessions. When the receiving session is idle, Claude Code starts a new turn with the message, and once delivered the message counts toward usage like a prompt you type [4]. The cost page lists this beside scheduled tasks as a reason usage climbs while a session is idle, and names the control: set crossSessionInbound to hold [2].

The setting takes three values. accept delivers each message. hold shows a notice for each message and does not deliver it; if an accept later applies, Claude Code releases the held messages. refuse drops each message [4]. You can pick the value in the /config row named Messages from your other sessions, which requires Claude Code v2.1.232 or later, and the row is hidden while managed settings or --settings set the key. When no value applies, Claude Code decides per message from the two sessions' permission modes: a session that prompts for permissions receives each message unless the sender bypasses permission prompts, and a session that bypasses permission prompts holds each one for your approval unless the sender also bypasses them. Claude Code holds at most 100 messages and past that drops the oldest [4]. The page on settings an administrator can enforce covers the managed form of this setting.

A claude -p run opens an inbox of the same type and can receive messages, except in bare mode, where Claude Code does not open it. The run cannot show the approval dialog, so a message the default holds is kept for the dialogExpiry deadline, five minutes by default, and then dropped. A message held by an explicit hold setting does not expire. To let a -p worker take messages unattended, set crossSessionInbound to accept in its --settings value [4].

Prompt suggestions

After Claude responds, Claude Code can suggest your next prompt. Anthropic's interactive mode page says each suggestion is generated with a short background request to the same model your session is using, that the request counts toward your plan's usage limits or your API costs, and that because it reuses the conversation's prompt cache it is mostly cache reads plus a few output tokens [5]. Claude Code skips a suggestion when the prompt cache is cold (its lifetime has passed), after a response that ended in an error, in plan mode, in teammates' sessions in an agent team, and while your account is close to or at its usage limit; setting CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION to true keeps them on until the limit is reached, which works on v2.1.238 or later [5][7].

In interactive mode, Claude Code leaves suggestions off by default in a session that does not fetch Anthropic's feature switches (feature flags), such as one on a third-party provider or through a Claude apps gateway. In print mode, which is the -p form, it does not generate them at all unless you pass --prompt-suggestions with --output-format stream-json and --verbose [5]. To turn them off, use any of three controls: the Prompt suggestions toggle in /config, promptSuggestionEnabled: false in a settings file, or CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false in the environment, which takes precedence over the setting [5]. Anthropic's cost page adds that other background work, such as summarising conversations for --resume, uses tokens even when idle, and puts the typical figure at under $0.04 per session [2].

Desktop scheduled tasks

Claude Code Desktop can run a task on a schedule with no session open. Anthropic's page states these facts, read on 4 October 2026: Desktop checks the schedule every minute while the app is open and starts a fresh session when a task is due, independent of any manual sessions. Each task gets a delay of a few minutes after its scheduled time to spread API traffic over time, and the delay is deterministic for that task. Tasks run only while the app is open and the computer is awake; a scheduled time that passes during sleep is skipped, and on wake Desktop starts exactly one catch-up run for the most recently missed time and discards anything older. Each task has its own permission mode and model, set in the instructions input. A task in Manual mode that needs a tool it has no permission for stops and waits until you approve it, and the session stays open in the sidebar. Local scheduled tasks need Claude Desktop 1.1.5368 or later [6].

The three scheduling options compare like this, by Anthropic's own table: a cloud Routine needs no machine and no open session and has a minimum interval of 1 hour; a Desktop task needs the machine on and has a minimum interval of 1 minute; /loop needs the machine on and an open session, with a minimum interval of 1 minute [1][6].

Every background cause, how often it fires, how to stop it

Background cause How often it fires, by Anthropic's documentation How to stop it
/loop with an interval On the fixed interval, between turns, plus an offset of up to 30 minutes or half the interval CronDelete, or ask Claude to cancel it; expires after 7 days [1]
/loop with no interval At a delay Claude picks, 1 minute to 1 hour, after each iteration Press Esc while it waits; Claude can stop it with ScheduleWakeup [1]
One-time reminder Once, then it deletes itself CronDelete before it fires [1]
Goal check-in while background work runs First after 30 minutes, then doubling up to 2 hours; at most three idle check-ins per goal CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0, or /goal clear [3][7]
Message from another session Each delivered message starts a turn when this session is idle crossSessionInbound: hold or refuse [4]
Prompt suggestion One short request after each response, skipped when the cache is cold /config toggle, promptSuggestionEnabled: false, or CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false [5]
Desktop scheduled task On its preset: hourly, daily, weekdays or weekly, a few minutes late, as a fresh session Status toggle to Paused, or Delete, on the task's detail page [6]
Any scheduled task on a machine As above CLAUDE_CODE_DISABLE_CRON=1 stops all of them [7]

Our position

Use a fixed-interval loop for a wait with a known end, such as a deployment that finishes within the hour, and cancel it when the wait is over. For anything longer, ask Claude to watch with the Monitor tool, which Anthropic says streams each output line back instead of re-running a prompt on an interval. Before you leave a session open, run /usage and read the Loops rows, set crossSessionInbound to hold on any session you leave idle, and clear any goal that is waiting on background work. For work that must run while you are away, prefer a Desktop scheduled task or a claude -p run started by your own scheduler, because each run starts a new session with an empty conversation, and a loop re-sends an old one. The next page, running Claude Code from a script with a spend cap, covers that form.

Reveneau is an AI software development consultancy. All of its code is written by AI, and every change must pass an eval suite, a set of automated tests written from the specification, before release, so token use is a running cost of every Reveneau build. Reveneau is independent of Anthropic, and every figure on this page is Anthropic's own statement about its own product, read on 4 October 2026.

Common questions

What is the difference between /loop 5m and /loop with no interval?

With an interval, such as `/loop 5m check the deploy`, Claude Code converts the interval to a cron expression and runs the prompt on that fixed schedule. With a prompt and no interval, Claude picks a delay after each iteration, between one minute and one hour, based on what it observed, and prints the delay and the reason. Anthropic's scheduled tasks page, read on 4 October 2026, says the jitter rules skip the self-paced form and the seven-day expiry still applies.

How long does a recurring scheduled task last in Claude Code?

A recurring scheduled task lasts 7 days from creation. Anthropic's documentation, read on 4 October 2026, says the task fires one final time at the end of that period and then deletes itself, which bounds how long a forgotten loop can run. To keep a task longer, cancel it and create it again before it expires, or move the schedule to a Routine in the cloud or a Desktop scheduled task, which Anthropic lists as the durable options.

Does a scheduled task fire while Claude is in the middle of a turn?

No. Anthropic's documentation, read on 4 October 2026, says the scheduler checks every second for due tasks, adds them to a low-priority queue, and fires a scheduled prompt between your turns. If Claude is busy when a task comes due, the prompt waits until the current turn ends. There is also no catch-up: when a task's time passes while Claude is on a long request, it fires once when Claude becomes idle, whatever the number of missed intervals.

Why did my hourly task fire at 25 past the hour instead of on the hour?

Because the scheduler adds a deterministic offset to fire times so that every session does not reach the API at the same moment. Anthropic's documentation, read on 4 October 2026, says a recurring task fires up to 30 minutes after its scheduled time, or up to half the interval for tasks that run more often than hourly. The offset comes from the task ID, so the same task always gets the same offset. Pick a minute other than :00 or :30 if exact timing matters.

How many scheduled tasks can one Claude Code session hold?

One session can hold up to 50 scheduled tasks at once, by Anthropic's documentation read on 4 October 2026. Each task has an 8-character ID, and Claude uses three tools to manage them: `CronCreate` to schedule a task from a 5-field cron expression, `CronList` to list tasks with their IDs, schedules and prompts, and `CronDelete` to cancel one by ID. You can also ask Claude in plain words to list or cancel tasks.

What does CLAUDE_CODE_DISABLE_CRON do?

Setting `CLAUDE_CODE_DISABLE_CRON=1` in your environment disables the scheduler entirely. Anthropic's documentation, read on 4 October 2026, says the cron tools and `/loop` become unavailable and any already-scheduled tasks stop firing, including tasks that are already running mid-session. Use it on a machine where no session should ever start a turn on a timer. In a single session, deleting the task with `CronDelete` is the narrower control.

Is the Monitor tool cheaper than a /loop for watching a build?

Anthropic says it often is. The scheduled tasks page, read on 4 October 2026, says that when the Monitor tool is available, Claude may use it directly for a dynamic loop request, because Monitor runs a background script and streams each output line back, which avoids polling (checking again on a timer) altogether and is, in Anthropic's words, often more token-efficient and responsive than re-running a prompt on an interval. A loop sends the full context on each firing.

What does CLAUDE_CODE_GOAL_CHECKIN_MINUTES control?

It sets how many minutes background work can keep an active goal waiting before Claude Code asks Claude to check on that work, which starts a new turn. Anthropic's environment variable reference, read on 4 October 2026, gives a default of 30, accepts whole minutes up to 10,080, treats any other value as unset, and requires Claude Code v2.1.234 or later. A value of 0 turns check-ins off and, by the goal page, also turns off the automatic retries after a failed goal turn.

What happens to a cross-session message that reaches a claude -p run?

A `claude -p` run cannot show the approval dialog, so when the inbound default holds a message there, Claude Code keeps it for the `dialogExpiry` deadline, five minutes by default, by Anthropic's documentation read on 4 October 2026. Before the deadline, a mode or settings change that allows the message delivers it; past the deadline, Claude Code drops it and reports it as expired to a sender it can reach. To let a `-p` worker take messages unattended, set `crossSessionInbound` to `accept` in its `--settings` value.

Does a desktop scheduled task reuse the previous run's conversation?

No. Anthropic's Desktop page, read on 4 October 2026, says Desktop checks the schedule every minute while the app is open and starts a fresh session when a task is due, independent of any manual sessions you have open. Each run appears under a Scheduled section in the sidebar. The task runs only while the app is open and the computer is awake; a run missed during sleep is skipped, and on wake Desktop starts exactly one catch-up run for the most recently missed time.

Why are prompt suggestions skipped when the cache is cold?

Because the suggestion request is cheap only while it can read the conversation's prompt cache. Anthropic's interactive mode page, read on 4 October 2026, says each suggestion is a short background request to the same model your session is using, mostly cache reads plus a few output tokens, and that Claude Code skips a suggestion when the prompt cache is cold (expired), in Anthropic's words to avoid unnecessary cost. It also skips them in plan mode, after an error, and while your account is close to its usage limit.

Can a loop keep firing after I close the terminal?

Only if the session was moved to the background first. Anthropic's documentation, read on 4 October 2026, says tasks fire only while Claude Code is running and idle, so closing the terminal or letting the session exit stops them. Moving the session to the background instead keeps it running without a terminal, with its `/loop` tasks, and those firings keep sending the full context. Cancel the loop before you background or leave a session you do not plan to return to.

More in Scheduled and unattended

How to run Claude Code from a script with a spend cap

To run Claude Code from a script with a spend cap, call `claude -p` with your prompt and add `--max-budget-usd` with a dollar amount. `claude -p` is a run with no person at the keyboard: Claude Code reads the prompt, works, prints the result and exits. Anthropic's CLI reference, read on 4 October 2026, says `--max-budget-usd` is the maximum dollar amount to spend on API calls before stopping, works in print mode only, counts spend from subagents, and from Claude Code v2.1.217 fails any further subagent with `Budget limit reached` once the cap is reached. Add `--output-format json` so the run reports `total_cost_usd`, and `--model` with a full model name so the run stays on one model version. This page covers each flag, what it controls and its default.

Timeouts, retries and cleanup for an unattended Claude Code run

An unattended Claude Code run needs a time cap as well as a spend cap, because a run that is waiting spends no dollars and still holds its place in the schedule. `--max-budget-usd` counts money spent on API calls; a stalled response stream, a development server that never exits, or a subagent that never reports keeps the session open while that counter does not move. Anthropic's documentation, read on 4 October 2026, gives time controls at three levels: per request, through `API_TIMEOUT_MS` and the streaming watchdogs; per command, through the Bash timeouts and the 30-minute limit on background commands in unattended sessions; and per run, through `--max-turns`, the 10-minute wait for background work, and a job-level timeout in CI (automated build jobs). This page covers each, plus the retry rules.