Cubs

Guide 01

Keeping an agent running after the laptop closes

Every method below works for a while. The question that decides between them is not how they start a process, it is what happens to that process when the screen goes dark.

Published 2 Dec 2026

The four options

There are only four things people actually do, and they fail in different ways.

1. Keep the Mac awake. caffeinate -dims stops the display, disk and system from sleeping for as long as it runs. It works, and it is what most people try first, because it costs nothing and takes one command.

Two caveats. With the lid closed, macOS suspends on its own schedule unless the machine is on power and configured not to; the process keeps the system busy but cannot argue with the lid switch forever. And the laptop is now a machine that never sleeps, sitting on a desk with the fan going, which is exactly the thing a laptop is bad at.

# Run an agent with the system kept awake, in a terminal that survives a disconnect
caffeinate -dims tmux new -s agent 'claude'

2. A server and tmux. Move the work to any Linux box you can SSH into and run the agent inside tmux. This is the honest DIY answer: the machine is always on, the agent is a child of a session that outlives your SSH connection, and reattaching is one command.

ssh you@your-server
tmux new -s work
# inside the session
claude
# detach with Ctrl-b then d
# later
tmux attach -t work

The part people get wrong is thinking tmux is what keeps the work alive. tmux keeps the process alive across a disconnect. A reboot, an out-of-memory kill or a sleeping host stops it just as dead as anything else.

3. A cloud session from the agent vendor. Some vendors now offer their own hosted sessions. These are genuinely convenient — nothing to install — but they are temporary by design, the workspace is reclaimed when idle, and the usage counts against the same plan you already pay for. Fine for a task, poor for a project that needs the same machine tomorrow.

4. A computer that stays on. Either a machine at home or a cloud machine dedicated to the work. This is the only option where closing your laptop is genuinely irrelevant, because the machine is not your laptop.

What actually happens when the lid closes

The mechanism is worth knowing, because it explains why most of the advice online does not work. Closing the lid on a Mac triggers a sleep request, and sleep is the operating system suspending the kernel: no process runs, no network stays up, the agent’s event loop stops mid-await. Nothing about the agent is at fault, and no flag passed to the agent changes it.

Power settings can override part of that. On a Mac on AC power, caffeinate can hold off idle sleep and disk sleep. It cannot hold off a closed lid indefinitely, and it cannot hold off a low battery, an update that decides to restart, or a kernel panic. On Windows the equivalent is powercfg /change standby-timeout-ac 0, which again addresses the timeout and not the lid. On Linux it is the lid switch in /etc/systemd/logind.conf:

# Ignore the lid entirely: the machine keeps running with the lid shut.
# This is the one setting that genuinely survives a closed lid on Linux.
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore

Run sudo systemctl restart systemd-logind afterwards, and know that you have just told a laptop to keep running with its vents covered.

The part the disconnects people miss

A session that detaches is not the same as a session that dies, and the difference costs people hours. Three distinct failures get conflated:

What happened Symptom What it actually is
SSH connection dropped Terminal hangs, then Connection to host closed The process may still be alive; only your view of it died
Shell exited without nohup or tmux Agent stops the moment you close the terminal SIGHUP sent to the process group
Host suspended or rebooted Nothing running when you return The kernel stopped; no signal was sent to anyone

Only the third one is fatal to the work in a way you cannot recover from, and only the third one is caused by the laptop rather than by how you started the process. That is why the advice “use tmux” keeps appearing next to the advice “use a server”: they solve different rows of that table, and people recommend whichever one fixed their particular incident.

What a remote agent costs you in attention

There is a cost that does not appear in any pricing table: an always-on agent is producing output while you are not looking, and someone has to read it. An agent that runs for six hours unattended has made hundreds of small decisions you have not reviewed, and the review is the work.

Two habits keep that manageable, and they matter more than which hosting you pick:

  • Cap the blast radius per task. One branch and one worktree per task means an agent that went sideways overnight is a branch you delete, not a repository you repair. git worktree add ../task-a -b task-a is the whole setup.
  • Make the agent write progress to a file, not to scrollback. A PROGRESS.md in the repository that the agent updates as it goes survives a crash and is what you read in the morning. A terminal buffer does not, and a resumed session tells you nothing about what happened while it was dead.

Neither habit depends on the machine. They are what make an always-on machine worth having, because an always-on agent without them just produces more to review.

How to choose

Decide by what has to survive.

  • A single task finished in an hour, on a machine you are sitting at: keep the Mac awake. Stop reading.
  • Work that has to outlive a disconnect but not a reboot: tmux on a server.
  • Work that has to outlive you leaving, repeatedly, for days: a machine that stays on.

Most people arrive at option four only after losing an agent’s progress for the third time. That is the expensive way to learn it.

Where the product fits

The fourth option is what this product is. The machine has its own power and network, agents run on it, and every terminal and preview is reachable from a browser, a phone or SSH. Closing the laptop does not pause it; pausing is a thing you choose, and pausing deliberately keeps the disk so nothing is lost.

Questions

Questions

Does an agent keep running if I close the MacBook lid?
Not by default. With the lid closed the machine suspends, and a suspended machine runs no processes. Tools that claim otherwise are either keeping the CPU awake at the cost of heat and battery, or running the work somewhere other than the laptop.
Does tmux help if the laptop sleeps?
No. tmux protects a process from a dropped SSH connection, not from the operating system being suspended. If the machine sleeps, the whole kernel stops with it and tmux stops too. tmux solves the disconnect problem and nothing else.
What is the simplest way to run an agent around the clock?
Put it on a computer that is not the one you carry. That can be a desktop under a desk, or a cloud machine. Either way the deciding property is that the machine has its own power and its own network, so closing your laptop changes nothing about it.

Read next

A new home for your agents

A machine that stays on, with your coding agents on it. $25 of credit to start, no card.

Get the download link

Enter your email and we will send the download link when the signed build ships. Open it on a Mac with Apple Silicon.

One message when the build is signed. No newsletter.