Short answer: Not on your laptop itself. /loop, Claude Code's cron tools, and claude -p all run on your machine, so they stop when it sleeps. If you don't want to keep the laptop open, the work has to run on some other computer that stays on. You have three options: Claude's cloud scheduled tasks (managed by Anthropic, fresh environment every run), your own always-on machine (a Mac mini or a VPS you maintain), or a managed personal cloud computer like fl0w that keeps your files and syncs your setup.
Why closing the lid stops Claude Code
Claude Code is local to your computer. Its scheduling features (/loop, and the cron tools Claude uses when you say "every morning at 9, do X") are tied to your session, so Claude Code has to be running. The docs say so directly: tasks only fire while Claude Code is running and idle, and closing the terminal or letting the session exit stops them. A sleeping laptop is an exited session as far as the scheduler cares, and missed runs aren't replayed when you open the lid.
Running claude -p from crontab has the same problem one layer down: cron doesn't fire on a sleeping Mac.
So the real question is: which other computer should run it?
Option 1: Claude scheduled tasks in the cloud
Anthropic has what used to be called routines and is now called scheduled tasks. You save a prompt, pick one or more GitHub repositories and your claude.ai connectors, and attach a trigger: a schedule, an API call, or a GitHub event. It runs in the cloud, so your laptop can be closed, off, or on a plane.
Create one at claude.ai/code/routines, from the desktop app, or from any Claude Code session:
/schedule every weekday at 8am summarize new issues in my repo and post the summary to Slack
I think cloud scheduled tasks are how most people will want to run automations from Claude Code. The examples are things like "build me a daily digest" or "check on the price of this." Those fit a remote environment that doesn't need to be set up a certain way, and cloud scheduled tasks are included in paid Claude plans.
Limitations
The thing I ran into is that Claude's remote environment is different from your local environment. I'm building an app that has a CLI component and a web app component. A lot of the time, I need to make changes in both, or change the web app based on how the CLI's behavior changed. Locally I have a folder with both codebases side by side, but the remote environment for a scheduled task is hard to customize that way. You can connect your GitHub, of course, but that's about it.
- No personal sandbox. Each run happens in a short-lived sandbox that clones your repos fresh. When the run ends, so does the environment. You can't build up a folder of notes, screenshots, or generated files across runs unless you commit them to GitHub every time.
- Your local repos and folders don't come along. Only GitHub repositories you've connected do. Local-only folders, uncommitted work, a directory of prompt templates, and dotfiles don't.
- Your local MCP servers aren't there. Servers you added with
claude mcp addlive on your machine, not your claude.ai account, so they don't show up in the connector list. You'd have to re-add them as connectors or commit a.mcp.json. - Not built from existing sessions. You start from an empty prompt box and copy in whatever worked locally.
- Hourly minimum, and it's still a research preview.
Option 2: Your own always-on machine
There was a big boom of people buying Mac minis for exactly this, but not all of us have a spare computer lying around. You can also rent a VPS, which I think is a great option: a separate computer running remotely that you can SSH into whenever you'd like. Install Claude Code there, then use /loop in a backgrounded session or claude -p from cron.
A personal machine or VPS is nice because your setup is exactly how you want it. The catch is that you're now running a server:
- Make sure the box has your Claude Code subscription and auth set up, and re-run OAuth for every MCP server on it before the tokens expire.
- Copy your skills,
CLAUDE.md, MCP config, and secrets over, then keep them in sync by hand as you change them locally. - Deal with SSH keys, port forwarding for anything with a callback URL, updates, and logs.
- Look at files on the box. There's no file explorer unless you set up a virtual desktop, which is a whole other can of worms.
Maybe this is laziness and a skill issue on my part, but I find it daunting to SSH in, set up port forwarding, and do everything else a remote computer needs. After the first time, it may well be the best way to run agents remotely. But it's DevOps work, and that's not something I wanted to do.
Option 3: A personal cloud computer that's managed for you (fl0w)
The point of fl0w is to give you that VPS experience, a computer that's truly yours, without the DevOps maintenance or tunnel forwarding.
- Every user gets their own sandbox that persists across sessions. It's almost like having a VPS, except we manage it for you. Repos you clone, folders you create, and files your workflows write are still there next time. That's the big difference from short-lived cloud sandboxes.
- Your setup follows you. You use the CLI to set up your MCP servers, skills, and everything else the way you want them locally. All of that is encrypted and synced to your cloud computer, and changes on either side sync back. See MCP servers in the cloud.
- No SSH. Open your cloud computer in the browser, on your phone or laptop, and you get a terminal, a native file explorer, and run history for every workflow.
- Turn what already works into a job. Run the task once in a session, type
/generate, and it becomes a workflow that runs on a schedule, from a webhook, or from a hosted form, all with your laptop closed. See turning a session into an automation.
curl -fsSL https://raw.githubusercontent.com/jackmuva/fl0w/main/install.sh | bash
fl0w login
One honest caveat: fl0w runs its own agent harness, not the claude binary. It borrows from Claude Code and OpenCode, it runs Claude models, and it can load the skills you've installed for Claude Code. If you need Claude Code specifically, use Option 1 or 2. If you need the work to keep going while your laptop is shut, on a computer that's set up like yours, try fl0w.
Which option should you pick?
| If your task… | Use |
|---|---|
| Only needs a prompt, a GitHub repo, and claude.ai connectors | Claude cloud scheduled tasks |
| Needs Claude Code specifically, and you're comfortable running a server | Claude Code on a Mac mini or VPS |
| Needs persistent files, multiple local repos, or your own MCP servers, without server upkeep | fl0w |
FAQ
Can Claude Code run while my laptop is closed?
Not locally. /loop, scheduled cron tasks, and claude -p cron jobs all stop when your laptop sleeps. Use Claude's cloud scheduled tasks, an always-on machine, or a managed cloud computer like fl0w.
Does /loop keep running when my Mac goes to sleep?
No. Session-scoped tasks only fire while Claude Code is running and idle, and runs missed while the machine was asleep aren't replayed.
Can I keep my laptop awake instead?
You can, with something like caffeinate on macOS, but then the laptop has to stay plugged in, open or docked, and online. That's fine for a one-off overnight job and fragile for anything recurring.
Do Claude cloud scheduled tasks keep files between runs?
No. Each run clones the selected repositories fresh and the session ends when the run finishes. To keep output, commit it, send it somewhere through a connector, or use an environment that persists, like a VPS or fl0w.