Languages: English | 简体中文
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 (
FocusViolationon breach), and dangerous system shortcuts (Cmd+Q,Cmd+Tab,Cmd+H,Cmd+Space, etc.) are refused by default.
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. |
uv tool install git+https://github.com/x0c/macos-e2e-toolkit.gitAlternative: 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 .Install cua-driver (>= 0.56) from the official Cua Driver quickstart, then grant macOS permissions once:
cua-driver permissions grantAlso enable Accessibility and Screen Recording for the terminal or IDE hosting your agent in System Settings → Privacy & Security.
npx skills add x0c/macos-e2e-toolkit -gThis 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.
macos-e2e doctormacos-e2e run /path/to/your-macos-appOn 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).
# 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"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 ./auditSwiftUI 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.
- 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+ (
uvorpipxrecommended). - Driver:
cua-driver0.56+. - Display state: An awake, unlocked macOS session on the active Space (macOS hides window AX trees and window buffers while locked).
SKILL.md— Agent skill instructions, red lines, test API, anti-false-pass gates, and failure playbook.references/cua-audit-guide.md— Observation economics, 2-call window taxonomy, live-content safety, and multi-agent fan-out rules.references/app-integration-swift.md— Minimal Swift/AppKit background window integration template.SECURITY.md— Private vulnerability reporting.
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. |