← Back to library

Let a CLI agent drive your screen to test a UI

Mohamed EL BATHA explains how Claude Code can operate the Mac screen from the terminal, but only as a fallback. It tries a shell command first, then an MCP tool if available, and turns to the screen only when a task genuinely needs eyes. Disabled by default and switched on per project, it requests permission for each app every session.

  • OutcomeCheck that a UI actually works by letting your terminal coding agent control the screen as a last resort, after it has tried commands and tools first.
  • SetupUnder an hour
  • LevelIntermediate
  • CreditMohamed EL BATHA
View original
Works with
Claude Code

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 23, 2026

When should you use it?

  • You want an agent to verify a UI, not just write code
  • You prefer commands and tools over screen control
  • You can grant permissions per session

Not for: Granting broad screen access without per-app approval; Headless or non-interactive sessions, where it does not run

What do you need, and what do you get?

You need

  • A supported interactive session on a Mac
  • OS permissions for watching and controlling the screen
  • A UI task that truly needs the screen

You get

  • A UI exercised the way a person would
  • Commands and tools tried before screen control
  • Per-app approval prompts you can allow or deny

How does it work, step by step?

  1. Keep it a last resortLet the agent run a command or use an MCP tool first; screen control only when needed.
  2. Enable it per projectTurn the feature on for the specific codebase, since it is off by default.
  3. Grant the OS permissionsApprove accessibility and screen recording, then restart the session if prompted.
  4. Approve each appAllow access per app per session rather than opening everything at once.
  5. Watch broad-reach warningsNote the extra warnings for terminals and IDEs, which are like shell access.

The prompt

Our own prompt, inspired by Mohamed EL BATHA and written to work in Claude Code. Values in lime are placeholders.

Prompt0 variables
For this task, prefer a shell command first, then an MCP tool if one fits, and only control the screen if the task genuinely requires it, such as verifying a rendered UI. Before touching any app, tell me which one and why. Exercise the interface the way a user would, report what you saw, and stop if an action needs broader access than I approved.

Inspired by Mohamed EL BATHA: Claude Code Computer Use: Test UIs Without Leaving the CLI. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.

What can go wrong?

  • Terminals and IDEs get flagged as shell-equivalent; approve them deliberately.
  • It needs an interactive session and does not work headless, so plan around that.

Our take

The design choice Mohamed EL BATHA highlights is worth copying in any agent setup: an escalation ladder that runs from a shell command, to a dedicated tool, to the screen only when nothing else will do. Screen control is slow, fragile and broad, since an agent that can click anywhere can also click the wrong thing, so making it the last resort keeps most work fast and predictable. The per-project setting and per-app approval each session add containment. Use screen control for what it is genuinely good at, such as checking that a UI renders correctly, that a button actually works or that a flow behaves the same as the tests claim. Close unrelated apps and private windows before a session, because a screenshot can capture anything visible, including messages or financial pages. Resist approving every app permanently for convenience. If the tool warns that an action has broad reach, such as controlling a terminal or a browser with logged-in sessions, read it rather than clicking through, and switch the feature off in projects that no longer need it.

Where the time goes back: UI checks that normally pull you out of the terminal get done in place, with the agent only touching the screen when nothing else will do.

FAQ

When does it use the screen?
Only as a last resort, after trying a shell command or an MCP tool for the task.
Is access broad by default?
No. It is off by default, enabled per project, and each app is approved per session.

Source and credit

Inspired by Mohamed EL BATHA. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.

Inspired by
Claude Code Computer Use: Test UIs Without Leaving the CLI
Creator
Mohamed EL BATHA
Published on
claudcod.com
Original date
Jun 6, 2026
License
Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
Originally for
Claude Code
AI dry run
Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

Are you the creator? Claim or correct this page.

More in IT & Security

All 82 IT & Security playbooks →

Related playbooks

IT & SecurityWorkflow✓ AI dry run

Compare an agent run with a task you did by hand

Before you believe big productivity claims, time and cost one routine agent task against a similar one you did yourself, counting review and cleanup.

Credit: Chris_Newton on Hacker News

Under an hour
IT & SecuritySkill✓ AI dry run

Find repeat fixes and good habits in your team's PRs

Have Claude Code look across a chosen window of commits and pull request review comments for the same fix or review note coming up again and again, suggest turning the top ones into a project rule or skill you write in your own words, and list good practices already in the repo that other teams could copy.

Credit: anthropics

Under an hour
IT & SecurityWorkflow✓ AI dry run

Hands-free voice loop for a coding agent

Add on-device voice input and spoken replies to your coding agent, with a tap to interrupt, so you can steer it while cooking or cleaning.

Credit: yberreby on Hacker News

An afternoon+
IT & SecurityWorkflow✓ AI dry run

Have a different model family critique the spec

Plan a spec with one model, have a model from another family critique it, then write tests, build and review against that spec.

Credit: u/wczaja on r/ClaudeAI

Under an hour