BlogTerminals and tmux

Does Claude Code keep running over SSH when I close my laptop?

No, not by itself. A claude started in a plain SSH shell is tied to that connection, and the connection ends when your laptop closes. Started inside tmux, it keeps running: the tmux manual says a session survives an SSH disconnection and can be reattached. The cost is that questions Claude asks while you are away wait for you, silently.

Why tmux changes the answer

tmux runs your programs under a server process, and your terminal is only a client attached to it. From the manual: "Each session is persistent and will survive accidental disconnection (such as ssh(1) connection timeout) or intentional detaching (with the C-b d key strokes)." It may be reattached with tmux attach.

The command to remember is new-session with -A, which "makes new-session behave like attach-session if session-name already exists":

ssh you@your-server
tmux new -A -s claude

Run it every time you connect. The first time it creates the session; afterwards it reattaches. Start claude inside, and closing the laptop only drops the client. For a full setup, see how to run Claude Code on a remote server.

If the session died without tmux

Claude Code saves a session continuously on the machine where it ran, so the conversation is not lost. Back in the same directory on that machine:

claude --continue    # most recent conversation in this directory
claude --resume      # pick a session from a list

Resuming restores the conversation. A tool call that was still running when the process ended is not rerun, so check what the agent was in the middle of before you tell it to carry on.

What you miss while you are away

When Claude finishes or stops for a permission prompt, it waits for you. Claude Code fires a notification event when you appear to be away, and the docs describe the desktop notification as reaching your local machine over SSH. That needs a connection. While you are detached, there is none, so do not count on being told: the agent sits at its prompt until you reattach and look.

You can reduce the gap with hooks that name the session (which Claude Code session is waiting), but a hook running on the server still has to reach you somehow. Plain SSH leaves that to you.

Claude Code also has background sessions: claude --bg starts one under a supervisor process, with no terminal needed, and they are preserved when the machine sleeps. Agent view is a research preview, and shutting the machine down still stops them.

With Kanbell 1.5.3

Kanbell removes the manual steps, for Claude Code on a Linux machine. The agent runs in tmux on the server (set up once per machine, see Remote machines (SSH)).

  • You close Kanbell or the laptop. The agent keeps running in tmux.
  • You reopen Kanbell. It reconnects and reattaches to the session on its own, without a click.
  • Questions that arrived meanwhile are in the menu bar panel, ready to answer, with a single notification instead of one per question.
  • The machine is unreachable. The session turns grey and Kanbell reconnects by itself; a lost connection is detected in about twenty seconds. The agent is not stopped.

There is no Kanbell server: everything goes through SSH, with a reverse tunnel to your Mac. Remote sessions show in a terminal, not the Focus view, and Codex and Gemini CLI do not run remotely.

FAQ

What does tmux new -A do?

tmux new-session with -A behaves like attach-session if the named session already exists, and creates it otherwise. So tmux new -A -s claude is safe to run every time you connect.

How do I get my conversation back if the SSH session died without tmux?

Claude Code saves each session continuously on the machine where it ran. Run claude --continue in the same directory for the most recent conversation, or claude --resume to pick one. A tool call that was still running is not rerun.

Will I be notified when Claude asks a question while I am disconnected?

Do not count on it. The docs describe the desktop notification as reaching your local machine over SSH, and with nothing attached there is no connection for it to travel through. Claude waits at its prompt until you reattach.

Can Claude Code keep working without any terminal?

Background sessions started with claude --bg run under a supervisor process and need no terminal open. Agent view is a research preview and they stop if the machine shuts down.

Sources