Phone harness

From oyi77/1ai-skills · View interactive version

Phone harness is an AI agent skill from the GitHub repository oyi77/1ai-skills. Use when an agent needs to control a real phone — iPhone via Mac iPhone Mirroring or Android via adb (open apps, tap, type, swipe, OCR the screen). Android path runs on this Linux workstation (adb), targets phonefarm devices. iOS path needs macOS + iPhone Mirroring. Use for phonefarm device debuggin

How to use this skill

Skill file

Phone Harness

Overview

Controls a real phone from the agent — iPhone via Mac iPhone Mirroring or Android via adb (open apps, tap, type, swipe, OCR the screen). Targets phonefarm devices for debugging, OTP/2FA flows, and one-off device QA.

When to Use

Trigger phrases:

account switches, uninstalls, first-run dialogs

When NOT to Use

(adapters/<platform>/mobile_adapter.py), not ad-hoc harness scripts

Workflow

  1. Install once (Android focus for this workstation):

```bash

git clone https://github.com/ShawnPana/phone-harness ~/.phone-harness

cd ~/.phone-harness && pip install -e .

# or: read install.md in the repo and follow it

phone-harness --doctor # verify adb + device chain

```

  1. Set Android default (this box has no macOS/iPhone Mirroring):

```bash

phone-harness config set platform android

```

  1. Drive the device (helpers pre-imported):

```python

task: dismiss a first-run dialog on the farm device

step: OCR, tap the right label, verify

open_app("chrome"); wait_stable()

tap_ui("Got it") # label from accessibility tree — exact, no misreads

```

  1. Verify after every action — adb reports nothing about outcomes; a tap on

empty space "succeeds". Use wait_for_app(...), wait_for_text(...), or

one ocr() check. Batch only steps already watched working.

  1. Keep the phone awake for long tasks: phone-harness android awake --bg,

then phone-harness android rest at the end.

Key helpers: ocr(), ui(), find_nodes(), tap_ui(), tap_text(),

screenshot(), open_app(), back(), current_app(), list_apps(),

swipe(), scroll(), type_text(), press().

Anti-Rationalization Table

| Rationalization | Reality |

|-----------------|---------|

| "The tap returned success" | adb always reports success; verify screen state changed |

| "I'll tap Connect/Continue myself" | Connection/unlock is the user's job; STOP and ask |

| "I'll type the PIN" | Never type a PIN; ask the user to unlock |

| "Screenshot pixel coords are fine for tap()" | iOS only: convert via image_point(); Android is 1:1 |

| "One big batch is faster" | Unverified batches fail silently; batch only proven steps |

| "uiautomator dump is stuck" | Known hang on React/WebView screens; use timeout + OCR fallback |

Verification

Code Example

PHONE_HARNESS_PLATFORM=android phone-harness <<'PY'
# task: confirm TikTok is foregrounded on the farm device
# step: launch, wait, read current app
open_app("com.zhiliaoapp.musically")
wait_stable()
print(current_app())
PY

Ecosystem Notes (1ai-phonefarm)

(adapters/*/mobile_adapter.py, backend/services/screen_assertions.py) —

prefer them for production flows.

OCR; phone-harness OCR uses the accessibility tree on Android — cheaper and

exact where a tree exists, tesseract where custom rendering wins.

not here.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.