Claude Code and tmux

Claude Code in tmux, and a tmux alternative for AI agents.

To run Claude Code in tmux, start a named session, run claude inside it and detach with Ctrl-b d: the agent keeps working after you close the terminal or your SSH link drops. Add three lines to ~/.tmux.conf so Shift+Enter and notifications work, and tmux covers most of what one person on one machine needs. This page shows that setup for Claude Code and Codex, Claude Code's own tmux features, and the jobs tmux was never built for.

Setup

How to run Claude Code in tmux

Give each agent its own named session. A name you can type beats a number you have to look up, and one session per task keeps a stuck run from hiding behind another.

bash
tmux new -s api          # one session per agent or task
cd ~/code/api && claude  # or: codex
# press Ctrl-b then d to detach; the agent keeps running

tmux ls                  # list sessions
tmux attach -t api       # pick it back up

On a remote box, let SSH open the session for you. -A attaches if the session already exists and creates it if not, so the same command works the first time and every time after:

bash
ssh -t devbox tmux new -A -s api

tmux keeps the process alive, not the machine. If the box sleeps, reboots or the tmux server is killed, the run stops. The conversation is still on disk, so claude --continue or codex resume --last in the same folder picks it up where it ended. The Claude Code resume guide and the Codex resume guide cover the picker and session IDs.

Config

A minimal .tmux.conf for coding agents

Out of the box, Claude Code inside tmux has two problems: Shift+Enter submits the prompt instead of adding a new line, and desktop notifications never reach your real terminal. The first three lines below come from Claude Code's own terminal docs and fix both. The rest are tmux options that help when an agent prints thousands of lines and you are not watching.

~/.tmux.conf
# Shift+Enter and notifications for Claude Code inside tmux
set -g allow-passthrough on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'

# Agents print a lot; keep more scrollback (new windows only)
set -g history-limit 50000

# Flag a window in the status line when its agent rings the bell
setw -g monitor-bell on
set -g bell-action any

# Scroll and pick panes with the mouse
set -g mouse on

Run tmux source-file ~/.tmux.conf to apply it to a running server. history-limit only affects windows created after the change. If Claude Code's display flickers in a small pane, its fullscreen renderer (/tui fullscreen) scrolls inside Claude Code instead of relying on tmux scrollback. If you only need a new line now, Ctrl+J works in any terminal without setup.

Alerts

Get notified when an agent finishes or needs approval

An agent waiting on a permission prompt in a detached session does nothing until you look. Make it ring:

  • Claude Code sends a desktop notification on its own only in Ghostty, Kitty and iTerm2. Anywhere else, set "preferredNotifChannel": "terminal_bell" in ~/.claude/settings.json. For a sound or your own script, add a Notification hook; it runs when Claude finishes or pauses for a permission prompt while you seem to be away.
  • Codex emits terminal notifications through tui.notification_method (auto, osc9 or bel), and notify = ["python3", "/path/to/notify.py"] in ~/.codex/config.toml runs a program on every finished turn.

With monitor-bell on, the bell marks the window in tmux's status bar, so you can see which of five sessions wants you. The catch: a bell only reaches a terminal that is attached. If you closed the laptop, nothing reaches you. The Claude Code notifications guide has hook commands for macOS, Linux and Windows.

Built in

Claude Code's own tmux features

A worktree in its own tmux session. claude --worktree feature-x --tmux creates a git worktree for the session and opens it in a new tmux session. --tmux requires --worktree. In iTerm2 it uses native panes; --tmux=classic forces plain tmux.

Agent teams in split panes. Agent teams let one Claude Code session lead several teammates, each a separate Claude instance. They are experimental and off by default: set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in your environment or in the env block of settings.json. The teammateMode setting picks the display:

  • "in-process" (the default): every teammate lives in your one terminal; arrow keys select one.
  • "auto": a split pane per teammate when you are already inside tmux (or iTerm2 with the it2 CLI), in-process otherwise.
  • "tmux": always split panes, tmux or iTerm2 detected from your terminal.

For one session, claude --teammate-mode auto does the same; the flag is experimental and does not appear in claude --help. Split panes do not work in the VS Code integrated terminal, Windows Terminal or Ghostty. Teammate permission prompts show up in the lead's pane, so you still answer them in one place. If a team's tmux session outlives Claude, tmux ls and tmux kill-session -t <name> clean it up. Each teammate is a full Claude session, so a team spends noticeably more tokens than one agent.

Often confused

cmux vs tmux

tmux is a multiplexer: it runs inside whatever terminal you have, on a server or over SSH, and keeps processes alive when you detach. cmux is a native Mac terminal app made for coding agents, with a sidebar of workspaces and a ring around any pane whose agent needs you. They solve different problems and many people run both. The full comparison, with cmux's platforms and pricing, is on Termdeck vs cmux.

Limits

What tmux does not solve for AI agents

Away from the keyboard

A run that stops on a permission prompt waits until you attach. The bell does not leave the machine, and answering from a phone means an SSH app and a terminal a few columns wide.

