Agent Skill
2/7/2026

termbox-testing

Test termbox2 UI applications using tmux sessions. Use this skill when you need to test terminal UI apps that require a real PTY, run pytest-based UI tests, or interact with tmux sessions programmatically.

A
acmiyaguchi
1GitHub Stars
1Views
npx skills add acmiyaguchi/zig-agent

SKILL.md

Nametermbox-testing
DescriptionTest termbox2 UI applications using tmux sessions. Use this skill when you need to test terminal UI apps that require a real PTY, run pytest-based UI tests, or interact with tmux sessions programmatically.

name: Termbox Testing description: Test termbox2 UI applications using tmux sessions. Use this skill when you need to test terminal UI apps that require a real PTY, run pytest-based UI tests, or interact with tmux sessions programmatically.

Termbox Testing with Tmux

This skill runs termbox2 UI tests using tmux to provide a real PTY environment. Termbox2 fails in headless environments but works inside tmux sessions.

Quick Start - Run All Tests

cd /home/anthony/zig-agent
zig build && uv run --with pytest --with pytest-json-report pytest scripts/test_termbox.py -v --tb=short

Quick Start - Machine-Readable Output

cd /home/anthony/zig-agent
uv run --with pytest --with pytest-json-report pytest scripts/test_termbox.py --json-report --json-report-file=test_results.json -q
cat test_results.json

Step-by-Step Workflow

Step 1: Build the Project

cd /home/anthony/zig-agent && zig build 2>&1

If build fails: Fix errors, rebuild. Do not proceed until build succeeds.

Step 2: Run Pytest

uv run --with pytest --with pytest-json-report pytest scripts/test_termbox.py -v --tb=short 2>&1

Output interpretation:

  • PASSED - Test succeeded
  • FAILED - Test failed (see error message)
  • SKIPPED - Test skipped (usually missing API key)
  • ERROR - Test crashed before completing

Step 3: For Specific Tests

Run a single test:

uv run --with pytest pytest scripts/test_termbox.py::TestTmuxHarness::test_session_creation -v

Run a test class:

uv run --with pytest pytest scripts/test_termbox.py::TestBasicShell -v

Manual Tmux Testing (for debugging)

Use the CLI harness for interactive debugging:

Create a session

uv run scripts/tmux_harness.py create mytest 80 24

Returns JSON: {"status": "created", "session": {"name": "mytest_abc123", ...}}

Run a command

uv run scripts/tmux_harness.py run mytest_abc123 "./zig-out/bin/zig-agent"

Type text (without Enter)

uv run scripts/tmux_harness.py type mytest_abc123 "hello world"

Send special key

uv run scripts/tmux_harness.py key mytest_abc123 Enter
uv run scripts/tmux_harness.py key mytest_abc123 C-c
uv run scripts/tmux_harness.py key mytest_abc123 Up

Capture screen

uv run scripts/tmux_harness.py capture mytest_abc123

Returns JSON with lines array and raw string.

Wait for text

uv run scripts/tmux_harness.py wait mytest_abc123 ">" 10

Returns {"status": "found", ...} or {"status": "timeout", ...}

Kill session

uv run scripts/tmux_harness.py kill mytest_abc123

Common Special Keys

Keytmux nameDescription
EnterEnterSubmit/newline
EscapeEscapeEscape key
Ctrl+CC-cInterrupt
Ctrl+DC-dEOF
BackspaceBSpaceDelete char
Arrow UpUpNavigate up
Arrow DownDownNavigate down
Arrow LeftLeftMove cursor left
Arrow RightRightMove cursor right
TabTabTab key
SpaceSpaceSpace key

Writing New Test Scenarios

Add tests to scripts/test_termbox.py:

class TestMyFeature:
    def test_something(self, tmux_session: TmuxSession, ensure_built, project_root: Path):
        """Describe what this test verifies."""
        binary = project_root / "zig-out" / "bin" / "zig-agent"

        # Start the app
        tmux_session.run(str(binary))

        # Wait for prompt
        assert_text_appears(tmux_session, ">", timeout=5)

        # Interact
        tmux_session.type_text("my input")
        tmux_session.send_key("Enter")

        # Verify
        assert_text_appears(tmux_session, "expected output", timeout=10)

Key Fixtures

FixturePurpose
tmux_sessionFresh tmux session, auto-cleanup
ensure_builtBuilds project before test
project_rootPath to project root

Key Helpers

HelperPurpose
assert_text_appears(session, text, timeout)Fail if text doesn't appear
assert_text_absent(session, text)Fail if text appears
session.wait_for_stable()Wait for screen to stop changing

Troubleshooting

ProblemSolution
"tmux not found"Install tmux: sudo apt install tmux
Tests hangCheck for blocking wait_for_text with text that never appears
Session leakRun tmux kill-server to clean up all sessions
"Binary not found"Run zig build first
API tests skipSet OPENROUTER_API_KEY environment variable

List active tmux sessions

tmux list-sessions

Kill all tmux sessions

tmux kill-server

Attach to session for debugging

tmux attach -t session_name

(Use Ctrl+B D to detach)


JSON Output Format

When using --json-report:

{
  "summary": {
    "total": 10,
    "passed": 8,
    "failed": 1,
    "skipped": 1
  },
  "tests": [
    {
      "nodeid": "scripts/test_termbox.py::TestTmuxHarness::test_session_creation",
      "outcome": "passed",
      "duration": 0.234
    }
  ]
}

Workflow Summary

1. zig build                                                    # Build project
2. uv run --with pytest pytest scripts/test_termbox.py -v      # Run tests
3. (If fails) Fix code, goto 1
4. (If passes) Done!

For machine-readable results:

uv run --with pytest --with pytest-json-report pytest scripts/test_termbox.py --json-report --json-report-file=results.json -q && cat results.json
Skills Info
Original Name:termbox-testingAuthor:acmiyaguchi