Claude TUI
Send slash commands to a Claude Code TUI session via tmux and capture the output. Resumes the target session in a detached tmux pane, sends the command, waits for output to stabilize, captures it, and tears down.
Prerequisites
- tmux must be installed (
brew install tmuxon macOS)
Commands
# Send /context to a specific session
python3 .claude/skills/claude-tui/scripts/tui_cmd.py <session-id> /context
# Send /compact to the most recent session
python3 .claude/skills/claude-tui/scripts/tui_cmd.py --latest /compact
# Send /cost to a session
python3 .claude/skills/claude-tui/scripts/tui_cmd.py <session-id> /cost
# Custom timeout (default: 30s)
python3 .claude/skills/claude-tui/scripts/tui_cmd.py --latest --timeout 60 /compact
# Use custom projects directory
python3 .claude/skills/claude-tui/scripts/tui_cmd.py --latest --dir /path/to/projects /context
Output
Session: 82c946c8-1eb8-4c70-9414-813fc0a278e4
Command: /context
Context Usage
...
How it works
- Launches
claude --resume <session-id>in a detached tmux session - Waits for the TUI to initialize (polls until pane output stabilizes)
- Sends the slash command via
tmux send-keys - Polls every 0.5s until output stabilizes (two identical captures), max 30s
- Captures the final pane content
- Kills the tmux session and Claude process