| name | agent-tui |
| description | Drive terminal UI (TUI) applications programmatically for testing, automation, and inspection. Use when: automating CLI/TUI interactions, regression testing terminal apps, verifying interactive behavior, extracting structured data from terminal UIs. Also use when: user asks "what is agent-tui", "what does agent-tui do", "demo agent-tui", "show me agent-tui", "how does agent-tui work", or wants to see it in action. Do NOT use for: web browsers, GUI apps, or non-terminal interfacesโthose need different tools.
|
Terminal Automation Mastery
Prerequisites
- Supported OS: macOS or Linux (Windows not supported yet).
- Verify install:
agent-tui --version
If not installed, use one of:
curl -fsSL https://raw.githubusercontent.com/pproenca/agent-tui/master/install.sh | sh
npm i -g agent-tui
pnpm add -g agent-tui
bun add -g agent-tui
cargo install --git https://github.com/pproenca/agent-tui.git --path cli/crates/agent-tui
If you used the install script, ensure ~/.local/bin is on your PATH.
Philosophy: Why Terminal Automation Is Different
Terminal UIs are stateless from the observer's perspective. Unlike web browsers with a persistent DOM, terminal automation works with a constantly-refreshed character grid. This fundamental difference shapes everything:
| Web Automation | Terminal Automation |
|---|
| DOM persists across interactions | Screen buffer redraws constantly |
| Stable UI IDs | No stable IDs; re-snapshot frequently |
| Query once, act many times | Re-snapshot before each decision |
| Network events signal completion | Detect visual stability or text |
The Core Insight: agent-tui gives you vision without memory. Each screenshot is a fresh observation. Previous screenshots can become stale after any UI change.
Mental Model: The Feedback Loop
Think of terminal automation as a closed-loop control system:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โ
OBSERVE โโโบ DECIDE โโโบ ACT โโโบ WAIT โโโบ VERIFY โโโโ
โ โ
โ โ
โโโโโโโโ NEVER skip โโโโโโโโโโโโโโโโโโโโโโ
Each phase is mandatory. Skipping verification is the #1 cause of flaky automation.
The "Fresh Eyes" Principle
Every time you need to interact with the UI:
- Take a fresh screenshot โ your previous one can be stale
- Re-read your target โ the screen may have shifted
- Verify the state โ the UI may have changed unexpectedly
- Act only when stable โ animations and loading states cause failures
This feels slower, but it's the only reliable approach. Optimistic reuse of stale state causes intermittent failures that are painful to debug.
Critical Rules (Non-Negotiable)
RULE 1: Re-snapshot after EVERY action
Screens can change after any interaction. Always take a fresh screenshot before deciding again.
RULE 2: Never act on unstable UI
If the UI is animating, loading, or transitioning, wait --stable first. Acting during transitions causes race conditions.
RULE 3: Verify before claiming success
Use wait "expected text" --assert to confirm outcomes. Don't assume an action workedโprove it.
RULE 4: Clean up sessions
Always end with agent-tui kill. Orphaned sessions consume resources and can interfere with future runs.
Decision Framework
Which Screenshot Mode?
Need only raw text?
โโโบ YES: Use `screenshot` (plain text, faster)
โ
โโโบ NO: Need machine-readable output?
โโโบ Use `screenshot --json`
How to Wait?
What are you waiting for?
โ
โโโบ Specific text to appear
โ โโโบ `wait "text" --assert`
โ
โโโบ Specific text to disappear
โ โโโบ `wait "text" --gone`
โ
โโโบ UI to stop changing (animations, loading)
โโโบ `wait --stable`
How to Act?
What do you need to do?
โ
โโโบ Type text into focused input
โ โโโบ `input "text"` (or `type "text"`)
โ
โโโบ Send keyboard shortcuts/navigation
โ โโโบ `press Ctrl+C` or `press ArrowDown Enter`
โ
โโโบ Scroll the viewport
โโโบ `scroll down 5`
Core Workflow
The canonical automation loop:
agent-tui run <command> [-- args...]
agent-tui screenshot --format json
agent-tui press Enter
agent-tui wait "Expected" --assert
agent-tui kill
Anti-Patterns (What NOT to Do)
โ Acting on Stale Screens
agent-tui screenshot --json
agent-tui press Enter
agent-tui screenshot --json
agent-tui press Enter
โ Acting During Animation/Loading
agent-tui run my-app
agent-tui press Enter
agent-tui run my-app
agent-tui wait --stable
agent-tui press Enter
โ Assuming Success Without Verification
agent-tui press Enter
agent-tui press Enter
agent-tui wait "Success" --assert