Practice
Keep Claude Code working when you close the laptop
A long agentic task and a closing laptop lid don't mix. There are four reliable fixes, and which one is right depends on whether you own a machine that can stay awake.
Quick answer
Claude Code stops when your laptop sleeps, and Remote Control only reconnects once it wakes. To keep work going with the lid shut, run the session somewhere that stays awake: Anthropic's cloud sessions (GitHub repos), a VPS with tmux or a session daemon such as Maude, or an always-on desktop like a Mac mini.
You give Claude Code something that will take forty minutes, then you need to leave. By default the work stops when you close the lid. There are four reliable ways around that, and which one fits depends on a single question: do you own a machine that stays awake?
Why it stops
Three different things can end a session. They're worth telling apart, because each fix only deals with some of them:
- The process stops. The machine sleeps, or the shell that owned
claudeexits. Nothing runs on a sleeping laptop, whatever app you use. - The connection drops. You lost signal, or your phone suspended the app. The process may be fine; you just can't see it.
- The session gets lost. The process survived, but nothing knows how to put you back in front of it, or tell you that it finished.
Anthropic's own Remote Control shows the difference well. Its docs say that if your laptop sleeps or the network drops, Claude Code reconnects when the machine comes back online. That fixes the connection. It doesn't keep anything running while the lid is shut, because "your computer has to stay on and the claude process has to keep running".
Option 1: Anthropic's cloud sessions
If you don't own a machine that stays awake, move the work off your machines entirely. Cloud sessions run Claude Code in an Anthropic-managed VM. The session keeps going after you close your laptop, and you can check on it from the Claude app, a browser or the terminal. They left research preview on 23 September 2026. They're available on Pro, Max and Team, and to Enterprise users with premium or Chat + Claude Code seats.
You can start one from your terminal and walk away:
claude --cloud "Fix the flaky test in auth.spec.ts"
The cloud VM clones your GitHub remote at the current branch, so push first. When it's done, claude --teleport pulls the session and its branch back into your terminal. What to know before relying on it, from the cloud sessions docs:
- Cloning and pull requests need GitHub.
- The session can't see your private network or local database.
- Usage comes out of the same limits as the rest of your Claude usage.
- Idle VMs are reclaimed after a while. Reopening restores the conversation, but not background work that was still running.
We compare this route in more detail in Maude vs Claude Code on the web.
Option 2: a server with tmux or systemd
The classic answer is to run Claude Code on a VPS, which never sleeps, inside tmux, which owns the process so your SSH connection doesn't have to:
tmux new -s work
# start claude, then Ctrl-B then D to detach
tmux attach -t work
This fixes all three problems: the process lives on an always-on box, a dropped connection doesn't touch it, and tmux attach puts you back in front of it. It costs a few euros a month, and our VPS setup guide walks through it.
Two upgrades are worth knowing about:
- Remote Control inside tmux. Run
claude remote-controlin the tmux session and you can drive it from the Claude app's Code tab, with push notifications, instead of a terminal. That combines Anthropic's official app with a machine that never sleeps. - systemd for reboots. tmux doesn't survive a reboot. A systemd service (a user unit with lingering enabled, so it starts without a login) can bring a long-running process back at boot. Claude Code itself doesn't resume a turn that a reboot interrupted.
claude --continuereopens the most recent conversation in that directory so you can tell it to carry on.
On a phone, the catch is mostly ergonomic. A plain tmux session can't notify you when the work is done, and reattaching means a full-screen terminal and a soft keyboard. More on that in tmux, mosh and Tailscale for coding agents.
Option 3: a session daemon (Maude)
This is the same idea one layer up. A small long-running process on the server owns every agent session and records what happens in it. Clients attach and detach, and the session doesn't notice. Compared with tmux:
- Reattaching gives you the conversation itself, not a screen buffer to scroll through.
- Several devices can follow the same session.
- Something is still watching when you aren't, so you can get a push notification when the work is done or needs a decision.
This is how Maude works. When you add a server, the app deploys its own daemon over SSH and registers it to start at boot: a systemd user unit on Linux, a LaunchAgent on macOS, and a cron @reboot entry as the fallback. Sessions keep running on the server when you close the app or your laptop. The inbox shows which ones finished, errored or need you, and push notifications let you answer a permission prompt with Allow or Deny without opening anything. Like any process, a turn that's running during a reboot is interrupted, but the conversation is kept and you can carry on from the app.
The same daemon runs Codex, OpenCode, Grok Build and Antigravity, so this works for whichever agent you start. We cover the multi-agent version in running coding agents 24/7.
Option 4: an always-on machine at home
If you already own a desktop that's always on, such as a Mac mini, a workstation or a home server, it can play the server's role at no extra cost. Use Remote Control, tmux or Maude on it, exactly as you would on a VPS. A few practical points:
- Stop it sleeping. macOS's Energy settings have an option to prevent automatic sleeping when the display is off.
caffeinatekeeps an open Mac awake from the command line, but it doesn't stop a MacBook sleeping when you close the lid. - A closed MacBook only stays awake in closed-display mode, which needs an external display connected and power. That's fine on a desk and no use in a bag.
- Reaching it from outside. Remote Control and Maude's relay both connect outwards, so the machine doesn't need an open port. For plain SSH, Tailscale is the usual way in.
Choosing
| Approach | Keeps running with your laptop shut | Needs | Notifies you |
|---|---|---|---|
| Cloud sessions | Yes | A repository on GitHub | Yes |
| tmux on a VPS | Yes | A server | No |
| Remote Control inside tmux on a VPS | Yes | A server, a Claude plan | Yes |
| Session daemon (Maude) | Yes | A server and the app | Yes |
| Always-on home machine | Yes | A desktop that never sleeps | Depends on the tool |
| Remote Control on the laptop itself | No, it reconnects when the laptop wakes | Nothing extra | Yes |
| tmux on the laptop itself | No | Nothing extra | No |
Do you own a machine that stays awake? If yes, put the session on it and use tmux, Remote Control or a daemon. If no, the work has to move somewhere that's awake by default: a cheap VPS you rent, or Anthropic's cloud sessions.
One thing that helps either way
A task nobody is watching should be written so it doesn't need watching. Say where to stop, what to do on failure, and what not to touch. "Fix the failing tests in api/; if a fix needs a schema change, stop and explain instead" holds up far better than "fix the tests". The specific instruction keeps a forty-minute unattended run from wandering off. Also decide in advance how much it may do without asking: running Claude Code with full permissions, safely covers that trade-off.
Run it from your phone
To keep Claude Code running on your own server and check on it from your phone, see Claude Code on your phone. For every option, including the free ones, see every way to run Claude Code on iPhone and iPad.
Frequently asked questions
Does Claude Code keep running when my Mac sleeps?
Will tmux survive a reboot?
claude --continue reopens the most recent conversation in that directory. A systemd user service brings the tooling back without you logging in, and so does a session daemon that registers itself to start at boot, such as Maude's daemon.Can I run Claude Code on a Mac mini at home?
Can I get a notification when a task finishes?
/config, and cloud sessions are tracked in the app. Maude pushes when a session finishes, errors or needs approval, with Allow and Deny buttons. A bare tmux session can't notify you at all.What changed
- — Rewritten: cloud sessions are out of research preview, Remote Control reconnects after sleep but doesn't run during it, Remote Control inside tmux on a server, reboot handling with systemd and --continue, always-on home machine option.
- — First published.