smux
Original:🇺🇸 English
Translated
Control tmux panes and communicate between AI agents. Use this skill whenever the user mentions tmux panes, cross-pane communication, sending messages to other agents, reading other panes, managing tmux sessions, or interacting with processes running in tmux. Includes tmux-bridge CLI for agent-to-agent messaging and raw tmux commands for direct session control.
11installs
Sourceshawnpana/smux
Added on
NPX Install
npx skill4agent add shawnpana/smux smuxTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →smux
Tmux pane control and cross-pane agent communication. Use (the high-level CLI) for all cross-pane interactions. Fall back to raw tmux commands only when you need low-level control.
tmux-bridgetmux-bridge — Cross-Pane Communication
A CLI that lets any AI agent interact with any other tmux pane. Works via plain bash. Every command is atomic: types text (no Enter), sends special keys, captures pane content.
typekeysreadDO NOT WAIT OR POLL
Other panes have agents that will reply to you via tmux-bridge. Their reply appears directly in YOUR pane as a message. Do not sleep, poll, read the target pane for a response, or loop. Type your message, press Enter, and move on.
[tmux-bridge from:...]The ONLY time you read a target pane is:
- Before interacting with it (enforced by the read guard)
- After typing to verify your text landed before pressing Enter
- When interacting with a non-agent pane (plain shell, running process)
Read Guard
The CLI enforces read-before-act. You cannot or to a pane unless you have read it first.
typekeys- marks the pane as "read"
tmux-bridge read <target> - checks for that mark — errors if you haven't read
tmux-bridge type/keys <target> - After a successful /
type, the mark is cleared — you must read again before the next interactionkeys
$ tmux-bridge type codex "hello"
error: must read the pane before interacting. Run: tmux-bridge read codexCommand Reference
| Command | Description | Example |
|---|---|---|
| Show all panes with target, pid, command, size, label | |
| Type text without pressing Enter | |
| Type text with auto sender info and reply target | |
| Read last N lines (default 50) | |
| Send special keys | |
| Label a pane (visible in tmux border) | |
| Print pane target for a label | |
| Print this pane's ID | |
Target Resolution
Targets can be:
- tmux native: (e.g.
session:window.pane), pane ID (shared:0.1), or window index (%3)0 - label: Any string set via — resolved automatically
tmux-bridge name
Read-Act-Read Cycle
Every interaction follows read → act → read. The CLI enforces this.
Sending a message to an agent:
bash
tmux-bridge read codex 20 # 1. READ — satisfy read guard
tmux-bridge message codex 'Please review src/auth.ts'
# 2. MESSAGE — auto-prepends sender info, no Enter
tmux-bridge read codex 20 # 3. READ — verify text landed
tmux-bridge keys codex Enter # 4. KEYS — submit
# STOP. Do NOT read codex for a reply. The agent replies into YOUR pane.Approving a prompt (non-agent pane):
bash
tmux-bridge read worker 10 # 1. READ — see the prompt
tmux-bridge type worker "y" # 2. TYPE
tmux-bridge read worker 10 # 3. READ — verify
tmux-bridge keys worker Enter # 4. KEYS — submit
tmux-bridge read worker 20 # 5. READ — see the resultMessaging Convention
The command auto-prepends sender info and location:
message[tmux-bridge from:claude pane:%4 at:3:0.0] Please review src/auth.tsThe receiver gets: who sent it (), the exact pane to reply to (), and the session/window location (). When you see this header, reply using tmux-bridge to the pane ID from the header.
frompaneatAgent-to-Agent Workflow
bash
# 1. Label yourself
tmux-bridge name "$(tmux-bridge id)" claude
# 2. Discover other panes
tmux-bridge list
# 3. Send a message (read-act-read)
tmux-bridge read codex 20
tmux-bridge message codex 'Please review the changes in src/auth.ts'
tmux-bridge read codex 20
tmux-bridge keys codex EnterExample Conversation
Agent A (claude) sends:
bash
tmux-bridge read codex 20
tmux-bridge message codex 'What is the test coverage for src/auth.ts?'
tmux-bridge read codex 20
tmux-bridge keys codex EnterAgent B (codex) sees in their prompt:
[tmux-bridge from:claude pane:%4 at:3:0.0] What is the test coverage for src/auth.ts?Agent B replies using the pane ID from the header:
bash
tmux-bridge read %4 20
tmux-bridge message %4 '87% line coverage. Missing the OAuth refresh token path (lines 142-168).'
tmux-bridge read %4 20
tmux-bridge keys %4 EnterRaw tmux Commands
Use these when you need direct tmux control beyond what tmux-bridge provides — session management, window navigation, creating panes, or low-level scripting.
Capture Output
bash
tmux capture-pane -t shared -p | tail -20 # Last 20 lines
tmux capture-pane -t shared -p -S - # Entire scrollback
tmux capture-pane -t shared:0.0 -p # Specific paneSend Keys
bash
tmux send-keys -t shared -l -- "text here" # Type text (literal mode)
tmux send-keys -t shared Enter # Press Enter
tmux send-keys -t shared Escape # Press Escape
tmux send-keys -t shared C-c # Ctrl+C
tmux send-keys -t shared C-d # Ctrl+D (EOF)For interactive TUIs, split text and Enter into separate sends:
bash
tmux send-keys -t shared -l -- "Please apply the patch"
sleep 0.1
tmux send-keys -t shared EnterPanes and Windows
bash
# Create panes (prefer over new windows)
tmux split-window -h -t SESSION # Horizontal split
tmux split-window -v -t SESSION # Vertical split
tmux select-layout -t SESSION tiled # Re-balance
# Navigate
tmux select-window -t shared:0
tmux select-pane -t shared:0.1
tmux list-windows -t sharedSession Management
bash
tmux list-sessions
tmux new-session -d -s newsession
tmux kill-session -t sessionname
tmux rename-session -t old newClaude Code Patterns
bash
# Check if session needs input
tmux capture-pane -t worker-3 -p | tail -10 | grep -E "❯|Yes.*No|proceed|permission"
# Approve a prompt
tmux send-keys -t worker-3 'y' Enter
# Check all sessions
for s in shared worker-2 worker-3 worker-4; do
echo "=== $s ==="
tmux capture-pane -t $s -p 2>/dev/null | tail -5
doneTips
- Read guard is enforced — you MUST read before every /
typekeys - Every action clears the read mark — after , read again before
typekeys - Never wait or poll — agent panes reply via tmux-bridge into YOUR pane
- Label panes early — easier than using IDs
%N - uses literal mode — special characters are typed as-is
type - defaults to 50 lines — pass a higher number for more context
read - Non-agent panes are the exception — you DO need to read them to see output
- Use to print to stdout (essential for scripting)
capture-pane -p - Target format: (e.g.,
session:window.pane)shared:0.0