Agents That Keep Working Without You

How to Schedule Claude to Run Automatically

Anthropic's Claude and Anthropic's Claude Code are the tools this guide names. It is independent, not affiliated with or endorsed by Anthropic.

Posts about AI agents that keep working after you close your laptop, kicked off by a schedule, an API call, or a GitHub event, have been everywhere this week. That capability is not hypothetical. Anthropic's Claude and Anthropic's Claude Code already support it today, through more than one mechanism, depending on where you want the work to actually run. This guide is about Claude Code specifically, the developer tool, not the separate scheduled-tasks feature inside the Claude consumer chat app. It walks through what it actually means for a Claude Code session to start itself, the five ways people set that up this week, and the checks worth running before you let any of them operate without you watching.

A Claude Code session running automatically means it starts itself from a prompt you saved earlier, works through that prompt, and reports back, with nobody opening a terminal at that moment. Claude Code supports this five ways: /loop for quick polling inside a session still open on your machine, /schedule for a durable cloud scheduled task that runs on Anthropic's own infrastructure, a cloud session at claude.ai/code that keeps running after you close your laptop, a GitHub Actions workflow that runs Claude Code on a repository event or a cron schedule, and a plain operating-system scheduler like cron, launchd, or Task Scheduler calling claude -p from the command line.

Published

Free lesson · no account neededMeet ClaudeWhy Claude?6 minStart the free lesson

Key Takeaways

  • Running automatically means a Claude Code session starts itself from a prompt saved ahead of time, works through it, and reports back, with nobody opening a terminal at that moment.
  • /loop runs inside a session you leave open on your own machine; /schedule creates a durable cloud scheduled task, formerly called a Routine, that runs on Anthropic's own infrastructure instead.
  • A cloud session at claude.ai/code, a GitHub Actions workflow, and your computer's own scheduler calling claude -p are three more ways to run Claude Code without a person at the keyboard.
  • The cron tools behind /loop only fire while Claude Code is open and idle on your machine; anything that must survive a closed laptop belongs in /schedule, GitHub Actions, or your own OS scheduler instead.
  • Every method here needs the same checks before you trust it unattended: scoped permissions, a spending limit, a visible run history, and a human approval step for anything that sends, pays, or deletes.

At a Glance: Five Ways to Run Claude Code Unattended

MethodWhere It RunsNeeds Your Machine On?Best For
/loopInside an open session, on your machineYes, the session must stay openWatching something today, like a deploy or a pull request
/scheduleAnthropic's cloud infrastructureNoA recurring job that must survive a closed laptop
Cloud session (claude.ai/code)Anthropic's cloud infrastructureNoOne substantial task you hand off and check on later
GitHub ActionsGitHub-hosted runnersNoReacting to a repository event, not a clock
OS scheduler + claude -pYour own machine or serverYesZero dependence on any cloud account for the scheduling itself

Copy and Paste

Prompts You Can Use Today

A quick local loop for something you're watching right now

/loop 10m check whether the deploy to staging has finished, read the last 50 lines of its log, and tell me in one line whether it succeeded, failed, or is still running. Don't touch anything, just report back each time.

/loop only fires while this session stays open on your machine, which is exactly right for babysitting something for an afternoon.

A durable cloud scheduled task created with /schedule

/schedule every weekday at 8am, open the repository's pull requests, read any new review comments or failed CI checks since yesterday, and post a one-paragraph summary to our team channel. If nothing changed, say so in one line instead of repeating yesterday's summary.

Unlike /loop, this keeps running on Anthropic's own cloud infrastructure even after you close your laptop.

Asking what an unattended run can do, before you schedule anything

Before I turn this into a scheduled task, tell me plainly what you can do without me watching: can you push commits, open pull requests, spend any API budget, or message anyone on my behalf? List anything that needs my approval first, so I know exactly what I'm turning on before I save this schedule.

A good answer here is specific. A vague one is a reason to narrow the task, not a reason to skip asking.

A prompt for a GitHub Actions workflow, scoped to one event

