跪拜 Guibai
← Back to the summary

phone-harness Lets AI Agents Tap, Swipe, and Type on Real Phones Without Appium or Root

Hello everyone, I'm Kuang Shi.

People who have done mobile testing are very familiar with the traditional App automation testing process. First set up the environment: JDK, Android SDK, Appium Server. If versions don't match, the device won't connect. For iOS, one more step: configure Xcode to sign WebDriverAgent. Once the environment is working, use inspector to grab locators one by one, write id and xpath into scripts, add sleep when the page loads slowly, and if a pop-up upgrade prompt appears mid-test, the test case breaks. When the page is redesigned, locators fail in droves, and fixing scripts becomes daily maintenance.


Today I'm sharing an automation open-source project: phone-harness.

phone-harness eliminates the entire traditional flow described above. You only need to give Claude Code or another AI Agent a one-sentence task using the phone. It takes screenshots itself, recognizes the text on the screen, and the operations that used to be hard-coded in scripts are now decided on the fly by the Agent watching the screen.

This project is still in its early stage. You only need to remember a few key facts.

What it does is simple, in one sentence: It connects a real phone's screen and touch input to AI Agents like Claude Code and Codex. The Agent can read text on the screen, tap, swipe, and type. No jailbreak, no root, and no app installation required.

How it connects to your phone

For iPhone, it uses the Mac's built-in iPhone Mirroring, requiring macOS 15 or above with an iPhone running iOS 18 or above. phone-harness captures that mirror window, uses Apple's Vision OCR to read the text on the screen, and converts taps, swipes, and keyboard input into events sent into the window.

For Android, it uses adb. Screenshots and input are standard adb capabilities; reading the screen uses the accessibility tree (accessibility tree). It works on macOS, Linux, and Windows, and supports both USB and Wi-Fi connections.

The key is that both paths expose the same interface to the Agent. The same script works on either phone. The script looks like this; Python code is fed directly to the command line.

phone-harness <<'PY'
open_app("Notes")
tap_text("New Note")
type_text("hello from the harness")
print([o["text"] for o in screen()][:10])
PY

open_app opens an app, tap_text finds the text on the screen and taps it, screen() returns the full screen text. There are about 50 such helper functions, all pre-imported, and there are waiting-built-in helpers like scroll_until (scroll until a condition is met) and wait_for_text (wait for a certain text to appear), so you don't have to write sleep yourself.

Official demo

The README includes a demo: on a real iPhone, it hailed a Waymo. The task was exactly "Buy me a Waymo to Delah Coffee from my current location". The Agent opened Waymo, selected pickup and drop-off points, and hailed the ride.

The phone is real, the app is installed from the App Store, and no test interface was involved.

Install with one command, hand the task to the Agent

Install is one command, using uv as follows. Requires uv and Python 3.12; the package supports 3.10 and above. If you don't have uv, pip install phone-harness also works.

uv tool install --python 3.12 --upgrade --force phone-harness

An even easier way is to send the setup prompt in the README verbatim to your coding Agent. The Agent will install it itself, register the skill, and read the docs if it gets stuck.

Install or upgrade phone-harness to the latest stable version with uv using Python 3.12, register the skill from `phone-harness skill`, then read https://github.com/phone-harness/phone-harness/blob/main/onboarding.md and walk me through it. Follow https://github.com/phone-harness/phone-harness/blob/main/install.md if setup or connection fails.

There are four components; beginners only need the first two.

The environment requirements depend on the phone. For iPhone, a Mac with an iPhone running iOS 18 or above, with accessibility and screen recording permissions enabled. For Android, just enable USB debugging in developer options. After installation, run a self-check to see if you can connect to the default phone.

phone-harness <<'PY'
ensure_device()
PY

A few limitations to know before using

The author clearly states the boundaries in the README; here are the important ones.

Final thoughts

This tool is still quite new; use it or not, but if you have no real-device integration needs, installing it is just for fun.

The approach is worth learning from. Mobile automation has been tied to adding interfaces to apps for years: testing requires instrumentation, automation requires installing clients, and the more changes you make, the harder it is to roll out. phone-harness reverses that, using the system's existing mirroring and adb to expose the screen and input. Any app can be operated without modification. Next time you need real-device integration tasks like verification codes, push notifications, or on-device regression, this approach of treating the screen as the interface can be borrowed.

GitHub project address:

https://github.com/phone-harness/phone-harness
Comments

Top 1 from juejin.cn, machine-translated. The original thread is authoritative.

用户683530038274

Does phone-harness connect directly to the real device, or does it need an agent installed first?