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
# 1. Start a test session
PANE_ID=$(./.claude/skills/test-cli/scripts/start-cli-test.sh)
# 2. Send a prompt to the CLI
./.claude/skills/test-cli/scripts/send-prompt.sh $PANE_ID "your prompt here" --submit
# 3. Wait for response and capture output
sleep 5
tmux capture-pane -t $PANE_ID -p
# 4. Exit CLI cleanly
./.claude/skills/test-cli/scripts/exit-cli-test.sh $PANE_ID
# 5. Cleanup sessions
./.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.
# Auto-generated session name
PANE_ID=$(./.claude/skills/test-cli/scripts/start-cli-test.sh)
# Custom session name
PANE_ID=$(./.claude/skills/test-cli/scripts/start-cli-test.sh my-test)
send-prompt.sh
Sends text character-by-character (simulates realistic typing).
# Send text without submitting
./.claude/skills/test-cli/scripts/send-prompt.sh $PANE_ID "hello world"
# Send text and press Enter
./.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.
# Kill all "cli-test-*" sessions
./.claude/skills/test-cli/scripts/cleanup-cli-tests.sh
# Custom pattern
./.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
# Capture output (use after sending prompts)
tmux capture-pane -t $PANE_ID -p # Current screen
tmux capture-pane -t $PANE_ID -p -S -100 # Last 100 lines
tmux capture-pane -t $PANE_ID -p -S -500 # Last 500 lines
# List all sessions
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-10before 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 learningsinteractive-tests/- Interactive test suite using tmuxsrc/tui/components/TUIApp.tsx- CLI exit behavior implementation