| name | hex1b |
| description | CLI tool for automating any terminal application — TUI apps, shells, CLI tools, REPLs, and more. Use when you need to launch a process in a virtual terminal, capture its screen output, inject keystrokes or mouse input, take screenshots, record sessions, or assert on what's visible. |
Hex1b CLI Skill
The dotnet hex1b CLI tool lets you automate any terminal application — TUI apps,
interactive CLIs, shells, REPLs, curses programs, or anything else that runs in a terminal.
It wraps arbitrary processes in a headless virtual terminal, giving you programmatic control
over screen capture, input injection, and content assertions.
Installation
dotnet tool install -g Hex1b.Tool
dotnet new tool-manifest
dotnet tool install --local Hex1b.Tool
dotnet tool restore
Concepts
A terminal is a headless virtual terminal managed by Hex1b. Any process that runs in a
terminal emulator can be launched inside one. Terminals are identified by a short numeric ID
(the process ID). Use a prefix if unambiguous.
All commands support --json for machine-readable output.
How to Launch a Process in a Virtual Terminal
Start any command in a headless terminal. This is the entry point for all automation.
dotnet hex1b terminal start -- bash
dotnet hex1b terminal start --width 120 --height 40 -- htop
dotnet hex1b terminal start --cwd /path/to/project -- vim myfile.txt
dotnet hex1b terminal start -- dotnet run --project src/MyApp
dotnet hex1b terminal start --attach -- bash
To get the terminal ID for subsequent commands:
dotnet hex1b terminal list
ID=$(dotnet hex1b terminal start --json -- dotnet run --project src/MyApp | jq -r .id)
How to See What's on Screen
Capture the terminal's visible content at any point.
dotnet hex1b capture screenshot <id>
dotnet hex1b capture screenshot <id> --format ansi
dotnet hex1b capture screenshot <id> --format svg --output screenshot.svg
dotnet hex1b capture screenshot <id> --format png --output screenshot.png
dotnet hex1b capture screenshot <id> --format html --output screenshot.html
dotnet hex1b capture screenshot <id> --scrollback 100
dotnet hex1b capture screenshot <id> --format png --output ready.png --wait "Ready" --timeout 30
The --wait option polls until the specified text is visible, then captures. Useful when
the application takes time to render its initial state.
How to Wait for Something to Appear
Use assertions to block until content is visible (or confirm it's absent). This is essential
for reliable automation — never assume timing.
dotnet hex1b assert <id> --text-present "Welcome" --timeout 30
dotnet hex1b assert <id> --text-absent "Error" --timeout 10
Exit code 0 means the assertion passed; non-zero means it failed (timed out).
How to Send Keyboard Input
Type text or send individual keys to the terminal.
dotnet hex1b keys <id> --text "hello world"
dotnet hex1b keys <id> --key Enter
dotnet hex1b keys <id> --key Tab
dotnet hex1b keys <id> --key Escape
dotnet hex1b keys <id> --key UpArrow
dotnet hex1b keys <id> --key C --ctrl
dotnet hex1b keys <id> --key S --ctrl
dotnet hex1b keys <id> --key Tab --shift
dotnet hex1b keys <id> --key F --ctrl --shift
Available key names (from the Hex1bKey enum, case-insensitive):
- Letters:
A–Z
- Digits:
D0–D9
- Function keys:
F1–F12
- Navigation:
UpArrow, DownArrow, LeftArrow, RightArrow, Home, End, PageUp, PageDown
- Editing:
Backspace, Delete, Insert
- Whitespace:
Tab, Enter, Spacebar
- Other:
Escape
- Punctuation:
OemComma, OemPeriod, OemMinus, OemPlus, OemQuestion, Oem1, Oem4, Oem5, Oem6, Oem7, OemTilde
- Numpad:
NumPad0–NumPad9, Multiply, Add, Subtract, Decimal, Divide
How to Send Mouse Input
Click or drag at specific terminal coordinates (0-based column, row).
dotnet hex1b mouse click <id> 10 5
dotnet hex1b mouse click <id> 10 5 --button right
dotnet hex1b mouse drag <id> 5 3 20 3
How to Start a Recording After a Terminal Has Launched
If the terminal is already running, start recording its session to an asciinema .cast file.
dotnet hex1b terminal start -- dotnet run --project src/MyApp
dotnet hex1b capture recording start <id> --output session.cast
dotnet hex1b capture recording start <id> --output session.cast --title "Demo session" --idle-limit 2.0
dotnet hex1b keys <id> --text "hello"
dotnet hex1b keys <id> --key Enter
dotnet hex1b capture recording stop <id>
How to Record a Session from the Moment It Starts
Use --record on terminal start to begin recording immediately when the process launches.
dotnet hex1b terminal start --record session.cast -- dotnet run --project src/MyApp
dotnet hex1b assert <id> --text-present "Ready" --timeout 15
dotnet hex1b keys <id> --key Enter
dotnet hex1b capture screenshot <id> --format text
dotnet hex1b capture recording stop <id>
How to Stop a Recording
dotnet hex1b capture recording stop <id>
dotnet hex1b capture recording status <id>
The .cast file is written incrementally, so the file will contain all events up to the
point you stop.
How to Play Back a Recording
dotnet hex1b capture recording playback --file session.cast
dotnet hex1b capture recording playback --file session.cast --speed 2.0
dotnet hex1b capture recording playback --file session.cast --player
How to Inspect a Hex1b TUI App's Widget Tree
If the terminal is running a Hex1b application with .WithDiagnostics() enabled, you can
inspect its internal widget/node tree.
dotnet hex1b app tree <id>
dotnet hex1b app tree <id> --focus
dotnet hex1b app tree <id> --popups
dotnet hex1b app tree <id> --depth 3
dotnet hex1b app tree <id> --json
How to Stop and Clean Up Terminals
dotnet hex1b terminal stop <id>
dotnet hex1b terminal info <id>
dotnet hex1b terminal resize <id> --width 160 --height 50
dotnet hex1b terminal clean
How to Attach Interactively
Attach to a terminal for interactive use — you see what the process sees and can type directly.
dotnet hex1b terminal attach <id>
How to Set Up the Agent Skill File
Generate this skill file for a repository so AI agents know how to use the CLI.
dotnet hex1b agent init
dotnet hex1b agent init --path /path/to/repo
dotnet hex1b agent init --force
dotnet hex1b agent init --stdout
Common Workflow: End-to-End Scripted Test
ID=$(dotnet hex1b terminal start --json -- dotnet run --project src/MyApp | jq -r .id)
dotnet hex1b assert $ID --text-present "Main Menu" --timeout 15
dotnet hex1b keys $ID --key Enter
dotnet hex1b assert $ID --text-present "Settings"
dotnet hex1b keys $ID --text "new value"
dotnet hex1b keys $ID --key Enter
dotnet hex1b capture screenshot $ID --format png --output result.png
dotnet hex1b capture screenshot $ID --format text
dotnet hex1b terminal stop $ID
Common Workflow: Record a Demo
ID=$(dotnet hex1b terminal start --json --record demo.cast -- dotnet run --project samples/MyApp | jq -r .id)
dotnet hex1b assert $ID --text-present "Ready" --timeout 15
dotnet hex1b keys $ID --key Tab
dotnet hex1b keys $ID --key Enter
dotnet hex1b capture screenshot $ID --format png --output highlight.png
dotnet hex1b capture recording stop $ID
dotnet hex1b terminal stop $ID
dotnet hex1b capture recording playback --file demo.cast --player
Tips
- Use
--json with jq for scriptable output: dotnet hex1b terminal list --json | jq '.[] | .id'
- Terminal IDs are PIDs — use a unique prefix instead of the full number
terminal list automatically cleans up stale sockets from exited processes
capture screenshot --wait is useful for waiting for async rendering before capturing
- Always use
assert before interacting — never assume the app has rendered
- For PNG screenshots,
--output is required since PNG is a binary format
- Recordings use the asciinema v2
.cast format and can be played with any compatible player