Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.
/loop and cloud scheduled tasks
Advanced · Elective · about 15 minutes, plus run time · Needs: Put bounds on autonomous runs · Verified against Claude Code v2.1.292 (stable) on 2026-10-15
[!NOTE] "Scheduled tasks are in research preview. Behavior, limits, and the API surface may change." (Automate work with scheduled tasks)
Goal
By the end of this Elective you can keep Claude working without prompting each step: on an interval in your session with /loop, and on a schedule in the cloud with a cloud scheduled task.
You need
- Your copy of the practice template, with Node.js LTS, for the Worked example, and one of your own repositories for Your turn.
- For the cloud scheduled task, steps 5 to 7 only: a Pro, Max, Team or Enterprise plan, signed in with
/login(Availability by subscription plan). Cloud scheduled tasks need a Claude subscription, so with a Console API key or a cloud provider, skip those steps (Feature availability). On Team and Enterprise, an Owner can turn cloud scheduled tasks off for everyone with the Scheduled tasks (Was Routines) toggle (Automate work with scheduled tasks). - Also for the cloud scheduled task: GitHub access for cloud sessions to your copy, through the Claude GitHub App or
/web-setup; with the App, a private copy needs the App installed on it (GitHub authentication options). On Team and Enterprise, either way needs an Owner first: the GitHub connector for the App's browser sign-in, or Quick setup for/web-setup(Connect GitHub, Quick setup for Team and Enterprise). - Usage: moderate. Each loop run sends the session's whole context again (Why usage climbs in a long session), and a cloud scheduled task run is a full cloud session that draws on your plan (Usage and limits). The steps keep each one small: Sonnet, a short loop and a task that runs once. Cheap variant: skip the cloud scheduled task (steps 5 to 7).
The idea
/loop and a cloud scheduled task each start Claude's next run without you (Compare scheduling options):
| Next run starts when | Stops when | |
|---|---|---|
/loop |
An interval passes, while your session is open and idle | You cancel it, Claude ends a self-paced loop, or it expires |
| Cloud scheduled task | A schedule, an API call or a GitHub event, in the cloud | You pause or delete it; a one-off turns itself off |
A loop runs in your session, on your files, and keeps the session's permission mode: in auto mode its runs go ahead unattended, and in Manual mode Claude asks first. A cloud scheduled task runs on a fresh clone of your repository, so it keeps working with your laptop closed but sees only what you've pushed (Compare scheduling options, Automate work with scheduled tasks). To keep Claude working toward a condition rather than on a clock, use /goal, which lesson 3 teaches.
[!WARNING] A cloud scheduled task runs as a full cloud session that starts in auto mode, unless auto mode is unavailable, so a classifier model, not you, allows or blocks the actions that would otherwise wait for your approval. It still stops for your answer in cases such as an action that prompts even in auto mode (one matching an ask rule, for example) or after repeated blocks (Permission prompts during a run). It acts as you: its commits and pull requests carry your GitHub user (Create a scheduled task). Claude can use each connector the task includes, writes included, and every connector on your claude.ai account is included by default (Create from the web, Connectors). Remove the connectors a task doesn't need, and keep its prompt to read-only work while you learn.
Worked example
Work in your practice copy.
Make the log folder, which git already ignores in the copy, then start Claude Code on Sonnet:
mkdir -p .practice claude --model sonnetWindows:
New-Item -ItemType Directory -Force .practicereplaces themkdirline.The status bar shows the permission mode (Switch permission modes). If it shows
⏸ manual mode on, approve each tool call as Claude asks; if it shows⏵⏵ auto mode on, the loop's runs go ahead on their own.Start a loop that logs the test results every minute:
/loop 1m run npm test and append one line to .practice/loop-log.txt with the time and the number of passing and failing tests. Don't change any other file.Claude schedules it and confirms the cadence and a job ID (Run on a fixed interval). Each run fires between your turns, never while Claude is mid-response (How session-scoped scheduled tasks run).
In your editor, not through Claude, break one test: in
test/config.test.js, change the first test'sfiles: ['.']tofiles: ['docs']. Wait until the log gains a line that shows a failure, then undo the change withgit restore test/config.test.js.Ask Claude
cancel the npm test loop, thenwhat scheduled tasks do I have?: none are left (Manage session-scoped scheduled tasks).cat .practice/loop-log.txtshows a line for each run, at least one of them failing. Your wording will differ.Steps 5 to 7 need a subscription; without one, you're done with the Worked example. Schedule a cloud scheduled task that runs once, in five minutes:
/schedule in 5 minutes, run npm test in this repository and reply with the number of passing and failing tests. Don't edit files, commit or push.Claude asks follow-up questions about the schedule, the repository and the prompt, and confirms the absolute time before it saves (Create from the CLI, Schedule a one-off run). The earlier name, routines, still appears in Claude's replies while it sets up a task and, in some accounts, in the app's sidebar entry and page title (Where the name routines still appears). Tell it to include no connectors; if it can't, remove them as soon as it saves, with
/schedule updateor the task's Edit dialog atclaude.ai/code/routines(Connectors).
If Claude adds a setup note about GitHub access, follow it before the run time; if the time passes first, edit the task and set a new one-off time (Repositories and branch permissions, Edit and control scheduled tasks). If Claude replies that you need to authenticate, no task was saved; if/scheduleisn't in the command menu, see/schedulereturns "Unknown command"./schedule listshows the task (Manage scheduled tasks from the CLI). After it runs, open it atclaude.ai/code/routines, open the run and read the transcript for the test counts (View and interact with runs). The run cloned your default branch, not your working tree (Repositories and branch permissions). The one-off is now marked Completed (Schedule a one-off run).Delete the task: open the menu next to its name and select Delete (Edit and control scheduled tasks).
If you connected GitHub only for the task, disconnect it atclaude.ai/customize/connectors, which deletes the credential whether it came from the browser or from/web-setup; theghtoken itself stays valid on GitHub (Remove the/web-setuptoken). If you installed the Claude GitHub App only for the task, also take your copy out of its repository access, and uninstall it only if nothing else of yours uses it (Reviewing and modifying installed GitHub Apps).
Your turn
In one of your own repositories, pick a check a command can run, such as the test suite or a lint command. Commit a .claude/loop.md that keeps watching it: the file replaces the built-in prompt of a /loop you start without a prompt of your own (Customize the default prompt with loop.md). With a subscription, you can also have a one-off cloud scheduled task run the command in the cloud once your work is on the default branch, or name your branch in the task's prompt (Repositories and branch permissions).
It's done when:
.claude/loop.mdis committed. It says what to check, and to report in one line without changing any file./loop 10m(an interval and no prompt) ran it at least twice, then you cancelled it (Run the built-in maintenance prompt).- No scheduled task is left:
what scheduled tasks do I have?lists none, and any cloud scheduled task you made is deleted.
Check
You are done when all of these are true:
- In your practice copy,
.practice/loop-log.txtholds lines from at least two loop runs, at least one of them failing. -
.claude/loop.mdis committed in your repository (git ls-files .claude/loop.mdprints it), andgit status --porcelainprints nothing. - Self-check (not tested):
/loop 10mran yourloop.mdat least twice before you cancelled it;what scheduled tasks do I have?lists none; and if you made a cloud scheduled task, you read its run's transcript and deleted it.
If no log line shows a failure, the loop didn't run while the test was broken: start the loop again as in step 2, break the test as in step 3, wait for a failing line, restore the file, then cancel the loop as in step 4. If git ls-files prints nothing, git check-ignore -v .claude/loop.md names the rule that hides the file: add it with git add -f, then commit.
Watch out
- A loop fires even while you're away, sending the session's whole context each time, and keeps going until you cancel it or it expires (Stop a loop). On a Pro, Max, Team or Enterprise plan,
/usagelists your heaviest loops (Plan usage breakdown). Escdoesn't stop a fixed-interval loop such as/loop 1m: ask Claude to cancel it (Stop a loop).- A green status in a cloud scheduled task's run list only means the session started and exited without an infrastructure error. Open the run and read the transcript to see whether the task worked (View and interact with runs).
Go further
- Loop engineering: Getting started with loops: Anthropic's Claude Code team on turn-based, goal-based, time-based and proactive loops, and when to use each.
- Add a GitHub trigger: run a cloud scheduled task on pull request or release events, with the Claude GitHub App installed on the repository.
- Schedule recurring tasks in Claude Code Desktop: scheduled tasks that run on your machine, with your local files, while the Desktop app is open.
Sources: Run prompts on a schedule · Automate work with scheduled tasks · Choose a permission mode · Manage costs effectively · Feature availability · Use Claude Code in the cloud · Get started with Claude Code in the cloud · Reviewing and modifying installed GitHub Apps
Back to the Advanced index · Topic: Automation · Stuck on this lesson?