Tests web apps or browser games on a real Android phone via adb, using Chrome DevTools Protocol for metrics like LCP, CLS, and FPS with real touch input. Use when emulation is insufficient.
Ships in android-device-testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Emulation lies about the things that break on phones. DevTools device mode and headless Chrome with a phone viewport give you the right CSS width, but not:
display-mode: standalone) — Chrome ignores
Emulation.setEmulatedMedia for display-mode, so it cannot be faked.So: build the layout in emulation, decide on the phone. If a check matters for the verdict and the phone was not available, say so in the report.
adb devices -l # note the serial of the physical phone
S=<serial> # always scope every command: adb -s "$S" ...
adb -s "$S" shell dumpsys power | grep -E 'mWakefulness=' # Awake / Asleep / Dozing
adb -s "$S" shell dumpsys window | grep -E 'isKeyguardShowing|mDreamingLockscreen|mShowingLockscreen'
-s <serial>. A stale or offline emulator left in the list
makes every unscoped command fail with more than one device/emulator.requestAnimationFrame, so FPS and paint timings are garbage.
DevTools eval may still answer with layout numbers; screenshots will not.Record the conditions you find and do not "fix" them: battery saver, dark
mode, rotation lock (settings get system accelerometer_rotation reads it;
0 = locked), no network. They change results — put them in the report.
PORT=5173 # your dev or preview server port
adb -s "$S" reverse tcp:$PORT tcp:$PORT # phone's localhost:$PORT -> your machine
adb -s "$S" forward tcp:9222 localabstract:chrome_devtools_remote
curl -s http://localhost:9222/json/version # Chrome on the phone answers
curl -s http://localhost:9222/json/list # its tabs (type, url, webSocketDebuggerUrl)
Open the page in a tab you own, so you can close it afterwards:
curl -s -X PUT "http://localhost:9222/json/new?http://localhost:$PORT/" # returns the new target's id
# or through Android itself (may reuse the current tab):
adb -s "$S" shell am start -a android.intent.action.VIEW -d "http://localhost:$PORT/" com.android.chrome
Measure a production build served locally (build + preview/start),
not the dev server: dev mode ships unminified modules and its timings mean
nothing. Through adb reverse there is no real network, so LCP is only valid
as a before/after comparison on the same phone, not as a field number.
Mark the phone's viewport once per session — it is not the spec sheet value:
node scripts/cdp.mjs eval 'innerWidth+"x"+innerHeight+" dpr "+devicePixelRatio+" vv "+visualViewport.height'
Repeat after anything that changes the browser chrome (scroll that hides the toolbar, rotation, fullscreen, an info bar appearing).
scripts/cdp.mjs is a dependency-free client (Node 22+, global WebSocket):
node scripts/cdp.mjs targets # list tabs
node scripts/cdp.mjs eval '<js expression>' # in the first tab whose URL matches $CDP_MATCH (default "localhost")
node scripts/cdp.mjs console 10 # print console + exceptions for 10 s
node scripts/cdp.mjs center 'button.play' # element centre in CSS px + DPR
node scripts/cdp.mjs close # close the matched tab
For richer runs use puppeteer-core against the same endpoint —
puppeteer.connect({ browserURL: "http://localhost:9222" }); see
scripts/phone-probe.mjs, which prints the first-screen metrics of §4 as JSON.
Do not call page.setViewport or emulation on the phone: you would be
emulating on a real device and lose the point of it.
Typing: adb shell input text does not reach inputs in Chrome reliably. Focus
the field and use CDP Input.insertText instead (puppeteer: page.keyboard.sendCharacter).
adb shell input tap X Y and input swipe X1 Y1 X2 Y2 MS take physical
screen pixels, origin at the top-left of the display (status bar included):
x = cssX × DPR + offsetX (offsetX is 0 in portrait)
y = cssY × DPR + offsetY (offsetY = status bar + browser toolbar + any info bar)
Do not guess offsetY from a spec — calibrate it:
node scripts/cdp.mjs eval 'window.__tap=null; addEventListener("pointerdown", e => window.__tap = {x: e.clientX, y: e.clientY}, {capture: true, once: true}); "armed"'
adb -s "$S" shell input tap 540 1400 # anywhere on page content
node scripts/cdp.mjs eval 'JSON.stringify(window.__tap)'
# offsetY = 1400 - tap.y × DPR ; offsetX = 540 - tap.x × DPR
Recalibrate whenever the toolbar hides, the phone rotates or fullscreen starts. Tap the arming point on something inert (page background), not a link.
Then tap an element by its rect:
OX=0; OY=<calibrated offsetY>
read CX CY DPR < <(node scripts/cdp.mjs center '[data-testid=play]')
adb -s "$S" shell input tap $(node -e "console.log(Math.round($CX*$DPR+$OX), Math.round($CY*$DPR+$OY))")
Limits to report, not hide: adb input is one finger, and each command
takes a few hundred ms. Two-finger play (move + jump) and fast rhythm input
cannot be verified this way; CDP Input.dispatchTouchEvent can send several
touch points, but that is synthetic input, not a finger on glass. Say which
one you used.
Probes are in references/measurements.md (copy-paste JS for cdp.mjs eval
or phone-probe.mjs). Typical set for a page:
scrollWidth - innerWidth must be 0.PerformanceObserver, before any touch, 5 reloads,
report median and range, plus the LCP element.requestAnimationFrame callbacks over 5 s.
Values cluster at 60/30/20/15 (vsync halving). If the engine caps its own
frame rate, rAF overstates — read the engine's own counter if it exposes one.cdp.mjs console).Write every number with its conditions: phone model class, browser version, viewport, DPR, build, network state, battery saver.
adb -s "$S" exec-out screencap -p > shot.png # exec-out, not shell: no CRLF mangling
If you must not load images into your own context (some agent setups crash or waste tokens on large PNGs), analyse them by script and hand the files to a human or a review page:
magick shot.png -format '%[fx:mean] %[fx:standard_deviation]\n' info: # ~0 0 => all black: phone asleep, not a bug
magick shot.png -resize 540x shot-s.jpg # small copy for a PR or review page
CDP Page.captureScreenshot captures only the page (no browser chrome) and is
the better choice for "what does the layout look like"; screencap shows what
the user sees, toolbar and system bars included.
The phone usually belongs to a person who will pick it up after you.
input keyevent KEYCODE_BACK) only while your page is in front;
never navigate the launcher, other apps, notifications or the lock screen.HTMLMediaElement.prototype.play stub or
the app's mute) before starting a game; never leave a game running.adb -s "$S" reverse --remove-all,
adb -s "$S" forward --remove-all.A report has three kinds of statements; keep them apart:
Never silently replace a phone check with emulation. "Not tested on the phone, it was locked" is a useful sentence; a green checkmark from device mode is not.
offsetY.scripts/cdp.mjs — minimal DevTools client: targets, eval, console, centre, close.scripts/phone-probe.mjs — puppeteer-core connect({browserURL}), first-screen
metrics and rects of the matched tab as JSON (diff two runs to prove "unchanged").references/measurements.md — the JS probes and how to read them.What SKILL.md sets; muted values are Claude Code's defaults
/android-device-testing:android-device-testingfrom android-device-testing
npx claudepluginhub freema/ai-skills --plugin android-device-testing