| name | test-cli |
| description | Start tmux sessions, send prompts to the CLI, capture output, and verify behavior using helper scripts. Use when testing the CLI, interactive mode, TUI components, or when the user mentions tmux sessions. |
| allowed-tools | ["Bash","Read"] |
Test CLI Skill
This skill helps test the interactive CLI application using tmux sessions via bash commands, providing a real terminal environment for testing OpenTUI-based interactive components.
Quick Start: Use Helper Scripts First
IMPORTANT: Always use these helper scripts for testing. Only use raw tmux commands (documented below) if the scripts don't support your specific use case.
All scripts are located at .claude/skills/test-cli/scripts/ and should be run from your project root directory.
Basic Testing Workflow
PANE_ID=$(./.claude/skills/test-cli/scripts/start-cli-test.sh)
./.claude/skills/test-cli/scripts/send-prompt.sh $PANE_ID "your prompt here" --submit
sleep 5
tmux capture-pane -t $PANE_ID -p
./.claude/skills/test-cli/scripts/exit-cli-test.sh $PANE_ID
./.claude/skills/test-cli/scripts/cleanup-cli-tests.sh
Helper Scripts Reference
start-cli-test.sh
Creates a tmux session and launches the CLI. Returns the pane ID.
PANE_ID=$(./.claude/skills/test-cli/scripts/start-cli-test.sh)
PANE_ID=$(./.claude/skills/test-cli/scripts/start-cli-test.sh my-test)
send-prompt.sh
Sends text character-by-character (simulates realistic typing).
./.claude/skills/test-cli/scripts/send-prompt.sh $PANE_ID "hello world"
./.claude/skills/test-cli/scripts/send-prompt.sh $PANE_ID "hello world" --submit
exit-cli-test.sh
Properly exits the CLI (sends two Ctrl+C within 3 seconds).
./.claude/skills/test-cli/scripts/exit-cli-test.sh $PANE_ID
cleanup-cli-tests.sh
Kills test sessions matching a pattern.
./.claude/skills/test-cli/scripts/cleanup-cli-tests.sh
./.claude/skills/test-cli/scripts/cleanup-cli-tests.sh "my-test-*"
CLI-Specific Behavior
Exit Confirmation
The CLI requires two Ctrl+C presses within 3 seconds to exit (src/tui/components/TUIApp.tsx:111-123). The exit-cli-test.sh script handles this automatically.
Essential tmux Commands for Debugging
tmux capture-pane -t $PANE_ID -p
tmux capture-pane -t $PANE_ID -p -S -100
tmux capture-pane -t $PANE_ID -p -S -500
tmux list-sessions
IMPORTANT: Never use tmux attach - it blocks execution. Always use capture-pane to read output.
Troubleshooting
- No output after sending prompt: Add
sleep 5-10 before capturing output
- Pane not found: Check session exists with
tmux list-sessions
- Need to see what happened: Capture more lines with
tmux capture-pane -t $PANE_ID -p -S -500
- CLI seems stuck: Capture output to see current state, don't attach to session
Related Files
testing-cli-with-tmux.md - Original documentation and learnings
interactive-tests/ - Interactive test suite using tmux
src/tui/components/TUIApp.tsx - CLI exit behavior implementation