shedix

Keep Claude Code running after you close your laptop

Claude Code does its work on the computer you start it on. It reads your files, runs your tests and calls the model from there. When that computer is a laptop, the agent's working day ends whenever the laptop's does: the lid closes for a commute, the train's Wi-Fi drops, the battery runs out.

Why the agent stops

The lid closes. A sleeping laptop pauses every process on it, claude included, along with any build or test run it started. Nothing moves until you open the lid again. Anthropic's Remote Control docs make the same point about phone access: the phone and browser are only windows into a session on your computer, so the computer has to stay on and the claude process has to keep running.

The Wi-Fi drops. Each step the agent takes starts with a request to the model. Without a connection, it can't take the next one.

The SSH connection drops. If you already run Claude Code on a remote machine, a dropped SSH session ends the shell you started it from, and the agent goes with it. The same docs recommend starting claude inside tmux or screen on a remote machine for exactly this reason.

So the fix has two parts. Run the agent on a machine that stays on, and run it inside tmux so it doesn't depend on your connection.

Run it in tmux on a remote machine

tmux keeps terminal sessions alive on the machine where it runs. The tmux manual describes its sessions as persistent: they survive an accidental disconnection, and you can detach from one and reattach later.

ssh dev@203.0.113.10
cd ~/work/myapp
tmux new -s claude
claude

Give Claude Code its task. Then press Ctrl-b, let go, and press d. You're back at the plain SSH prompt, and the session keeps running on the machine. Log out, close the laptop and go.

Reconnect later

From any computer with your SSH key:

ssh -t dev@203.0.113.10 tmux attach -t claude

-t asks ssh for a terminal, which tmux needs when you start it as a remote command. tmux ls lists the sessions on the machine. If you'd rather have one command that always works, tmux new -A -s claude attaches to the session when it exists and creates it when it doesn't.

If a session was lost anyway, say you started claude outside tmux and the connection dropped, the conversation is still there. Claude Code saves sessions to disk as it works (sessions docs). In the same folder, claude --continue reopens the most recent conversation and claude --resume shows a picker. A command that was running when the process died won't rerun by itself, so ask Claude to start it again.

Make SSH notice a dead connection

By default, ssh sends no messages of its own to check the connection, so it can sit on a dead one for a long time. A keepalive fixes that. Add this to ~/.ssh/config on your laptop:

Host *
  ServerAliveInterval 30

With ServerAliveInterval set to 30, ssh asks the server for a reply after 30 seconds of silence. With the default ServerAliveCountMax of 3, it disconnects after about 90 seconds without an answer. That's your signal to reconnect and reattach. The agent inside tmux never noticed.

Let it work while you're gone

An agent that stops to ask permission waits until you answer. Before you close the laptop, make sure the task can run without you: tell it which commands it will need, or pick a permission mode that fits unattended work. Claude Code's docs keep bypassPermissions, which skips every prompt, for isolated containers and VMs. We went through the trade-offs in Give your coding agent its own machine.

How shedix does it

A shedix machine is a VM on Google Cloud that stays on when your laptop doesn't. Each one has Claude Code, Codex and tmux installed, and there are four ways in: a web terminal in the browser that works on phones, VS Code in the browser, plain SSH with your keys, and the shedix ssh and shedix code commands.

Claude Code and Codex open in terminal tabs on the machine page. Those tabs run inside tmux on the machine, so closing the tab, or the laptop, doesn't stop the agent. Open the tab again from any browser, your phone's included, and the session is where you left it. If you'd rather use the Claude app, turn on Remote Control for the machine, as described in our post on phone access.

Machines also go to sleep when nobody uses them. After 60 minutes with no SSH session, no open terminal or VS Code tab, no agent writing its conversation, the CPU under a quarter of a core and network traffic under 1 MB per 30 seconds, the machine stops by itself. Files stay; running processes end.

While Claude Code works, it writes its conversation, which counts as use. If it stops to wait for your answer, nothing counts, and an hour later the machine stops. Turn on Keep awake for a machine that has to wait for you. If it did stop, start it again (about 45 to 60 seconds, at a new IP address), cd into the project and run claude --continue.

Close the laptop shows how an agent on your laptop can move its own session to a shedix machine. The FAQ answers the usual questions about sleep and files, or you can start a machine and try it.