Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling
TL;DR Highlight
Running Claude Code agents in tmux works well, but limits appear around four agents.
Who Should Read
A developer running several Claude Code agents at once who spends too much time managing tmux sessions.
Core Mechanics
- claude --worktree --tmux does it in one line
- Recent Claude Code creates the git worktree and tmux session together.
- --tmux errors out without --worktree.
- On iTerm2 it uses native panes instead of tmux, so pass --tmux=classic if you want to script against the session.
- One session per repo, not per task
- The guide recommends one tmux session per repo, named after the repo.
- Tasks become windows inside that session.
- new-session -A attaches if it exists and creates it if not.
- send-keys confuses text with key names
- Bare words like Enter, C-c, Escape, and Space are sent as keypresses.
- Send the prompt with -l and send Enter in a separate call.
- Agent input boxes can swallow an Enter that arrives in the same frame, so sleep 0.3 between them.
- capture-pane reads, pipe-pane logs
- capture-pane -p -J joins wrapped lines so grep does not break at the seams.
- pipe-pane streams pane output to a file continuously.
- The output contains raw escape sequences, so filter it with sed to make it readable.
- The status-line monitor is just screen scraping
- The script string-matches each pane's last lines every 5 seconds to tell working, waiting, and idle apart.
- The match strings depend on whatever your agent version prints that week.
- monitor-silence alerts on no output, but a thinking agent is silent too, so it is not a done signal.
- tmux's limit is that it doesn't know what an agent is
- Waiting on approval, thinking, and finished 20 minutes ago all look like the same pane of text.
- There is no shared state across sessions, and a reboot wipes sessions and scrollback.
- history-limit 100000 across a dozen panes uses real memory.
- The author still recommends tmux for remote boxes and SSH.
Community Reactions
- Opinion: tmux is still worth it
- One commenter said tmux or screen pays back hugely for just 10 minutes of learning.
- Another told Claude it was in tmux with iTerm, had it spawn subagents into tabs, and asked the primary agent for fleet status, which worked well.
- Tools people use instead
- Several commenters switched to herdr and said it shows what's open much better than juggling tmux sessions.
- One uses shpool because they only need persistence, not multiplexing.
- Many others built their own multiplexers (seance, zmx, workmux, agent-deck, and more).
- Experience with setup and maintenance cost
- One commenter used Claude Code in tmux from January to August, then moved to the ChatGPT desktop app because of too much tinkering and maintenance.
- Another said too many sessions cause context-switching fatigue and aims for 2 active sessions.
- Reaction to the article
- One commenter called it essentially an ad for crystl.
- Another said agents now have --resume, which weakens the main reason for using tmux to avoid losing sessions.
How to Apply
- Make a per-repo session with an agent() shell function
- Today, add a function to ~/.zshrc wrapping tmux new-session -A -s NAME -c DIR.
- Derive the name from basename with . replaced by -.
- Run tmux ls and check that sessions are listed per repo.
- Change send-keys calls to the -l, sleep, Enter pattern
- Find where your scripts feed prompts to an agent and send only the body with send-keys -l.
- Send Enter in a separate call after sleep 0.3.
- Escape semicolons in the prompt as \;.
- Build a status script with capture-pane -J
- Read the last 8 lines of each pane with capture-pane -p -J for your status line.
- Edit the match strings for approval-waiting and working to fit your agent version.
- Recheck them after each agent upgrade since the strings may change.
- Decide on a tool switch once you pass 4 agents
- If you keep missing approval prompts, compare agent-specific tools layered on tmux.
- Keep using tmux -A for remote servers and SSH work.
Try It
# Paste into a tmux terminal (run with Claude Code available in the shell)
# 1) Create a session and window, then start the agent
tmux new-session -d -s api -c ~/code/api
tmux new-window -t api -n auth -c ~/code/api
tmux send-keys -t api:auth "claude" Enter
# 2) Send a prompt (body with -l, Enter separately)
PROMPT="run the test suite and fix what fails"
tmux send-keys -t api:auth -l "$PROMPT"
sleep 0.3
tmux send-keys -t api:auth Enter
# 3) Read the screen: last 30 lines, wrapped lines joined
tmux capture-pane -p -J -S -30 -t api:auth
# Next to try: save a log with pipe-pane
mkdir -p ~/agent-logs
tmux pipe-pane -o -t api:auth 'cat >> ~/agent-logs/api-auth.log'Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques
Related Resources
- https://crystl.dev/guides/tmux-for-ai-agents/
- https://github.com/zackham/seance
- https://zmx.sh
- https://bower.sh/zmx-ai-portal
- https://github.com/jdonaldson/headless-horseman
- https://github.com/raine/workmux
- https://github.com/asheshgoplani/agent-deck
- https://gitlab.com/skeledrew/jaiver
- https://github.com/NavistAu/claude-tmux-bridge
- https://github.com/NavistAu/claude-tmux-director
- https://michael.sinax.be/jai/index.html
- https://domux.dev
- https://github.com/wb14123/tcode
- https://shikigami.dev