tmux Skill
Use tmux to isolate tasks inside dedicated terminal sessions. Always begin work by creating (or attaching to) a task-specific tmux session, then perform every command from within that session. This keeps logs organized, makes it easy to resume work, and enables pane captures when the user asks for "screenshots."
Requirements
- •
tmuxavailable in$PATH(check withtmux -V). - •Basic familiarity with terminal navigation (the skill documents the key bindings and command equivalents below).
Quick Start Workflow
- •Create a new session (unique, descriptive name):
bash
tmux new -s taskname
- •Use lowercase, hyphenated names (e.g.,
tmux new -s hn-audit).
- •Use lowercase, hyphenated names (e.g.,
- •Detach/reattach as needed:
bash
tmux detach # Ctrl-b d tmux attach -t taskname
- •Add windows or panes for subtasks (see sections below).
- •Capture panes with
tmux capture-pane+tmux save-buffer /tmp/<file>.txtwhenever a transcript/screenshot is requested. - •Clean up completed sessions:
tmux kill-session -t taskname.
Session Management
| Action | Command |
|---|---|
| List sessions | tmux ls |
| Create + attach | tmux new -s taskname |
| Attach existing | tmux attach -t taskname |
| Detach | Ctrl-b d |
| Rename session | tmux rename-session -t old name |
| Kill session | tmux kill-session -t taskname |
Tips:
- •When running commands from outside tmux (e.g., via scripts), target sessions explicitly:
tmux send-keys -t taskname "command" Enter. - •Store session names in environment variables for automation:
SESSION=taskname.
Windows and Panes
Windows
- •New window:
Ctrl-bcortmux new-window -t taskname -n build. - •List windows:
Ctrl-bw. - •Rename window:
Ctrl-b,ortmux rename-window -t taskname:1 logs. - •Switch windows:
Ctrl-b<number>/Ctrl-bn/Ctrl-bp.
Panes
- •Split horizontal:
Ctrl-b"ortmux split-window -v. - •Split vertical:
Ctrl-b%ortmux split-window -h. - •Navigate panes:
Ctrl-barrow keys. - •Resize:
Ctrl-bCtrl+ arrow keys ortmux resize-pane -L/-R/-U/-D 5. - •Close pane:
Ctrl-din the pane ortmux kill-pane -t taskname:1.1.
Organize panes by task (e.g., editor, tests, logs). Document pane targets as session:window.pane (e.g., taskname:1.0).
Capturing Pane Output ("Screenshots")
Use tmux's buffer utilities to grab exact pane contents:
target="taskname:1.0"
tmux capture-pane -t "$target" -J -S -2000 # -J joins wrapped lines, -S sets scrollback start
capture_file="/tmp/${SESSION:-taskname}-pane1.txt"
tmux save-buffer "$capture_file"
tmux delete-buffer
Guidelines:
- •Choose filenames under
/tmpor the project workspace (reference them in your final response). - •Use
-S -2000(or another negative offset) to include recent scrollback. - •For raw bytes (e.g., binary output), add
-etocapture-pane. - •Mention the capture path when summarizing work.
Logging / Streaming Output
For long-running commands, pipe pane output to a file:
tmux pipe-pane -t taskname:1.0 -o 'cat >> /tmp/taskname.log'
Use tmux pipe-pane -t taskname:1.0 with no command to stop piping.
Troubleshooting & Cleanup
- •Session already exists: attach with
tmux attach -t tasknameinstead of creating a new one. - •Stale sessions:
tmux lsthentmux kill-session -t <name>. - •Detached but want to rejoin:
tmux a -t taskname. - •Copy mode:
Ctrl-b[to scroll and copy text; exit withq. - •Keyboard shortcuts not working: ensure
$TERMis compatible (e.g.,screen-256color).
Always clean up sessions when the task is complete unless the user asks to keep them running.
Learned Lessons
Any agent who uses this skill and discovers a new workflow, edge case, or tip should document it here for future reference.
2026-02-04 – Mitmproxy + curl workflow
- •Interactive programs: when driving full-screen apps (e.g., mitmproxy) inside a pane,
tmux send-keys -t session:window.pane q/ypairs are useful for quitting cleanly. Control sequences (such asC-cto interruptsleep 1000) can be sent the same way. - •Pane inspection: use
tmux capture-pane -t target -pfor a quick textual “peek” before deciding whether to save a pane. This helps verify commands succeeded before capturing to/tmp. - •Exports from TUI tools: mitmproxy’s built-in exporter (
e→ select part →b) piping into an editor makes it easy to write captured responses to files (e.g.,/tmp/response). Document file paths you create so users know where outputs live.