tmux
Control interactive CLIs (python, gdb, etc.) via tmux sessions - send keystrokes and scrape output
13 stars
Best use case
tmux is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Control interactive CLIs (python, gdb, etc.) via tmux sessions - send keystrokes and scrape output
Teams using tmux should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
$curl -o ~/.claude/skills/tmux/SKILL.md --create-dirs "https://raw.githubusercontent.com/connorads/dotfiles/main/.agents/skills/tmux/SKILL.md"
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/tmux/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How tmux Compares
| Feature / Agent | tmux | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Control interactive CLIs (python, gdb, etc.) via tmux sessions - send keystrokes and scrape output
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# tmux Skill
Use tmux to control interactive terminal applications by sending keystrokes and capturing output.
## When to Use
- Running interactive REPLs (python, node, psql)
- Debugging with gdb/lldb
- Any CLI that requires TTY interaction
- Remote execution where you need to observe output
## Core Pattern
```bash
# Create session
tmux new-session -d -s "$SESSION" -x 120 -y 40
# Send commands
tmux send-keys -t "$SESSION" "python3" Enter
# Capture output
tmux capture-pane -t "$SESSION" -p
# Wait for prompt (poll)
for i in {1..30}; do
output=$(tmux capture-pane -t "$SESSION" -p)
if echo "$output" | grep -q ">>>"; then break; fi
sleep 0.5
done
# Cleanup
tmux kill-session -t "$SESSION"
```
## Remote Execution (Codespaces/SSH)
For mise-installed tools, wrap in zsh:
```bash
# Non-interactive (won't hang)
ssh host 'zsh -c "source ~/.zshrc; tmux new-session -d -s mysession; tmux send-keys -t mysession python Enter"'
# Interactive (for tmux attach) - needs TTY
ssh host -t 'zsh -ilc "tmux attach -t mysession"'
```
**Critical**: Use `zsh -c "source ~/.zshrc; ..."` not `zsh -lc` to avoid hangs.
## User Notification
After starting a session, ALWAYS print:
```
To monitor: tmux attach -t $SESSION
To capture: tmux capture-pane -t $SESSION -p
```
## Tips
- Use `-x 120 -y 40` for consistent pane size
- Poll with `capture-pane -p` rather than `wait-for`
- Send literal text with `-l` flag to avoid shell expansion
- Control keys: `C-c` (interrupt), `C-d` (EOF), `Escape`
- For Python REPL: set `PYTHON_BASIC_REPL=1` to avoid fancy console interference
## Helper Scripts
### [wait-for-text.sh](scripts/wait-for-text.sh)
Poll tmux pane for a text pattern with timeout:
```bash
scripts/wait-for-text.sh -t session:0.0 -p '^>>>' -T 15
```
### [find-sessions.sh](scripts/find-sessions.sh)
List tmux sessions, optionally filtered:
```bash
scripts/find-sessions.sh -q claude # filter by name
scripts/find-sessions.sh --all # all sessions
```Related Skills
We are still matching the closest adjacent skills for this page. In the meantime, continue through the full directory.