| name | tmux |
| description | Run long-running commands in a tmux session and capture their output. Use when you need to start a build/test/server that takes minutes, run multiple commands in parallel, or interact with a process across tool calls. |
Tmux Skill
Drive tmux directly via shell commands — no MCP needed. Use this for any
long-running task whose output you'll want to inspect later, or for processes
that need to outlive a single Bash tool call.
Session naming convention
All sessions you create must be prefixed with claude-. This keeps them
namespaced and lets you find idle ones to reuse.
Find an idle session, or create one
Before starting a new session, check whether an existing claude-* session
is idle and reuse it. A session is "idle" if its current pane is at a shell
prompt with no running command.
tmux list-sessions -F '#{session_name}' 2>/dev/null | grep '^claude-' || true
tmux new-session -d -s claude-build
tmux has-session -t claude-build 2>/dev/null || tmux new-session -d -s claude-build
Run a command and wait for it
Send the command followed by a unique completion marker, then poll
capture-pane until the marker appears.
SESSION=claude-build
MARKER="__DONE_$$_$RANDOM__"
tmux send-keys -t "$SESSION" "your-long-command; echo $MARKER" Enter
until tmux capture-pane -p -t "$SESSION" | grep -q "$MARKER"; do
sleep 2
done
tmux capture-pane -p -S - -t "$SESSION"
Use Bash(run_in_background=true) for the polling loop if you want to do
other work while waiting.
Capture output
tmux capture-pane -p -t claude-build
tmux capture-pane -p -S - -t claude-build
tmux capture-pane -p -S -200 -t claude-build
-p prints to stdout. Without it, output goes to a paste buffer.
Run things in parallel
Use multiple sessions or multiple windows in one session.
tmux new-session -d -s claude-build -- bash -c 'nix build .#foo'
tmux new-session -d -s claude-tests -- bash -c 'pytest'
tmux new-session -d -s claude-work
tmux new-window -t claude-work -n build -- bash -c 'nix build .#foo'
tmux new-window -t claude-work -n tests -- bash -c 'pytest'
tmux list-windows -t claude-work
Note: when a command passed via -- exits, the window closes too. To keep
the pane around for inspection, wrap with bash -c 'cmd; exec bash' or use
the send-keys pattern above.
Inspect
tmux list-sessions
tmux list-windows -t claude-build
tmux list-panes -t claude-build
Clean up
tmux kill-session -t claude-build
tmux kill-server
When NOT to use tmux
- One-shot commands that complete in seconds → just use
Bash directly.
- Commands you want to background but don't need to interact with later →
Bash(run_in_background=true) is simpler.
- Anything that needs structured stdout/stderr separation — tmux merges them.