agentleFS
KubementatKubementat/ai_agent_skills/skills/tmux-specialist/SKILL.md

tmux-specialist

Skill2 starsChanged 8 months agoMITView on GitHub

Complete tmux expertise: session/window/pane management, scripting, automation, copy mode, configuration, plugins, agent steering, and all advanced features. Use when working with tmux in any capacity.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the relevant reference file(s) before answering any question or executing any task in that area:

    line 22
  2. Distinctive:

    After starting a session, immediately print a copy-paste monitor command for the user:

    line 63
  3. Very specific:

    Always use -l to prevent shell interpretation of special characters:

    line 128
  4. Distinctive:

    Use when you need to know if a long-running agent/command has truly finished:

    line 205
  5. Very specific:

    gdb/lldb: start with --quiet; disable paging.

    line 233
  6. Distinctive:

    When debugging, prefer lldb by default.

    line 235

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

tmux Specialist

Full-spectrum tmux expertise covering interactive use, scripting, automation, configuration, and steering agents via tmux panes.

Terminology

  • Session: a persistent workspace container (survives detach/disconnect). All work lives inside sessions.
  • Window (tab): each session has one or more windows, each with independent content.
  • Pane (split): windows are subdivided into panes; each runs an independent shell or program.
  • Target format: {session}:{window}.{pane} — e.g., myapp:editor.0. Omit parts to use current.

Reference Documents

Read the relevant reference file(s) before answering any question or executing any task in that area:

TopicFile
Quick-reference keybindings & CLI cheat sheetreferences/cheat-sheet.md
Session create/attach/rename/kill/envreferences/session-management.md
Windows, panes, splits, layouts, synchronizereferences/window-pane-layouts.md
~/.tmux.conf options, keybindings, status barreferences/configuration.md
Copy mode navigation, paste buffers, clipboard, pipe-panereferences/copy-mode-buffers.md
Hooks, monitoring, popups, shared sessions, control modereferences/advanced-features.md
TPM, tmux-resurrect, tmux-yank, themes, etc.references/plugins.md
send-keys, capture-pane, format strings, scripting sessionsreferences/scripting-automation.md
Steering agents/TUIs (pi, vim, REPLs, gdb) via send-keysreferences/steering-agents.md

Helper Scripts

ScriptPurpose
scripts/wait-for-text.shPoll a pane until a regex appears (with timeout)
scripts/find-sessions.shList sessions on one socket or scan all sockets
scripts/session-layout.shCreate named multi-pane layouts (dev, monitor, grid4, triple-h, triple-v, custom)
scripts/tmux-snapshot.shDump all pane scrollbacks to files or stdout
scripts/session-watch.shWatch and display status of all panes in a multi-agent session (updates every 60s by default)

Socket Convention (Agents)

Agents MUST use a private socket to avoid interfering with the user's personal tmux:

SOCKET_DIR="${CLAUDE_TMUX_SOCKET_DIR:-${TMPDIR:-/tmp}/claude-tmux-sockets}"
mkdir -p "$SOCKET_DIR"
SOCKET="$SOCKET_DIR/claude.sock"
SESSION="claude-myproject"   # slug-like, no spaces

tmux -S "$SOCKET" new-session -d -s "$SESSION" -n shell

After starting a session, immediately print a copy-paste monitor command for the user:

To monitor this session:
  tmux -S "$SOCKET" attach -t "$SESSION"

Or capture output once:
  tmux -S "$SOCKET" capture-pane -p -J -t "$SESSION":0.0 -S -200

Print this again at the end of the tool loop.


Quickstart Examples

Start a session and run a command

SOCKET=/tmp/claude-tmux-sockets/claude.sock
SESSION=mywork
tmux -S "$SOCKET" new-session -d -s "$SESSION" -n main
tmux -S "$SOCKET" send-keys -t "$SESSION":main.0 -l -- 'python3 -q'
tmux -S "$SOCKET" send-keys -t "$SESSION":main.0 Enter
tmux -S "$SOCKET" capture-pane -p -J -t "$SESSION":main.0 -S -200

Wait for a prompt before proceeding

./scripts/wait-for-text.sh -S "$SOCKET" -t "$SESSION:0.0" -p '^\$\s*$' -T 30

Create a dev layout (editor + build + logs)

./scripts/session-layout.sh -S "$SOCKET" -s myapp dev

Snapshot all panes to files

./scripts/tmux-snapshot.sh -S "$SOCKET" -o /tmp/snapshots "$SESSION"

Watch a multi-agent session

Monitor all panes in a session with periodic status updates:

