English | 简体中文
An Agent Skill and macOS terminal screenshot runner for visually verifying CLI output, ANSI colors, table alignment, and TUI layouts in an isolated iTerm2 or Terminal.app window — without interrupting or writing into the user's active terminal session.
Most CLI regressions can be checked with unit tests, git diff --check, or stdout assertions. When a real rendered terminal screenshot is needed (color contrast, Unicode column widths, box drawing, wrapping), running ad hoc AppleScript against current window or front window hijacks focus and pollutes the user's live shell.
terminal-visual-qa isolates visual verification into a dedicated, persistent QA window whose ID is saved across runs, waits deterministically for command completion before capturing, and never targets the user's active terminal session.
- macOS with
osascriptandscreencapture - iTerm2 (recommended — allows background window updates and screenshots without stealing focus) or Terminal.app
- macOS Automation permission (for
osascriptcontrolling iTerm2 / Terminal) and Screen Recording permission (forscreencapture)
npx skills add xdlkc/terminal-visual-qa# Codex
git clone https://github.com/xdlkc/terminal-visual-qa "${CODEX_HOME:-$HOME/.codex}/skills/terminal-visual-qa"
# Claude Code
git clone https://github.com/xdlkc/terminal-visual-qa ~/.claude/skills/terminal-visual-qa
# Agent Skills-compatible harnesses
git clone https://github.com/xdlkc/terminal-visual-qa ~/.agents/skills/terminal-visual-qa- Automated checks first (
SKILL.md): Run unit tests,git diff --check, stdout snapshots, or ANSI-stripped width checks before taking a screenshot. - One-time window initialization (
--create): When no saved QA window exists (or was closed), runscripts/terminal_visual_qa.shwith--create. In iTerm2, it creates a window bounded at{40, 60, 1900, 1080}, names the session"Terminal Visual QA", and stores the window ID in/tmp/terminal-visual-qa-<app>-window-id. - Zero-interruption reuse: Subsequent calls omit
--create, look up the saved window ID directly, and execute withoutactivate,front window, orcurrent windowtargeting. - Deterministic completion marker + capture: The script writes a temporary runner (
/tmp/terminal-visual-qa-<app>-runner-<pid>.sh) thatcds into--cwd, clears the QA window, executes--command, prints__TERMINAL_VISUAL_QA_DONE__ status=<exit>, and touches a done marker file (/tmp/terminal-visual-qa-<app>-done-<pid>). Once the marker appears (polled every0.1sup to--timeout), it waits0.5s, captures the window viascreencapture -x -l"<WIN_ID>" "<OUTPUT>", cleans up temporary files, and prints:window=<id> image=<path>
terminal_visual_qa.sh --command '<cmd>' [--cwd <dir>] [--app iterm|terminal] [--output <png>] [--timeout <sec>] [--create]
| Flag | Required | Default | Description |
|---|---|---|---|
--command '<cmd>' |
Yes | — | Shell command to render inside the isolated QA window. |
--cwd <dir> |
No | Current $PWD |
Working directory executed before running --command (validated to exist). |
--app iterm|terminal |
No | iterm |
Target terminal application (iterm for iTerm2 or terminal for Terminal.app). |
--output <png> |
No | /tmp/terminal-visual-qa-screenshots/terminal-visual-qa-<app>-<YYYYMMDD-HHMMSS>.png |
Destination PNG screenshot path (parent directories created automatically). |
--timeout <sec> |
No | 60 |
Maximum seconds to wait for the done marker before failing (exit 1). |
--create |
No | Disabled | Create and persist a new QA window if no saved window ID exists or matches an open window. Without --create, missing windows fail immediately. |
-h, --help |
No | — | Print usage help and exit. |
Initialize the isolated iTerm2 QA window once:
SKILL_DIR="${CODEX_HOME:-$HOME/.codex}/skills/terminal-visual-qa"
"$SKILL_DIR/scripts/terminal_visual_qa.sh" \
--app iterm --create --cwd "$PWD" \
--command 'ls -la --color=always'Reuse the saved QA window without activating it or creating extra windows:
SKILL_DIR="${CODEX_HOME:-$HOME/.codex}/skills/terminal-visual-qa"
"$SKILL_DIR/scripts/terminal_visual_qa.sh" \
--app iterm --cwd "$PWD" \
--command '<command to render>' \
--output /tmp/terminal-visual-qa-screenshots/check.pngagents/openai.yamlexposes display metadata (Terminal Visual QA) and the default prompt (Use $terminal-visual-qa to run a terminal command in an isolated QA window and capture a screenshot.).- Do not use Computer Use on iTerm2 or Terminal.app (often blocked by policy and disruptive).
- Do not target the user's active terminal session or use
activate,front window, orcurrent windowon repeat runs. - Do not pass
--createroutinely — only initialize once or when a previously saved QA window was closed. - Always attach/cite the resulting
image=<path>screenshot path when visual verification matters.
| Symptom | Fix |
|---|---|
Saved iTerm QA window not found. Run with --create once. (or Terminal equivalent) |
The QA window was not initialized yet or was closed; re-run once with --create. |
| Table columns or lines wrap unexpectedly | Widen the QA window or narrow the rendered table width and re-run. |
Terminal.app brings itself to focus during do script |
Switch to --app iterm for non-intrusive background reuse. |
.
├── SKILL.md # Agent workflow, safety rules, troubleshooting
├── agents/
│ └── openai.yaml # Codex skill UI display metadata & default prompt
├── scripts/
│ └── terminal_visual_qa.sh # Isolated AppleScript + screencapture QA runner
├── README.md
└── README.zh-CN.md