Skip to content

About

Test, audit, and regress macOS desktop apps in the background without moving the cursor or stealing focus, via cua-driver, AX actions, and pixel baselines for Claude Code, Codex, Cursor, and Pi

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Languages: English | 简体中文

macos-e2e-toolkit

License: MIT Platform: macOS skills.sh

Test, audit, and regress native macOS desktop apps in the background — without moving your cursor or stealing window focus.

macos-e2e-toolkit pairs a guarded Python E2E harness (macos-e2e, built on cua-driver, macOS Accessibility, and screencapture -l) with an AI coding agent skill (SKILL.md) for Claude Code, Codex, Cursor, Pi, OpenCode, and Antigravity.

100% Local Execution · Zero Telemetry · Focus-Safe · macOS Only Every action runs locally on your Mac behind your active window. Every driver call is bracketed by a frontmost-PID and cursor-drift guard (FocusViolation on breach), and dangerous system shortcuts (Cmd+Q, Cmd+Tab, Cmd+H, Cmd+Space, etc.) are refused by default.


Why This Exists

Driving real macOS apps from an AI agent usually breaks in three ways: it hijacks your mouse and foreground window, it produces false-green tests when flags/mocks bypass real rendering or persistence, or it fails silently when the screen locks or a window moves to another Space.

macos-e2e-toolkit solves all three:

Capability What it gives you
Focus-safe background control Launches apps with open -g -n -a, drives AX actions, hotkeys, menus, and scrolling in the background, and asserts zero frontmost changes and zero cursor drift.
Occlusion-independent visual baselines Captures by window_id (screencapture -l) even when the window is completely covered, compares Retina-aware pixels, and outputs actual.png / baseline.png / diff.png + manifest.json.
One-command suite & quick actions macos-e2e run . scaffolds and runs Tests/E2E; macos-e2e do runs a single background click, hotkey, menu, AX read, or capture with zero suite boilerplate.
Built-in CUA audit instrumentation macos-e2e audit-call and macos-e2e audit-aggregate log per-call latency, payload size, and refusals (metrics.tsv) for exploratory audits and multi-agent fan-out.
Agent skill with battle-tested gates SKILL.md teaches agents how to self-install missing tools, classify windows before acting, avoid live-editor mutation traps, and prevent false-green E2E passes.

Install (macOS Only)

1. Install the macos-e2e CLI

uv tool install git+https://github.com/x0c/macos-e2e-toolkit.git
Alternative: pipx or editable install from source
# With pipx
pipx install git+https://github.com/x0c/macos-e2e-toolkit.git

# From a local clone
git clone https://github.com/x0c/macos-e2e-toolkit.git
cd macos-e2e-toolkit
uv venv && uv pip install -e .

2. Install cua-driver (required runtime dependency)

Install cua-driver (>= 0.56) from the official Cua Driver quickstart, then grant macOS permissions once:

cua-driver permissions grant

Also enable Accessibility and Screen Recording for the terminal or IDE hosting your agent in System Settings → Privacy & Security.

3. Install the Agent Skill

npx skills add x0c/macos-e2e-toolkit -g

This installs the macos-swift-e2e skill (SKILL.md + references/) into your coding agent runtimes. If an agent loads the skill on a fresh Mac where macos-e2e or cua-driver is missing, the skill guides it to install them from the official sources and run macos-e2e doctor.


Quick Start

Check your environment

macos-e2e doctor

Scaffold and run a deterministic E2E suite

macos-e2e run /path/to/your-macos-app

On the first run, macos-e2e run creates Tests/E2E/ (conftest.py, e2e.json, run_e2e.sh, test_app_smoke.py) and captures initial visual baselines. Run it a second time to verify deterministic match (diff_ratio == 0.0).

Run a one-shot background action (no suite required)

# Read AX text and capture a running app's window
macos-e2e do --app MyApp --text --shot /tmp/myapp.png

# Open Settings in the background via hotkey and inspect its labels
macos-e2e do --app MyApp --hotkey cmd+, --window-title "Settings" --labels

# Trigger a menu item in the background
macos-e2e do --pid 1234 --menu "View>Zoom In"

Audit live apps with per-call metrics

CUA_AUDIT_LOG=./audit/myapp/metrics.tsv CUA_AUDIT_SESSION=audit-myapp \
  macos-e2e audit-call get_window_state '{"session":"audit-myapp","pid":1234,"window_id":567,"query":"AXTextArea","include_screenshot":false}'

macos-e2e audit-aggregate ./audit

Preparing Your macOS App

SwiftUI WindowGroup apps launched in the background (open -g) defer window creation until activated. To make your app testable in the background, add a small --e2e-testing hook that presents an AppKit NSWindow with orderBack(nil), isolates data under --e2e-root, and locks appearance deterministically.

See the copy-pasteable Swift template in references/app-integration-swift.md.


Prerequisites

  • OS: macOS 14+ (Apple Silicon or Intel). This toolkit relies on AppKit, Quartz, AXUIElement, and screencapture -l, and does not support Linux or Windows.
  • Python: 3.11+ (uv or pipx recommended).
  • Driver: cua-driver 0.56+.
  • Display state: An awake, unlocked macOS session on the active Space (macOS hides window AX trees and window buffers while locked).

Documentation


Related Tools

If you run multiple AI coding agents daily, check out the rest of the local-first toolkit:

Repository Description
corral Search local coding-agent sessions, delegate durable runs, and coordinate parallel agents across Claude Code, Codex, OpenCode, Cursor, Pi, and Antigravity.
subswap Check remaining quota and switch Claude Code, Codex, Cursor, Kimi Code, and OpenCode accounts without logging out.
agentsync Sync AGENTS.md, CLAUDE.md, skills, and MCP configs across coding agents from one local source of truth.
agent-doc-skills Navigable project knowledge base skills (doc-init, doc-update, doc-compact) so coding agents do not rediscover your repo every session.
sesskit Parse and export local session transcripts from Claude Code, Codex, OpenCode, Cursor, Pi, and Antigravity.

MIT License

About

Test, audit, and regress macOS desktop apps in the background without moving the cursor or stealing focus, via cua-driver, AX actions, and pixel baselines for Claude Code, Codex, Cursor, and Pi

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages