A practical how-to for running Claude Code and other long-lived AI coding agents inside tmux, arguing that tmux is the right tool because it survives disconnection, consolidates multiple agents into named sessions, and is fully scriptable from the outside. The built-in claude worktree tmux flag automates the one-agent-per-branch case (claude worktree tmux or claude worktree <name> tmux) but uses iTerm2 native panes by default and requires tmux=classic for real tmux scripting. For multi-agent workflows, manual tmux setup is required: one tmux session per repository (named after the repo), one window per agent (windows for idle agents, panes for the two or three to watch side-by-side), tiled or main-vertical layouts, and attach-or-create session commands like tmux new-session -A -s <name> -c <dir>.
Concrete, actionable specifics cover useful .tmux.conf deltas (large history-limit, tmux-256color, mouse on, allow-rename off, base-index 1, monitor-activity on, escape-time 10, pane-jump bindings), pane creation and layout commands, and the scripting/readback pair: tmux send-keys (use -l to send literal strings, escape trailing ;, sleep before Enter, C-c to interrupt) and tmux capture-pane (use -J to join wrapped lines, -S to pick a range, -e to keep colors). pipe-pane streams raw output to logs. The guide also shows how to turn tmux’s status line into a lightweight monitor of agent activity and documents practical limits encountered when running multiple agents.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.