Read the pull request that was just opened, compare it against the project's CLAUDE.md conventions, and leave one inline comment per real issue you find. If you find nothing worth flagging, post a single comment that says the change looks clean. Never approve or merge the pull request yourself.

This is the text you'd put in the workflow's prompt input, not something you type into a chat window.

Interactive vs. Unattended

What "Running on Its Own" Actually Means

Every chat you've had with an AI assistant so far probably started the same way: you opened a window, typed something, and waited. Close that window and the conversation stops existing until you come back. Nothing happens while you're away, because nothing is scheduled to happen in your absence.

Running automatically flips that. A Claude Code session starts on its own, at a time or in response to an event you set up in advance, works through a prompt you already wrote, and stops when it's done or when it needs you. The person who starts the session is the real dividing line, not how capable the underlying model is in the moment you happen to be watching it.

That one shift, who starts the session, is also the reason the rest of this guide is specific about Claude Code rather than Claude in general. Anthropic's Claude, the consumer chat app, has its own separate scheduled-tasks feature for things like a daily inbox summary. Claude Code, the developer-facing agentic coding tool, has a different set of mechanisms built for running inside a repository, a terminal, or a CI pipeline, and those are what the rest of this guide covers.

None of the five mechanisms below need you to write new software. Each one is a way of telling Claude Code when to start and what to do once it has, using tools that already ship today.

Where the Work Actually Runs

Five Ways to Put Claude Code on a Schedule

Pick the one that matches where the work needs to happen, not the one that sounds the most capable.

/loop, for Quick Polling in an Open Session

A built-in Claude Code command that reruns a prompt on an interval, or lets Claude choose the interval itself, for as long as the session stays open on your own machine.

/schedule, for a Durable Cloud Scheduled Task

Also a built-in Claude Code command. It saves a prompt, repositories, and connectors as a scheduled task that runs on Anthropic's own cloud infrastructure on a timer, an API call, or a GitHub event, whether or not your machine is on.

A Cloud Session at claude.ai/code

Start a Claude Code session in your browser, the Claude mobile app, or with claude --cloud from your terminal. It keeps running after you close your laptop, and you can check on it from any device.

A GitHub Actions Workflow

The Claude Code GitHub Action runs inside your repository's workflows, responding to an @claude mention or running a saved prompt automatically on any event you configure, including a cron schedule.

Your Computer's Own Scheduler, Calling claude -p

Cron and launchd on macOS and Linux, Task Scheduler on Windows, calling claude -p, Claude Code's non-interactive flag, from a line or script you write yourself. No cloud account tied to the schedule at all.

Built Into the CLI

/loop and /schedule: Claude Code's Own Scheduling Commands

/loop is the fastest way to try this. Type /loop 5m check the deploy and tell me if it finished and Claude Code converts that interval into a cron expression, schedules the job inside the current session, and reruns your prompt every five minutes until you stop it or seven days pass, whichever comes first. Leave off the interval and Claude chooses one dynamically instead, waiting longer once whatever it's watching goes quiet.

The catch is right there in how it works: /loop is session-scoped. The tasks it creates only fire while that particular Claude Code session is still running and idle on your machine. Close the terminal, and they stop. That makes /loop excellent for babysitting a deploy or a pull request for an afternoon, and the wrong tool for anything that needs to survive you shutting your laptop.

/schedule is the other built-in command, and it solves exactly that gap. Describe a recurring task in plain language, such as /schedule daily PR review at 9am, or a one-off like /schedule in 2 weeks, open a cleanup PR that removes the feature flag, and Claude Code saves it as a cloud scheduled task, what Anthropic called a Routine before renaming it. From then on it runs on Anthropic's own cloud infrastructure, triggered by a schedule, an API call, or a GitHub repository event, with no dependence on your machine being on at all.

Custom cron intervals for a /schedule task are capped at once per hour; anything more frequent is rejected, a deliberate floor rather than a bug, since this is work meant to run unattended instead of being polled continuously. /loop has no such floor: its cron tools support one-minute granularity, because a session you're actively watching can tolerate a much tighter loop than one running completely on its own.

Three More Ways to Run Unattended

Cloud Sessions, GitHub Actions, and Your Computer's Own Scheduler

A cloud session is the broader category that a /schedule task actually runs as. You can start one directly, with no schedule attached at all, from claude.ai/code in your browser, from the Code tab in the Claude mobile app, or with claude --cloud "your task" from your own terminal. However you start it, the session runs on Anthropic-managed infrastructure instead of your laptop, keeps going after you close that laptop, and you can check on it or steer it from any device signed into the same account.

GitHub Actions takes the trigger outside Claude Code entirely and puts it on your repository instead. The Claude Code GitHub Action, anthropics/claude-code-action, runs inside a workflow file you add to .github/workflows/. Give it a prompt input and it runs that prompt automatically on whatever GitHub event you configure the workflow to listen for: a pull request being opened, an issue being labeled, or a plain cron schedule trigger like any other scheduled workflow. Mention @claude in a comment instead, with no prompt input set, and it switches to responding directly to that mention rather than running on its own.

The plainest option skips Anthropic's own scheduling infrastructure altogether. claude -p, the p standing for print, runs Claude Code non-interactively: it takes a prompt, runs it once, prints the result, and exits with a status code your script can check. Point cron on macOS or Linux, launchd on macOS, or Task Scheduler on Windows at a line that calls claude -p "your prompt" --allowedTools "...", and the operating system itself becomes the thing deciding when Claude runs, with no cloud account or subscription tier involved in the scheduling at all.

Pair claude -p with a permission mode and a flag to turn off permission prompts when nothing is going to be at the keyboard to answer one. Without that pairing, an unattended run can simply stall, waiting on an approval nobody is there to give.

Before You Save the Schedule

What to Check Before You Let Anything Run Unattended

These checks apply to every method above. They're about what the schedule is allowed to touch, not which one you picked.

Scope Its Permissions Narrowly

Decide which tools, repositories, and connectors a scheduled run actually needs, and grant only those. A task that only has to read a log file has no reason to hold write access to your entire codebase.

Set a Spending Limit

An unattended run can call the API far more times than you'd ever type by hand. Cap it, whether that's a turn limit on a single invocation or a budget alert on the account running the schedule.

Keep a Visible Run History

Every method here keeps some record of what ran and when: a session transcript, a workflow run log, or a line your own script writes to a file. Read it, especially for the first week.

Add a Human Approval Step for Anything Risky

Nothing unattended should complete a payment, send a message to a real person, push to a protected branch, or delete something, without a person approving that specific action first.

Give It a Heartbeat

Set up some way of noticing if a schedule silently stops firing: a weekly glance at the task's run history, or a separate reminder that checks whether its last report actually arrived on time.

Matching the Tool to the Job

Which One Should You Actually Use

Start with where the work needs to happen, not with which method sounds most capable. If you're actively watching a deploy or a pull request this afternoon and already have a Claude Code session open, /loop costs nothing extra to try and stops the moment you close the terminal.

If the job needs to survive you closing your laptop and run again tomorrow regardless, reach for /schedule, a cloud session, or GitHub Actions instead. /schedule is the fastest of the three to set up from inside a conversation you're already having. A cloud session at claude.ai/code suits a single substantial task you want to hand off and check on later rather than something recurring. GitHub Actions is the right choice when the trigger itself is a repository event, a pull request, an issue, a release, rather than a clock.

Reach for your own operating system's scheduler and claude -p when you want zero dependence on any cloud account for the scheduling itself, when the job already lives alongside other cron jobs you maintain, or when your organization's policy keeps automation on infrastructure it controls directly rather than a vendor's cloud.

Putting It Together

What This Looks Like Once It's Running

Picture a /schedule task set for every weekday morning. It wakes on its own because a trigger, not a person, started the session. It clones the repository fresh, reads the pull requests opened since yesterday, and checks each one's CI status and review comments against the project's own CLAUDE.md conventions.