./scripts/session-watch.sh -S "$SOCKET" -s "pi-multiagent" -i 30

This displays a formatted table showing the last non-empty line from each pane (truncated to 40 chars), updated every N seconds. Ideal for watching multi-agent workflows where different panes run parallel tasks.

Find sessions across all sockets

./scripts/find-sessions.sh --all

Sending Input Safely

Always use -l to prevent shell interpretation of special characters:

tmux -S "$SOCKET" send-keys -t TARGET -l -- "your command here"
tmux -S "$SOCKET" send-keys -t TARGET Enter

Control keys: C-c (interrupt), C-d (EOF), C-l (clear), Escape, Tab, BSpace, F1–F12.



Session Watching

The session-watch.sh script provides a convenient way to monitor multi-agent tmux sessions with a formatted display that shows the current state of each pane at regular intervals.

Basic Usage

./scripts/session-watch.sh [OPTIONS]

Options:

  • -S, --socket-path — tmux socket path (default: /tmp/pi-tmux-sockets/pi.sock)
  • -s, --session — session name (default: pi-multiagent)
  • -i, --interval — update interval in seconds (default: 60)
  • -h, --help — show usage information

Example:

# Watch with default settings
./scripts/session-watch.sh

# Custom socket and session
./scripts/session-watch.sh -S /tmp/my.sock -s mysession

# Update every 15 seconds
./scripts/session-watch.sh -i 15

Output Format: The script displays a table with:

  • Timestamp of each update
  • Pane index and label (0=Dev, 1=QA, 2=QA)
  • Last non-empty line from each pane (truncated to 40 characters)
  • Context usage from tmux environment variable #E

Use Cases:

  • Monitoring parallel agent tasks running in separate panes
  • Quick status checks without attaching to the session
  • Watching long-running workflows in a read-only manner

Watching Output

# Capture last 200 lines (joined, no wrapping artifacts):
tmux -S "$SOCKET" capture-pane -p -J -t TARGET -S -200

# Poll until text appears (preferred over sleep loops):
./scripts/wait-for-text.sh -S "$SOCKET" -t TARGET -p 'pattern' -T 20 -i 0.5 -l 2000

wait-for-text.sh options:

  • -t target (required)
  • -p regex pattern (required); add -F for fixed string
  • -T timeout seconds (default 15)
  • -i poll interval (default 0.3)
  • -l history lines to search (default 1000)
  • Exits 0 on match, 1 on timeout; prints last capture to stderr on failure.

Stability Detection (Agent Completion)

Use when you need to know if a long-running agent/command has truly finished:

prev=""
stable=0
STABLE_ROUNDS=3
while true; do
  current=$(tmux -S "$SOCKET" capture-pane -t TARGET -p \
    | sed 's/\x1b\[[0-9;]*m//g' \
    | grep -vE '[0-9]{2}:[0-9]{2}:[0-9]{2}')
  if [ "$current" = "$prev" ]; then
    ((stable++))
    [ "$stable" -ge "$STABLE_ROUNDS" ] && break
  else
    stable=0
    prev="$current"
  fi
  sleep 2
done

Interactive Tool Recipes

See references/steering-agents.md for the full guide. Quick patterns:

  • Python REPL: set PYTHON_BASIC_REPL=1; start python3 -q; wait for ^>>>; send code with -l.
  • gdb/lldb: start with --quiet; disable paging; wait for (gdb)/(lldb) prompt; send commands with -l.
  • Node / psql / mysql / bash: same pattern — start program, poll for prompt, send literal text + Enter.
  • When debugging, prefer lldb by default.

Common Scripting Patterns

See references/scripting-automation.md for the full reference including format strings, conditionals, and one-liners.

# Check if session exists before creating:
if ! tmux -S "$SOCKET" has-session -t "$SESSION" 2>/dev/null; then
  tmux -S "$SOCKET" new-session -d -s "$SESSION"
fi

# Get PID of process in pane and wait for it to exit:
PID=$(tmux -S "$SOCKET" display-message -t "$SESSION":0.0 -p '#{pane_pid}')
while kill -0 "$PID" 2>/dev/null; do sleep 0.5; done

Configuration

See references/configuration.md for the full ~/.tmux.conf guide.

Reload config at runtime:

tmux source-file ~/.tmux.conf

Plugins

See references/plugins.md for TPM, tmux-resurrect, tmux-continuum, tmux-yank, themes, and more.


Cleanup

tmux -S "$SOCKET" kill-session -t "$SESSION"          # kill one session
tmux -S "$SOCKET" kill-server                          # kill everything on this socket

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.