Skip to content

About

Agent Skill and macOS script for isolated iTerm2 and Terminal.app UI screenshot verification without interrupting the user's active terminal.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terminal-visual-qa

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.

Why It Exists

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.

Prerequisites

  • macOS with osascript and screencapture
  • iTerm2 (recommended — allows background window updates and screenshots without stealing focus) or Terminal.app
  • macOS Automation permission (for osascript controlling iTerm2 / Terminal) and Screen Recording permission (for screencapture)

Installation

Via skills.sh

npx skills add xdlkc/terminal-visual-qa

Manual Clone

# 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

How It Works

  1. Automated checks first (SKILL.md): Run unit tests, git diff --check, stdout snapshots, or ANSI-stripped width checks before taking a screenshot.
  2. One-time window initialization (--create): When no saved QA window exists (or was closed), run scripts/terminal_visual_qa.sh with --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.
  3. Zero-interruption reuse: Subsequent calls omit --create, look up the saved window ID directly, and execute without activate, front window, or current window targeting.
  4. Deterministic completion marker + capture: The script writes a temporary runner (/tmp/terminal-visual-qa-<app>-runner-<pid>.sh) that cds 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 every 0.1s up to --timeout), it waits 0.5s, captures the window via screencapture -x -l"<WIN_ID>" "<OUTPUT>", cleans up temporary files, and prints:
    window=<id>
    image=<path>
    

Script Usage (scripts/terminal_visual_qa.sh)

terminal_visual_qa.sh --command '<cmd>' [--cwd <dir>] [--app iterm|terminal] [--output <png>] [--timeout <sec>] [--create]

Options

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.

Examples

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.png

Agent Integration & Rules

  • agents/openai.yaml exposes 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, or current window on repeat runs.
  • Do not pass --create routinely — 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.

Troubleshooting

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.

Repository Structure

.
├── 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

About

Agent Skill and macOS script for isolated iTerm2 and Terminal.app UI screenshot verification without interrupting the user's active terminal.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages