· 5 min read
How to run Claude Code 24/7, even with your laptop closed
How to keep Claude Code running 24/7: cloud scheduled tasks, cloud sessions, GitHub Actions and an always-on server compared. Why it stops when your laptop sleeps, what breaks when nobody is watching, and how to know an always-on agent actually did the work.
Claude Code stops when your laptop sleeps because it runs on your laptop. To keep it running 24/7, move it to a machine that stays on: Anthropic's cloud scheduled tasks or cloud sessions, GitHub Actions, or your own server. Then add what always-on work needs most, a way to know each run actually did the job.
Why does Claude Code stop when I close my laptop?
Claude Code is a process on your computer. When the laptop sleeps, every process on it pauses, and tmux sessions pause with them. On a Mac, caffeinate -i holds off idle sleep while a command runs, but closing the lid on battery still sleeps the machine.
Remote Control doesn't change that. It reconnects after your machine wakes, but nothing runs while it sleeps. Closing the lid can even end work that runs elsewhere: an open feature request about the Desktop app's SSH remote (#49790, 48 reactions) asks for remote sessions to survive the client disconnecting.
So the fix is always the same: the session has to live on a computer that stays on. The options differ in whose computer that is and what starts the work. If you run many sessions at once, managing many agent sessions covers the day-to-day side.
What are the ways to run Claude Code 24/7?
| Option | Runs on | What starts it | Your machine must stay on | Asks you mid-run |
|---|---|---|---|---|
| Cloud scheduled tasks | Anthropic's cloud | A schedule, an API call or a GitHub event | No | No, runs on its own |
| Cloud sessions | A virtual machine Anthropic manages | You, from the web, the Claude app or claude --cloud | No | Yes, you answer in the app |
| GitHub Actions | A GitHub runner | Repo events, @claude mentions or a cron schedule | No | No |
| Your own server | A VPS or an always-on desktop | cron, or a session in tmux | No, the server does | Only when you attach |
| Desktop scheduled tasks | Your computer | A schedule | Yes | Configurable per task |
/loop | Your open session | An interval, from 1 minute | Yes, with the session open | Like the session |
| Kavela | A cloud computer for each agent | A message, a schedule or an event | No | Yes, in an Approvals inbox |
/loop and Desktop scheduled tasks look like always-on, and both need your machine awake. Recurring /loop tasks also expire after 7 days. What each option costs on your plan is compared in the best way to work with Claude Code in the cloud.
How do I set up a Claude Code scheduled task in the cloud?
Scheduled tasks, called routines until recently, run Claude Code on Anthropic's cloud with your laptop closed. They are in research preview on Pro, Max, Team and Enterprise plans.
- Create one at claude.ai/code/routines, or type
/schedulein Claude Code. - Give it a prompt, one or more repositories, and the connectors it needs. Remove the connectors it doesn't need, because a scheduled task can use every tool of an included connector, including writes, without asking.
- Add a trigger. A schedule (hourly, daily, weekly, a custom cron expression or a one-off time), an API call with a bearer token, or a GitHub event such as a pull request or release.
The limits worth knowing:
- The shortest interval is one hour. A run set exactly on the hour can start several minutes late, so the docs suggest a time like 9:07 over 9:00.
- Each account gets 100 scheduled runs an hour. None of the hourly limits has overage.
- Runs draw on your plan's usage. Past your limit, runs are rejected until the window resets, unless your organization turns on usage credits.
To find out why a run did nothing, ask: /schedule why did my nightly review do nothing this morning?
How do I run Claude Code continuously on my own server?
On an always-on server you have two patterns.
A job on a timer. A script that runs headless Claude Code, started by cron:
#!/bin/bash
# ~/jobs/daily-triage.sh
source ~/.config/claude-token.env # CLAUDE_CODE_OAUTH_TOKEN=... from claude setup-token, chmod 600
cd ~/app
claude -p "Triage new GitHub issues: label each one and write a summary to reports/triage.md" \
--permission-mode acceptEdits \
--allowedTools "Bash(gh issue *)"
# crontab -e: weekdays at 07:00
0 7 * * 1-5 /home/dev/jobs/daily-triage.sh >> /home/dev/logs/triage.log 2>&1
A session that never closes. Claude Code in tmux, with claude remote-control so you can check on it from your phone. /loop inside that session handles polling, such as checking a deploy every few minutes, as long as you recreate it before the 7-day expiry.
Server setup, headless login and security are in Claude Code on a VPS. More cron and GitHub Actions recipes are in the Claude calendar guide.
What breaks when Claude Code runs unattended?
Always-on fixes the closed laptop. It also brings failures you never see at your desk, and most of them are quiet.
- A green run can be a failed job. Anthropic's docs on scheduled tasks: a green status means the session exited without an infrastructure error, and "does not mean the work your prompt describes succeeded."
- Approvals go missing. Headless
claude -pdenies anything that would prompt and carries on. Desktop scheduled tasks can stall waiting for an approval nobody gives (#101851). Cloud scheduled tasks never ask at all. - Logins lapse. A cloud scheduled task whose GitHub connection expires skips runs for up to 72 hours, then turns itself off. A setup token lasts a year.
- Usage limits stop work mid-run. Two open requests about it have 215 and 106 reactions, the second asking to "auto-continue after subscription rate limit resets".
- Nobody reads the output. A report written at 3am to a log file nobody opens is the same as no report.
How do I know an always-on agent actually did the work?
- Write "done" into the prompt. Name the output: a pull request, a file at a known path, a comment on the issue.
- Ask for proof. A passing test run, a link, a count. A summary that says "done" is a claim.
- Make failure loud. End every run with a last line such as
DONEorBLOCKED: <reason>, and alert on anything else, including no line at all. - Put results where you already look, such as a pull request or a channel you read.
- Have something other than the worker check it. A reviewer with read-only tools, checking the output against the definition of done, catches the run that went green and did nothing.
The fifth matters most once there are more runs than you can read.
How does Kavela run Claude Code around the clock?
Kavela's workspace is a calendar. You tell Kav, the lead agent, what should happen and when, and it lands as a task that runs as soon as possible or at a set time, a routine (every Monday at 8:00 in your time zone, optionally between a start and an end date), or an event that fires on a webhook from any service or a file added to the workspace.
Every run happens in the agent's own cloud computer, with a shell, files, git and a real browser, and Claude Code runs there on your own Claude plan. Your laptop can stay closed. When a run needs you, the agent posts one card to the Approvals inbox and ends its turn; your answer starts its next turn, and other work keeps running meanwhile.
Every workflow run is checked by a second agent against your checklist. Work that falls short goes back with the exact gap, and after three tries you're told what's missing. A checklist line that fails twice is raised with you. When your plan reaches its limit, the task waits and picks up after the reset, or you choose to finish it on Kavela credits. Results arrive as deliverables attached to the task.
Kavela starts with a 14-day free trial, no card. Start your free trial