Cube

How to keep Claude Code running after you close your laptop

When your Mac sleeps, Claude Code stops. Here are the four ways around that, from a one-line command to a computer that never sleeps.

Published

A Claude Code task runs as a process on your computer. When the computer sleeps, the process stops, so the real question is where the process lives. Here are four answers.

1. Stop your Mac from sleeping

For a one-off task, keep the Mac awake while Claude Code works. In a second terminal:

caffeinate -dims

That prevents sleep until you press Ctrl-C. With the lid closed, a MacBook still sleeps unless it’s on power with an external display attached, so this only really works with the lid open.

Good for: one task, today. Not for: leaving the house.

2. Run Claude Code on a server, inside tmux

Move the work to a machine that stays on, like a VPS or a desktop at home, and run Claude Code inside tmux so it survives your SSH connection dropping:

ssh my-server
tmux new -s claude
claude
# detach with Ctrl-b then d; your task keeps running

Later, from any device:

ssh my-server
tmux attach -t claude

Good for: full control. The catch: it’s your server to maintain. Small instances run out of memory, updates restart the box, and you set up repos, keys and credentials yourself.

3. Use Claude Code cloud sessions

Anthropic can run a Claude Code session on a VM it manages. Start it from the browser, the desktop app, your phone or the terminal, and it carries on when you close your laptop. There’s no separate charge for the VM; it counts against your plan’s usage.

Good for: a single task with nothing to set up. The catch: the VM is temporary. It’s reclaimed when the session goes idle, and in-flight background work is lost. Your own toolchain doesn’t persist between sessions.

4. Give Claude Code its own always-on computer

Cube is a full Linux computer in the cloud with a Mac app. Sign in with GitHub, install Claude Code from the list, and start a task. Close your laptop; it keeps running. Check in from your phone or come back later to the same session, with your repos, tools and files where you left them.

Good for: long and parallel tasks, every day, without running a server.

Which should you pick?

  • One task, you’re staying at your desk: caffeinate.
  • You enjoy running servers: a VPS with tmux.
  • A quick task from the browser: Claude Code cloud sessions.
  • Agents that run for hours, most days: an always-on computer like Cube.

Questions

Does Claude Code keep running when I close my MacBook?

Not by default. Closing the lid puts the Mac to sleep, and every process on it, Claude Code included, pauses until it wakes.

Does tmux keep Claude Code running if my laptop sleeps?

Only if tmux runs on another machine. tmux keeps a session alive when your SSH connection drops, but if tmux is on your laptop, it sleeps with the laptop.

What’s the simplest way to run Claude Code 24/7?

Run it on a machine that stays on. That can be a server you manage, a Mac mini at home, or a managed cloud computer like Cube.

A new home
for your agents.

Download for Mac

Enter your email to receive the Cube installer link. Open it on your Mac to install Cube.