
Using Tmux For Interactive Commands
- 433 installs
- 401 repo stars
- Updated June 1, 2026
- obra/superpowers-lab
using-tmux-for-interactive-commands is an agent skill that runs interactive CLI tools in detached tmux sessions so coding agents can send keystrokes and read pane output for vim, git rebase, and REPL workflows.
About
using-tmux-for-interactive-commands is a superpowers-lab skill for situations where standard bash cannot control programs that require a real TTY—vim, nano, interactive git rebase, Python REPLs, and similar tools. It uses detached tmux sessions controlled programmatically via send-keys to inject input and capture-pane to read screen output. Developers and coding agents reach for this skill when automating editor sessions, stepping through interactive git flows, or driving REPL-based debugging where piping stdin fails. The approach keeps sessions alive across agent turns and avoids pseudo-TTY hacks in one-off shell invocations.
- tmux pane lifecycle for long-running commands.
- Send keys and capture scrollback safely.
- Pairs with Superpowers debugging workflows.
Using Tmux For Interactive Commands by the numbers
- 433 all-time installs (skills.sh)
- +11 installs in the week ending Jul 18, 2026 (Skillselion tracking)
- Ranked #125 of 560 CLI & Terminal skills by installs in the Skillselion catalog
- Security screen: HIGH risk (skills.sh audit)
- Data as of Jul 23, 2026 (Skillselion catalog sync)
npx skills add https://github.com/obra/superpowers-lab --skill using-tmux-for-interactive-commandsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 433 |
|---|---|
| repo stars | ★ 401 |
| Security audit | 2 / 3 scanners passed |
| Last updated | June 1, 2026 |
| Repository | obra/superpowers-lab ↗ |
How do agents run interactive CLI tools like vim?
Run interactive CLI commands in tmux panes so agents can send keystrokes and read output.
Who is it for?
Coding agents or developers automating vim, interactive git rebase, or REPL sessions that need real terminal input and output capture.
Skip if: Non-interactive commands that run fine in a normal shell invocation without a persistent TTY session.
When should I use this skill?
An agent must run vim, nano, git rebase -i, a Python REPL, or another interactive CLI that blocks on real-time terminal I/O.
What you get
A detached tmux session driving the interactive program with scripted keystrokes and captured pane output the agent can parse.
- detached tmux session
- captured pane transcript
- completed interactive CLI workflow
Files
Using tmux for Interactive Commands
Overview
Interactive CLI tools (vim, interactive git rebase, REPLs, etc.) cannot be controlled through standard bash because they require a real terminal. tmux provides detached sessions that can be controlled programmatically via send-keys and capture-pane.
When to Use
Use tmux when:
- Running vim, nano, or other text editors programmatically
- Controlling interactive REPLs (Python, Node, etc.)
- Handling interactive git commands (
git rebase -i,git add -p) - Working with full-screen terminal apps (htop, etc.)
- Commands that require terminal control codes or readline
Don't use for:
- Simple non-interactive commands (use regular Bash tool)
- Commands that accept input via stdin redirection
- One-shot commands that don't need interaction
Quick Reference
| Task | Command |
|---|---|
| Start session | tmux new-session -d -s <name> <command> |
| Send input | tmux send-keys -t <name> 'text' Enter |
| Capture output | tmux capture-pane -t <name> -p |
| Stop session | tmux kill-session -t <name> |
| List sessions | tmux list-sessions |
Core Pattern
Before (Won't Work)
# This hangs because vim expects interactive terminal
bash -c "vim file.txt"After (Works)
# Create detached tmux session
tmux new-session -d -s edit_session vim file.txt
# Send commands (Enter, Escape are tmux key names)
tmux send-keys -t edit_session 'i' 'Hello World' Escape ':wq' Enter
# Capture what's on screen
tmux capture-pane -t edit_session -p
# Clean up
tmux kill-session -t edit_sessionImplementation
Basic Workflow
1. Create detached session with the interactive command 2. Wait briefly for initialization (100-500ms depending on command) 3. Send input using send-keys (can send special keys like Enter, Escape) 4. Capture output using capture-pane -p to see current screen state 5. Repeat steps 3-4 as needed 6. Terminate session when done
Special Keys
Common tmux key names:
Enter- Return/newlineEscape- ESC keyC-c- Ctrl+CC-x- Ctrl+XUp,Down,Left,Right- Arrow keysSpace- Space barBSpace- Backspace
Working Directory
Specify working directory when creating session:
tmux new-session -d -s git_session -c /path/to/repo git rebase -i HEAD~3Helper Wrapper
For easier use, see /home/jesse/git/interactive-command/tmux-wrapper.sh:
# Start session
/path/to/tmux-wrapper.sh start <session-name> <command> [args...]
# Send input
/path/to/tmux-wrapper.sh send <session-name> 'text' Enter
# Capture current state
/path/to/tmux-wrapper.sh capture <session-name>
# Stop
/path/to/tmux-wrapper.sh stop <session-name>Common Patterns
Python REPL
tmux new-session -d -s python python3 -i
tmux send-keys -t python 'import math' Enter
tmux send-keys -t python 'print(math.pi)' Enter
tmux capture-pane -t python -p # See output
tmux kill-session -t pythonVim Editing
tmux new-session -d -s vim vim /tmp/file.txt
sleep 0.3 # Wait for vim to start
tmux send-keys -t vim 'i' 'New content' Escape ':wq' Enter
# File is now savedInteractive Git Rebase
tmux new-session -d -s rebase -c /repo/path git rebase -i HEAD~3
sleep 0.5
tmux capture-pane -t rebase -p # See rebase editor
# Send commands to modify rebase instructions
tmux send-keys -t rebase 'Down' 'Home' 'squash' Escape
tmux send-keys -t rebase ':wq' EnterCommon Mistakes
Not Waiting After Session Start
Problem: Capturing immediately after new-session shows blank screen
Fix: Add brief sleep (100-500ms) before first capture
tmux new-session -d -s sess command
sleep 0.3 # Let command initialize
tmux capture-pane -t sess -pForgetting Enter Key
Problem: Commands typed but not executed
Fix: Explicitly send Enter
tmux send-keys -t sess 'print("hello")' Enter # Note: Enter is separate argumentUsing Wrong Key Names
Problem: tmux send-keys -t sess '\n' doesn't work
Fix: Use tmux key names: Enter, not \n
tmux send-keys -t sess 'text' Enter # ✓
tmux send-keys -t sess 'text\n' # ✗Not Cleaning Up Sessions
Problem: Orphaned tmux sessions accumulate
Fix: Always kill sessions when done
tmux kill-session -t session_name
# Or check for existing: tmux has-session -t name 2>/dev/nullReal-World Impact
- Enables programmatic control of vim/nano for file editing
- Allows automation of interactive git workflows (rebase, add -p)
- Makes REPL-based testing/debugging possible
- Unblocks any tool that requires terminal interaction
- No need to build custom PTY management - tmux handles it all
#!/bin/bash
# Simple wrapper around tmux for Claude Code to interact with interactive programs
set -euo pipefail
ACTION="${1:-}"
SESSION_NAME="${2:-}"
case "$ACTION" in
start)
COMMAND="${3:-bash}"
shift 3 || true
ARGS="$*"
# Create new detached session
if [ -n "$ARGS" ]; then
tmux new-session -d -s "$SESSION_NAME" "$COMMAND" "$@"
else
tmux new-session -d -s "$SESSION_NAME" "$COMMAND"
fi
# Wait for initial output
sleep 0.3
# Capture and display initial state
echo "Session: $SESSION_NAME"
echo "---"
tmux capture-pane -t "$SESSION_NAME" -p
;;
send)
shift 2
if [ $# -eq 0 ]; then
echo "Error: No input provided" >&2
exit 1
fi
# Send all arguments as separate keys (allows "Enter", "Escape", etc.)
tmux send-keys -t "$SESSION_NAME" "$@"
# Wait a moment for output
sleep 0.2
# Capture and display updated state
echo "Session: $SESSION_NAME"
echo "---"
tmux capture-pane -t "$SESSION_NAME" -p
;;
capture)
echo "Session: $SESSION_NAME"
echo "---"
tmux capture-pane -t "$SESSION_NAME" -p
;;
stop)
tmux kill-session -t "$SESSION_NAME"
echo "Session $SESSION_NAME terminated"
;;
list)
tmux list-sessions
;;
*)
cat <<EOF
Usage: $0 <action> <session-name> [args...]
Actions:
start <session-name> <command> [args...] - Start a new interactive session
send <session-name> <input> - Send input to session (use Enter for newline)
capture <session-name> - Capture current pane output
stop <session-name> - Terminate session
list - List all sessions
Examples:
$0 start python_session python3 -i
$0 send python_session 'print("hello")' Enter
$0 capture python_session
$0 stop python_session
EOF
exit 1
;;
esac
Related skills
How it compares
Use this skill instead of raw shell execution whenever the target program expects a full-screen interactive terminal session.
FAQ
Why do agents need tmux for some commands?
Interactive CLI tools like vim, interactive git rebase, and REPLs require a real terminal and cannot be controlled through standard non-interactive bash. using-tmux-for-interactive-commands uses detached tmux sessions so agents can send-keys and capture-pane output programmatical
Which tools does using-tmux-for-interactive-commands cover?
The skill targets vim, nano, interactive git rebase -i, Python and other REPLs, and any CLI that needs real-time terminal input and output rather than a one-shot shell command with piped stdin.
How does an agent read output from a tmux session?
using-tmux-for-interactive-commands instructs agents to use tmux capture-pane to snapshot the visible terminal buffer after send-keys injects keystrokes, letting the agent parse on-screen program state between steps.
Is Using Tmux For Interactive Commands safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.