Panes, agent teams, and knowing when it's waiting. tmux keeps Claude Code running after you close the laptop lid or lose SSH, puts several agents side by side, and tells you in the status bar which one needs an answer.
This guide covers the tmux settings Claude Code needs, a session layout that works for daily use, agent teams in split panes, detaching from long runs, and three ways to get alerted when Claude stops and waits for you. Claude Code details are checked against the official docs at code.claude.com.
Out of the box, two things break when Claude Code runs inside tmux: Shift+Enter submits the prompt instead of adding a new line, and Claude's desktop notifications never reach your outer terminal. The Claude Code docs fix both with four lines in ~/.tmux.conf:
# ~/.tmux.conf set -g allow-passthrough on # tmux 3.3+: notifications reach the outer terminal set -g focus-events on set -s extended-keys on # Shift+Enter inserts a newline set -as terminal-features 'xterm*:extkeys' # Optional, but useful with long agent output set -g mouse on set -g history-limit 50000
tmux source-file ~/.tmux.conf (see reloading the tmux config). For Shift+Enter you also need to detach, reattach and restart Claude Code.\ followed by Enter, inserts a newline in every terminal with no setup, so you can use those while you sort out key handling./terminal-setup (VS Code, Cursor, Zed, older Alacritty), run it in the host terminal, not inside tmux.allow-passthrough on, only panes in the window you are looking at can pass notifications through. Use set -g allow-passthrough all if you want agents in background windows to notify you as well. More on the option in tmux allow-passthrough.C-a. Give every project its own tmux session, with Claude in the first window and a plain shell in the second. You switch projects with prefix s, and each agent keeps its own scrollback and working directory.
# Start a project session: Claude in window 1, a shell in window 2 tmux new-session -d -s api -c ~/code/api -n claude tmux send-keys -t api:claude 'claude' Enter tmux new-window -t api -n shell -c ~/code/api tmux attach -t api
send-keys types the command into the pane instead of making claude the pane's process, so the pane stays open with a shell when Claude exits. Save the four lines as a script and you have a one-word project launcher (more on send-keys).
If you'd rather watch tests or a dev server next to Claude, split the window instead. Opening the new pane in the same directory saves a cd:
# Claude on the left, shell on the right, both in the project directory
tmux split-window -h -c "#{pane_current_path}"
# Give Claude two thirds of the width
tmux resize-pane -t 0 -x 66% See splitting panes for the keys and the built-in layouts, and zooming a pane (prefix z) when you need Claude's output full screen for a moment.
Two Claude sessions editing the same checkout will overwrite each other's work. Give each one its own git worktree and its own tmux window:
git worktree add ../api-auth-fix -b auth-fix tmux new-window -t api -n auth-fix -c ~/code/api-auth-fix tmux send-keys -t api:auth-fix 'claude' Enter
Agent teams let one Claude Code session start several teammates that work in parallel and message each other. The feature is experimental and off by default. When you run Claude inside tmux, each teammate can get its own split pane, so you can watch all of them at once.
Set the environment variable in your shell, or in the env block of ~/.claude/settings.json, and choose how teammates are displayed:
{
"env": {
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
},
"teammateMode": "tmux"
}"in-process": the default. All teammates live inside your main terminal; works anywhere."auto": split panes when Claude runs inside tmux (or iTerm2 with its it2 CLI), in-process otherwise."tmux": always split panes, using tmux or iTerm2 depending on your terminal. For one session only: claude --teammate-mode auto. The flag is experimental and doesn't appear in claude --help.
Then ask for a team in plain language, for example "Create an agent team: one teammate reviews the API changes for security issues, one writes integration tests, one updates the docs." Teammates are only spawned in an interactive session; claude -p and Agent SDK runs don't start them.
| Mode | Keys | What they do |
|---|---|---|
| Split panes | prefix + arrow | Move to a teammate's pane and type to it directly |
| Split panes | prefix z | Zoom one teammate full screen, press again to return |
| Split panes | prefix Space | Cycle tmux layouts when four or more panes get cramped |
| In-process | Up / Down, Enter | Select a teammate, open its transcript and message it |
| In-process | Escape, x | Interrupt the teammate's current turn; stop a selected teammate |
| In-process | Ctrl+T | Show or hide the shared task list |
If Claude Code crashes mid-team, teammate panes or sessions can be left behind. List them with tmux ls and remove them with tmux kill-session -t <name>.
Press prefix d to detach. Claude keeps working inside the tmux server; closing the terminal or dropping an SSH connection no longer kills a long refactor. Come back from any terminal, or from another machine over SSH:
tmux ls # which projects are running tmux attach -t api # back into the api session # On a remote box: start tmux there, then Claude inside it ssh devbox -t 'tmux new -A -s api'
new -A attaches if the session exists and creates it if not, so the same command works every time. More in detaching, attaching and tmux over SSH.
tmux doesn't survive a reboot, but Claude Code keeps its conversations on disk. In the project directory:
claude --continue # reopen the most recent conversation in this directory claude --resume # pick from a list of earlier conversations
Claude Code doesn't restore flags such as --mcp-config, --add-dir or --settings on resume, so pass them again. Conversations started with claude -p don't show up in the list.
The expensive part of running agents is the minutes an agent sits on a permission prompt while you work in another window. Use one of these, or stack them.
While Claude works, its spinner and output keep the pane busy. When it stops to ask you something, the pane goes quiet. monitor-silence flags the window in the status bar after that many quiet seconds:
# Only on the Claude window: flag it after 20 quiet seconds
tmux set-window-option -t api:claude monitor-silence 20
# The window gets a ~ flag in the status bar; make it louder
set -g window-status-format '#I:#W#{?window_silence_flag, WAITING,}'It can't tell "waiting for you" from "done", but either way it's your turn. The full set of options (activity, bell, silence) is in tmux alerts and monitoring.
Claude Code can ring the terminal bell instead of (or in addition to) a desktop notification. Set Local notifications to the terminal bell in /config, or in ~/.claude/settings.json:
{
"preferredNotifChannel": "terminal_bell"
}Then let tmux turn that bell into a status-bar flag:
set -g monitor-bell on set -g bell-action other # flag bells from windows you aren't looking at set -g visual-bell off set -g window-status-bell-style 'fg=black,bg=colour208,bold'
Claude Code hooks run a shell command on lifecycle events. Notification fires when Claude needs permission for a tool or has been idle at the prompt for about a minute; Stop fires every time Claude finishes responding. Hooks inherit Claude's environment, so inside tmux $TMUX_PANE points at the pane Claude is running in:
{
"hooks": {
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "[ -n \"$TMUX_PANE\" ] && tmux display-message -d 5000 -t \"$TMUX_PANE\" 'Claude needs you in #{session_name}:#{window_name}'"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "[ -n \"$TMUX_PANE\" ] && tmux display-message -d 5000 -t \"$TMUX_PANE\" 'Claude finished in #{session_name}:#{window_name}'"
}
]
}
]
}
}prefix s."matcher": "permission_prompt" next to "hooks"; idle_prompt matches the idle case.afplay /System/Library/Sounds/Glass.aiff on macOS or notify-send on Linux if you want a sound or a desktop notification instead.message and notification_type for Notification), so a small script can say which tool is waiting for approval.All three methods need you to look at the terminal. If Claude runs in a tmux window you can't see, a small companion on the desktop is easier to notice. We also make OpenPets: OpenPets' Claude Code integration adds an MCP server, and optional hooks, so a pet next to your editor shows when Claude is running, waiting for you, ready for review or has failed. It runs locally, and Claude Code keeps working if the app is closed.
| Symptom | Fix |
|---|---|
| Shift+Enter sends the prompt | set -s extended-keys on and terminal-features 'xterm*:extkeys', then detach, reattach and restart Claude. See modifier key issues. |
| No desktop notifications inside tmux | set -g allow-passthrough on (tmux 3.3+), or all for background windows. |
| Agent team opens in-process, not in panes | Start Claude from inside tmux and set teammateMode to "auto" or "tmux"; check CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1. |
| Ctrl+B doesn't background a command | tmux took it as the prefix. Press it twice. |
| Window never gets flagged | Alerts only show for windows you aren't viewing. Check tmux show-window-options -t api:claude for the monitor options. |
AI Powered, Non-Intrusive Terminal Assistant
TmuxAI enhances your terminal with AI-powered commands, automation, and contextual awareness while preserving your existing workflow. It's open-source, privacy-focused, and can be used with any terminal emulator.
curl -fsSL https://get.tmuxai.dev | bash