How do developers run multiple AI coding agents with tmux?
Developers who run several AI coding agents at once are leaning on tmux, a terminal multiplexer that has been around since 2007, to keep those agents running. The tool lets each agent live in a named session that keeps going after a terminal window closes, an SSH connection drops or a laptop goes to sleep. A detailed guide on the practice says that combination is the reason people use it.
The guide points out that recent versions of Claude Code can handle part of the setup. Running claude --worktree --tmux creates a new git worktree and a tmux session for it, and a name can be added to the worktree. The --tmux flag only works alongside --worktree, so it is a worktree feature that happens to create a session. On iTerm2, the flag uses native panes instead of tmux by default. Users who want real tmux underneath need to pass --tmux=classic, which the guide recommends for anyone planning to script against the session.
Beyond that single-agent case, the guide says, users have to build the rest themselves. The usual approach is one tmux session per repository, named after the project, rather than one per task or agent. Tasks come and go, the authors argue, while the project stays constant. A shell function that wraps the attach-or-create command lets a developer run the same line repeatedly without creating duplicate sessions.
Scripting agents from outside
How do scripts control AI coding agents in tmux?
Two tmux commands do most of the work. The first, send-keys, types text into a running pane as if someone were at the keyboard. That lets a cron job, a git hook or another agent send a prompt to a running agent. The second, capture-pane, dumps a pane's contents so a script can read the agent's output back.
The guide flags several problems that catch people out. Words such as Enter, C-c and Escape are read as keypresses unless the text is sent with the literal flag, and the newline then has to go in a separate call. A semicolon in the prompt ends the tmux command unless it is escaped. Agent input boxes can also drop an Enter that arrives in the same moment as the text, so the guide suggests a short pause of about 0.3 seconds between the two.
Developers who want a continuous record rather than a snapshot can use pipe-pane to stream a pane's output to a file. The raw output includes terminal escape sequences, so the guide recommends stripping them before reading the logs later.
Where tmux stops
What are the limits of tmux for AI coding agents?
The guide lists several gaps when tmux is used for agent work. tmux cannot tell whether an agent is waiting for approval, thinking or finished, since all three look like a pane with text in it. Developers have built status-line scripts that scrape the screen for phrases such as "esc to interrupt" to estimate an agent's state. The guide says those scripts are fragile, because they depend on whatever text the agent prints in a given version. A simpler option, the monitor-silence setting, alerts when a pane goes quiet, but silence does not confirm an agent has finished. An agent working through a large file can also go silent.
Other limits involve memory and persistence. Large scrollback buffers across many panes use real memory for as long as the server runs. Sessions do not survive a reboot, and scrollback disappears when the tmux server stops. Two agents in separate sessions also cannot see each other's work without custom file-based tooling.
The guide ends by recommending that readers keep tmux for remote machines, long-running server processes and cases where an unreliable SSH link is the main concern. It also pitches crystl, a macOS terminal the guide describes as built for running many agents at once. According to the guide, crystl shows approval requests as cards, displays each session's state in a single panel, saves agent output as structured records and uses git worktrees to isolate sessions on the same repository. The guide presents these features as answers to the tmux limits it describes, and the claims come from the guide's authors rather than from independent testing.
Questo articolo è stato scritto con l'assistenza dell'IA.
News Factory APP - notizie agentiche per potenziare il tuo SEO e AEO.
