Claude Code in tmux: Setup, Config and Agent Teams (2026)
How to run Claude Code in tmux: the four tmux.conf lines that fix Shift+Enter and notifications, persistent SSH sessions, and split-pane agent teams.
Claude Code runs fine inside tmux, but out of the box two things break: Shift+Enter submits your prompt instead of adding a newline, and Claude Code's notifications never reach your real terminal. Four lines in ~/.tmux.conf fix both. Once that is done, tmux gives Claude Code three things it is genuinely good at: sessions that survive a closed laptop or dropped SSH connection, many agents organized in windows and panes, and split-pane display for Claude Code's experimental agent teams. This guide covers the config, the workflows worth copying, and when tmux is more ceremony than you need.
The tmux.conf you actually need
Add this to ~/.tmux.conf:
set -g allow-passthrough on
set -g focus-events on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'
Then reload: tmux source-file ~/.tmux.conf. Here is what each line does:
| Line | Fixes |
|---|---|
allow-passthrough on |
Lets Claude Code's desktop notifications and progress updates pass through tmux to your outer terminal |
focus-events on |
Tells Claude Code when the pane gains or loses focus |
extended-keys on |
Lets tmux distinguish Shift+Enter from Enter |
terminal-features 'xterm*:extkeys' |
Advertises extended-key support to the outer terminal |
If Shift+Enter still submits after reloading, kill the tmux server (tmux kill-server) and start fresh; some options only apply to new sessions. And remember Ctrl+J inserts a newline everywhere, tmux or not. Our Shift+Enter fix guide has the per-terminal details.
Two more quality-of-life lines most people add:
set -g mouse on
set -g history-limit 50000
Mouse mode lets you scroll Claude Code's output with the trackpad. A bigger history keeps long sessions scrollable.
One caveat: run /terminal-setup outside tmux
If your terminal needs /terminal-setup (VS Code, Cursor, Zed, older Alacritty), run it in a plain window, not inside tmux. It configures the outer terminal and cannot see it from inside tmux. Same story for anything that checks which terminal you are in: tmux reports itself, not the app around it.
Workflow 1: the session that survives everything
The classic reason to put Claude Code in tmux is persistence. Start a named session on a remote box:
tmux new -s refactor
claude
Give Claude a long task, detach with Ctrl+B then D, close your laptop, go get lunch. Later, from any machine:
ssh devbox
tmux attach -t refactor
Claude has kept working the whole time. This is the single best argument for tmux, and it is why most Claude Code over SSH setups use it. On a local Mac it matters less, because your terminal app does not disappear when you close the lid.
Workflow 2: one window per agent
When you run several Claude Code sessions, give each its own tmux window and name it after the task:
tmux new -s work -n api
# inside: claude
Ctrl+B c # new window
Ctrl+B , # rename it "tests"
Pair this with git worktrees so each agent has its own checkout and they never edit the same files. Our git worktrees guide shows the pattern. The weak spot: tmux's status bar shows window names, not which agent is waiting on a permission prompt. With allow-passthrough on you at least get the outer terminal's notification, but you still have to find the right window.
Workflow 3: agent teams in split panes
Claude Code has an experimental agent teams feature, where a lead session coordinates several teammate sessions. It is off by default; turn it on by setting CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in your shell or in the env block of settings.json.
Teammates can display two ways, controlled by the teammateMode setting or --teammate-mode flag:
- In-process (the default) keeps everything in one terminal and works anywhere.
- Split panes gives each teammate its own pane so you can watch them all at once. This needs tmux or iTerm2 (with its
it2CLI and Python API enabled). Values arein-process,auto,tmuxanditerm2.
The docs note split panes are not supported in VS Code's terminal, Windows Terminal or Ghostty, so tmux is the portable way to get the multi-pane view. If a team run ends badly and leaves panes behind, tmux ls and tmux kill-session -t <name> clean up. For the difference between teams and subagents, see our Claude Code subagents guide.
tmux vs the alternatives
| Approach | Survives disconnect | Multi-agent view | Setup effort |
|---|---|---|---|
| tmux | Yes | Windows and panes, text status bar | Medium (config file, prefix keys) |
| Zellij | Yes | Panes, floating windows, discoverable keys | Low to medium |
| Terminal tabs (iTerm2, Ghostty) | No | Tabs | Low |
| MOLTamp | No | Up to 50 tabs with attention badges | Low |
Zellij is the friendlier modern multiplexer if tmux's prefix keys never stuck; we compare them in Zellij vs tmux. But note that Claude Code's split-pane team mode targets tmux and iTerm2 specifically.
When to skip tmux
Be honest about why you want it. If it is persistence on a remote server, tmux is the right tool and nothing replaces it. If it is just "I want to see a bunch of Claude Code sessions on my Mac," a terminal built for that is less work.
That is the case MOLTamp is built for. It is a skinnable terminal shell for Claude Code and other agent CLIs on Mac. Each session gets a tab (up to 50), and attention badges flag the one that finished or needs you, so you are not cycling through tmux windows hunting for a permission prompt. You get desktop notifications when an agent goes quiet while you are in another app, Shift+Enter works out of the box, and the whole thing is skinnable. Many people run both: tmux on the remote box, MOLTamp as the cockpit on the Mac. Our MOLTamp and tmux power-user setup shows how they fit together.
MOLTamp is free to use with every feature working; a one-time $10 license removes a recurring popup. Download MOLTamp, or see how it ranks among the best terminals for AI agents.
FAQ
Does Claude Code work in tmux?
Yes. Add extended-keys and allow-passthrough settings to ~/.tmux.conf so Shift+Enter and notifications work, and Claude Code behaves the same as in a plain terminal.
Why doesn't Shift+Enter work in Claude Code inside tmux?
tmux does not forward extended key sequences by default, so Shift+Enter arrives as a plain Enter. Set extended-keys on and add the extkeys terminal feature, then reload.
Can Claude Code keep running after I disconnect SSH? Yes, if you start it inside tmux (or Zellij or screen). Detach, disconnect, and reattach later; the session keeps running on the server.
Do Claude Code agent teams need tmux? No. The default in-process mode works in any terminal. tmux or iTerm2 is only needed if you want each teammate in its own split pane.
Should I use tmux or Zellij for Claude Code? Both work. tmux is everywhere and is what Claude Code's split-pane team mode targets. Zellij is easier to learn.