Agent skill

tmux

Remote control tmux sessions for interactive CLIs (python, gdb, etc.) by sending keystrokes and scraping pane output.

Stars 1
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/geggo98/dotfiles/tree/main/modules/ai/_files/skills/tmux

SKILL.md

tmux Skill

Use tmux as a programmable terminal multiplexer for interactive work. Works on Linux and macOS with stock tmux; the claude-tmux wrapper manages sockets, targets, and defaults automatically.

Detailed References

Topic Description Reference
Sending keystrokes send-keys modes (literal vs key-name), control keys, quoting, multi-line input, pitfalls send-keys
Capturing output capture-pane flags, scrollback depth, polling patterns, filtering capture-output
Interactive recipes Step-by-step for Python, lldb, gdb, psql, node, pdb, long-running servers interactive-recipes
Session management Creating, targeting, inspecting, and cleaning up sessions/windows/panes session-management

Wrapper Script: claude-tmux

All tmux interactions go through ./scripts/claude-tmux.sh. This avoids raw variable expansion in shell commands (no more $SOCKET / $SESSION security prompts).

Defaults:

  • Socket: ${TMPDIR}/claude-tmux-sockets/claude.sock (created automatically)
  • Target: auto-detected (first session on the socket, pane :0.0)

Commands at a glance

Command Description Example
new Create a session ./scripts/claude-tmux.sh new -s claude-py -c 'PYTHON_BASIC_REPL=1 python3 -q'
send Send literal text + Enter ./scripts/claude-tmux.sh send 'print("hello")'
keys Send special keys ./scripts/claude-tmux.sh keys C-c
capture Print current pane content ./scripts/claude-tmux.sh capture
delta Print only new output since last capture/delta ./scripts/claude-tmux.sh delta
wait Poll for text pattern ./scripts/claude-tmux.sh wait -p '^>>>'
list List sessions ./scripts/claude-tmux.sh list
kill Kill session or server ./scripts/claude-tmux.sh kill -s claude-py
attach Print monitor command for user ./scripts/claude-tmux.sh attach

Global options (before the command)

  • -S PATH — override socket path
  • -t TARGET — override pane target (session:window.pane)

Quickstart

bash
# Start a Python REPL session
./scripts/claude-tmux.sh new -s claude-py -c 'PYTHON_BASIC_REPL=1 python3 -q'

# Wait for the prompt
./scripts/claude-tmux.sh wait -p '^>>>'

# Send code
./scripts/claude-tmux.sh send 'print("hello world")'

# Read output
./scripts/claude-tmux.sh capture

# Read only new output since last capture
./scripts/claude-tmux.sh delta

# Clean up
./scripts/claude-tmux.sh kill -s claude-py

After starting a session ALWAYS tell the user how to monitor it. Use ./scripts/claude-tmux.sh attach to print the command, or manually give them:

To monitor this session yourself:
  tmux -S '<socket-path>' attach -t '<session>'

This must ALWAYS be printed right after a session was started and once again at the end of the tool loop.

Targeting specific panes

When running multiple sessions or panes, use -t globally:

bash
./scripts/claude-tmux.sh -t claude-gdb:0.0 send 'bt'
./scripts/claude-tmux.sh -t claude-gdb:0.0 capture

Without -t, the script auto-detects the first session on the socket.

Sending input safely

  • send uses -l (literal mode) by default — no shell expansion, no tmux key interpretation. Text is followed by Enter automatically.
  • Use send -R for raw mode (tmux key names like Up, Down are interpreted).
  • Use keys for special keys without text: keys C-c, keys C-d, keys Escape, keys Enter.

Watching output

  • capture prints the last 200 lines (adjustable with -l). It also saves a snapshot for delta.
  • delta prints only lines that are new since the last capture or delta call — useful for tracking incremental output without re-reading everything.
  • wait -p PATTERN polls until a regex matches (default 15s timeout). Use -F for fixed strings, -T for custom timeout.

Spawning Processes

  • When asked to debug, use lldb by default.
  • When starting a python interactive shell, always set PYTHON_BASIC_REPL=1. Pass it via -c:
    bash
    ./scripts/claude-tmux.sh new -s claude-py -c 'PYTHON_BASIC_REPL=1 python3 -q'
    

Interactive tool recipes

  • Python REPL: new -s claude-py -c 'PYTHON_BASIC_REPL=1 python3 -q'; wait -p '^>>>'; send 'code'; interrupt with keys C-c.
  • lldb: new -s claude-lldb -c 'lldb ./a.out'; wait -p '\\(lldb\\)'; send 'breakpoint set ...'; exit via send quit.
  • gdb: new -s claude-gdb -c 'gdb --quiet ./a.out'; wait -p '\\(gdb\\)'; send 'set pagination off'; exit via send quit then send y.
  • Other TTY apps (psql, node, bash): same pattern — new with -c, wait for prompt, send commands.

Cleanup

bash
# Kill one session
./scripts/claude-tmux.sh kill -s claude-py

# Kill everything on the socket
./scripts/claude-tmux.sh kill --all

Expand your agent's capabilities with these related and highly-rated skills.

geggo98/dotfiles

eval-notebook

Execute .ipynb notebooks (Python, Kotlin, or any Jupyter kernel) without overwriting; return LLM-friendly JSON with outputs and errors. Use when you need to run or validate a Jupyter notebook.

1 0
Explore
geggo98/dotfiles

nix-shell

Search Nix packages and run commands with packages from nixpkgs that are not installed locally. Use when you need a package not available locally or want to search nixpkgs.

1 0
Explore
geggo98/dotfiles

slidev

Create and present web-based slidedecks for developers using Slidev with Markdown, Vue components, code highlighting, animations, and interactive features. Use when building technical presentations, conference talks, code walkthroughs, teaching materials, or developer decks. Also trigger when the user mentions Slidev, sli.dev, slide decks with code, or wants to create developer-facing presentations.

1 0
Explore
geggo98/dotfiles

diagram-render

Render PlantUML (@startuml…@enduml) and Mermaid fenced blocks to a self-contained HTML preview; if rendering fails, the error text must be embedded in the output image. Use when the user asks to render, preview, or export diagrams.

1 0
Explore
geggo98/dotfiles

adr-writing

Use when documenting significant architectural decisions. Creates focused ADRs explaining context, decision, and alternatives. Prevents vague documentation and implementation detail bloat. Triggers: 'create ADR', 'document decision', making technology/framework/persistence/auth choices, cross-cutting concerns.

1 0
Explore
geggo98/dotfiles

writing-clearly-and-concisely

Use when writing documentation, commit messages, error text, explanations, reports, or summaries. Applies Strunk's principles for clear, vigorous prose. Triggers: writing human-readable content, verbose text, unclear explanations.

1 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results