Keep Claude Code running with your laptop closed: tmux on a server
You start Claude Code on a server, give it a longer task, and then the connection drops: Wi-Fi gone, laptop closed, a restart for an update. Without precautions, the agent’s work is lost. With tmux, that no longer happens.
Why the agent dies when the connection drops
Everything you start in an SSH session is tied to that session. When it ends, the system sends the running programs a signal to terminate (SIGHUP). Claude Code is stopped in the middle of its task.
The solution is a terminal multiplexer such as tmux. tmux keeps running on the server, independently of your connection. You attach, work, detach again, and the programs inside simply keep running.
tmux in five minutes
Install tmux on the server. On Debian or Ubuntu:
sudo apt install tmux
Start a session named main, or attach to it if it already exists:
tmux new -A -s main
Start claude inside it and enter your task. To detach, press Ctrl+b and then d. The session keeps running, even after you log out. Later you get it back with:
tmux attach -t main
tmux ls lists all running sessions.
Always land in the same session
It is even more convenient if every SSH login automatically lands in the same tmux session. To set this up, add the following at the end of ~/.bashrc on the server:
if [[ -n "$SSH_CONNECTION" && -z "$TMUX" && $- == *i* && "$TERM_PROGRAM" != "vscode" ]]; then
exec tmux new -A -s main
fi
The conditions make sure this only happens for interactive SSH logins. File transfers with scp or rsync are not affected. The VS Code terminal is excluded because VS Code manages its terminals itself.
From now on, ssh meinserver is all it takes, and you are right where you left off.
If the process was terminated anyway
Even without tmux, not everything is lost, because Claude Code saves your conversations. This command continues the most recent conversation in the current directory:
claude --continue
The short form is claude -c. With claude --resume you pick from a list of earlier sessions instead. An interrupted task does not resume on its own: just ask the agent to carry on where it left off.
Continue from your phone
With Remote Control you can steer a running Claude Code session from the browser or your phone. To do this, start Claude Code like this:
claude --remote-control
In a session that is already running, type /remote-control instead, or /rc for short. You then open the session at claude.ai/code or in the Claude app. It keeps running on your server; the browser and the app are only a window into it. Combined with tmux, the agent keeps working on the server while you check in from wherever you are.
Remote Control is available on the Pro, Max, Team and Enterprise plans. On Team and Enterprise, an admin has to enable it in the settings first.
Summary
tmux on the server, automatic attach via .bashrc and Remote Control when you need it: this way your agent keeps working, no matter what happens to your laptop. On the euhost Box, all of this is already set up.