It doesn't merge anything, and it doesn't push to the default branch. It opens a draft summary, or a small pull request of its own if the prompt specifically authorized that, and stops there, the same way the sibling methods in this guide do: a GitHub Actions run posts to the pull request it was triggered from and nowhere else; a cron job calling claude -p prints its result to a log file and exits with a status code; a /loop session tells you what it found and waits for its next interval.

In every case, the schedule is doing one job: starting the session so a person doesn't have to remember to. Everything after that, what the session is allowed to touch and what it has to ask about first, is still a decision you made when you wrote the prompt and chose the permissions, not something the schedule decides on its own.

Practice Writing the Brief Before You Automate Something Bigger

Writing a prompt a Claude Code session can run unattended, and knowing exactly which permissions to leave out, is the same skill whether the trigger is /loop, /schedule, a GitHub event, or a line in cron. Nightschool AI's free lesson on hooks and automation walks through wiring up an automated run with an approval gate, using Claude Code as the example.

Frequently Asked Questions

What does it actually mean for Claude to run automatically?

It means a Claude Code session starts itself from a prompt you saved earlier, works through that prompt on its own, and reports back, with nobody opening a terminal or a chat window at that moment. The schedule decides when it starts; the prompt and the permissions you set still decide everything it's allowed to do.

What's the difference between /loop and /schedule in Claude Code?

/loop reruns a prompt inside a session that's still open on your own machine, and stops the moment you close that session. /schedule saves a prompt as a cloud scheduled task that runs on Anthropic's own infrastructure instead, on a timer, an API call, or a GitHub event, whether or not your machine is on.

Do I need Claude Code open on my laptop for a scheduled task to fire?

Only for /loop, which is session-scoped and stops firing the moment the session closes. A task created with /schedule, a cloud session at claude.ai/code, and a GitHub Actions workflow all run on infrastructure other than your laptop, so none of them need your machine to be on.

Can a GitHub Actions workflow run Claude Code on a schedule instead of only on a pull request?

Yes. Give the Claude Code GitHub Action a prompt input and configure the workflow's trigger as a cron schedule, the same way you'd schedule any other GitHub Actions workflow, and it runs that prompt automatically at the times you set, with no pull request or issue needed to kick it off.

What is claude -p, and why would I call it from cron or Task Scheduler instead of using /schedule?

claude -p runs Claude Code non-interactively from the command line, printing its result and exiting with a status code instead of opening a chat window. Calling it from your own operating system's scheduler keeps the scheduling itself off any cloud account, which matters if your policy requires automation to stay on infrastructure you control.

Is a cloud session at claude.ai/code the same thing as a scheduled task?

A scheduled task created with /schedule runs as a cloud session, but you can also start a cloud session directly, with claude --cloud or at claude.ai/code, for a one-off piece of work with no schedule attached at all. A scheduled task is a cloud session with a trigger saved in advance; not every cloud session has one.

What should I never let an unattended Claude Code run do on its own?

Complete a payment, send a message to a real person, push to a protected branch, or delete something, without a person approving that specific action first. Those cover almost everything that's hard to undo. Reading, drafting, summarizing, and flagging are reasonable to automate fully from the start.

Is this guide affiliated with or endorsed by Anthropic?

No. This is an independent educational guide. It names Anthropic's Claude and Anthropic's Claude Code descriptively, to explain real tools accurately, without any affiliation, endorsement, or partnership with Anthropic.

Do I need a paid plan to use /schedule or start a cloud session?

Cloud scheduled tasks and cloud sessions are available on Pro, Max, Ultra, and Team plans, and for Enterprise users with the right access, rather than on every free tier. /loop and claude -p calling into your own scheduler carry no such plan restriction tied to the scheduling itself.

Turn This Into Your First Unattended Claude Code Run

Pick one narrow job, write what it should never do on its own, choose the method that matches where the work needs to happen, and watch its first few runs before trusting it with more.

Nightschool AI is an independent learning platform and is not affiliated with, endorsed by, or sponsored by Anthropic. Claude is a trademark of Anthropic, PBC. Looking for Anthropic's official Claude Academy? It's at academy.claude.com.