More than one machine

Each box has its own tmux server. Agents on a laptop, a desktop and a cloud VM are three SSH sessions and three status bars, with nothing that shows all of them at once.

Reviewing what changed

Edits scroll past as text in the pane. To review them properly you open git diff in another window, or read them in the scrollback before it is gone.

Windows

tmux has no native Windows build. On a Windows box you run it inside WSL or a similar layer, and the agent runs there too.

Where Termdeck fits

A tmux-style grid for agents on every machine

Termdeck is a web UI for Claude Code, Codex and Grok. A small agent on each machine (macOS, Linux or Windows) dials out to termdeck.io, and every session on every machine shows up in one sidebar in your browser. Runs happen on the machine, so closing the tab does not stop them; transcripts stay in the engines' own files on your disk.

Its Terminals page is the part a tmux user will recognise: chats tiled edge to edge with a status bar along the bottom, one pane per chat, from any machine, with a tmux classic theme if you want it. You split a pane right or down, drag a chat from the sidebar onto an edge, and open more windows. Approval prompts appear in the pane as numbered buttons, and a window with one waiting gets a flashing !. Away from the desk, Web Push reaches your phone and the notification opens the chat. Edits render as diffs you can review and turn into a pull request. Terminals needs a wide screen; on a phone you use the normal chat view.

It works alongside tmux. A Claude Code session you started in a tmux pane appears in Termdeck too, view-only while the terminal holds it, so two writers never fork the transcript. Take over closes an idle terminal client, and the terminal can resume the session later. See the interface docs for Terminals and sessions for how the lock works.

Compare

tmux + SSH vs Termdeck for coding agents

Featuretmux + SSHTermdeck
Keeps a run alive when you disconnectYesYes, the run lives on the machine
Built forAny program in a terminalClaude Code, Codex and Grok
Pane gridSplits, windows, sessionsTerminals page: chats tiled from every machine
Permission promptsThe CLI's own prompt in the paneAllow / deny buttons, answerable from a phone
Alert when an agent needs youBell on an attached client"Needs you" badge and Web Push
Diff reviewScrollback or git diffEvery edit rendered as a diff
Many machinesOne tmux server per boxOne sidebar for all of them
WindowsThrough WSLNative agent
PriceFree, open source14-day trial, then $9.99 or $19.99 a month

Straight answer

Who should just keep tmux

If your agents run on one machine you are usually sitting at, tmux plus the config above is enough, and it costs nothing. The same goes if you live in SSH, run CLIs other than Claude Code, Codex and Grok, or do not want any hosted service in the loop: Termdeck needs an account on termdeck.io, even though your transcripts stay on your machine. Termdeck earns its place when runs outlive your attention: agents on several machines, approvals you want to answer from your phone, or more sessions than one status bar can show.

FAQ

Claude Code and tmux, answered

How do I run Claude Code in tmux?

Start a named session with tmux new -s api, change to your project and run claude. Press Ctrl-b then d to detach. The agent keeps working, and tmux attach -t api brings you back to it. Over SSH, ssh -t yourhost tmux new -A -s api attaches if the session exists and creates it if not.

Why does Shift+Enter submit instead of adding a new line in tmux?

tmux does not pass extended keys through by default, so Claude Code sees Shift+Enter as Enter. Add set -s extended-keys on and set -as terminal-features 'xterm*:extkeys' to ~/.tmux.conf and run tmux source-file ~/.tmux.conf. Ctrl+J also inserts a new line without any setup.

Does Claude Code keep running after I detach from tmux?

Yes. tmux owns the process, so closing the terminal window or losing the SSH link does not stop the run. It stops if the machine sleeps, reboots or the tmux server is killed. If that happens, claude --continue or codex resume --last picks the conversation back up from disk.

How do I get notified when Claude Code in tmux needs me?

Set preferredNotifChannel to terminal_bell in ~/.claude/settings.json, or add a Notification hook that runs your own command. With monitor-bell on, tmux marks the window in the status line when the bell rings. Add set -g allow-passthrough on so desktop notifications reach the outer terminal.

Does Claude Code use tmux for agent teams?

It can. Agent teams are experimental and need CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1. With teammateMode set to auto, each teammate gets its own split pane when you are already inside tmux, and stays in one terminal otherwise. Split panes do not work in the VS Code terminal, Windows Terminal or Ghostty.

What is the difference between cmux and tmux?

tmux is a terminal multiplexer that runs inside any terminal, on a server or over SSH, and keeps processes alive when you detach. cmux is a native Mac terminal app built for coding agents, with a sidebar and pane alerts. Many people use both.

Is Termdeck a tmux replacement?

Not for shells, servers or editors; keep tmux for those. Termdeck replaces the part of a tmux setup that watches coding agents: Claude Code, Codex and Grok sessions from every machine in one browser tab, with approvals, diffs and phone push.

100+ engineers at five companies that asked not to be named. Their managers watch the spend.

tmux kept it alive. Termdeck keeps you in control.