跪拜 Guibai
← Back to the summary

Agent-Device: A Device Layer That Lets AI Agents Drive Simulators and Verify Their Own Code

Crazy! agent-device helps AI control apps, multi-device validation can run locally

I'm Kuangshi (狂师).

Today I'm sharing an open-source project: agent-device, a "device layer" for AI agents that lets programming assistants like Claude Code, Codex, and Cursor directly control real devices and simulators, and verify the app code they write.

Let's note down a few key facts first:

What it does is simple in one sentence: it gives AI agents device-control capabilities, letting them open apps, read the UI, click and input, debug and capture evidence, then after changing code, run it on a real device or simulator to verify, and leave screenshots and logs as proof.

agent-device official banner

The problem: AI writes app code, but verification still relies on humans

Any developer who has used AI agents to write apps knows this problem. The agent finishes the code, compilation passes, unit tests are all green, and then what? What the page looks like, whether buttons work, and whether it behaves correctly on both iOS and Android, it has no idea.

So the verification step still needs a human. Open the simulator, install the package, click through, take screenshots, copy the error, paste it back into the chat, wait for the agent to fix it, then reinstall and click again. A single round eats up dozens of minutes, slower than writing the code itself. As the project grows, iOS and Android each need separate setups, plus a real device, and the human becomes a courier between the agent and the device.

agent-device targets exactly this gap. Once installed, you can tell the agent something like the example in the official docs:

Implement the onboarding page, run it on both the iOS simulator and the Android simulator, and attach screenshots.

The agent opens the device itself, installs the package, clicks, checks the results, and hands you the evidence. You just approve.

How it lets AI use your app

The underlying approach is worth explaining. The most direct way for agents to control the UI is screenshots, letting the model look at the image to find a button. Large images burn tokens, and positions are often inaccurate.

agent-device takes a different path: it reads the system's accessibility tree (accessibility tree), turning the UI into a numbered list of elements. The agent operates by those numbers.

Take the official README example of adding a contact in iOS Contacts:

# Open a session and launch Contacts
agent-device open Contacts --platform ios

# Read the UI, output a numbered element list
agent-device snapshot -i
# @e2 [button] "Add"

# Click the button by number, --settle waits for the UI to stabilize before returning changes
agent-device press @e2 --settle
# + @e7 [text-field] "First name"

agent-device fill @e7 "Ada" --settle

# Take a screenshot as evidence, close the session
agent-device screenshot ./contact-form.png
agent-device close

After each step, the tool returns a diff of the UI changes, showing which elements appeared or which values changed, so the agent can confirm whether the previous step succeeded. When validation is done, screenshots, recordings, logs, network requests, and performance traces can all be archived and attached to a PR for human review.

agent-device demo, Codex creating a contact in iOS Contacts from a single prompt

One more detail is notable: when several agents run in parallel, the tool uses device occupancy declarations to say which simulator each agent's session holds, isolated by git worktree, so two agents never fight over the same device and confuse each other.

Almost full-platform support

The breadth of support is why it dares to be called a "device layer." On mobile, it covers iOS, Android, and HarmonyOS, both real devices and simulators; on TV, it covers tvOS, Android TV, and Fire TV, and even supports Amazon's newly launched Vega OS TV system; on desktop, it can automate macOS and Linux; and it has basic Web support. For app stacks, native, React Native, Expo, and Flutter are all covered.

Devices can run anywhere. Locally is the most direct, with simulators and real devices plugged in. If you don't have physical devices, you can connect to cloud real-device platforms like BrowserStack and AWS Device Farm, both officially integrated.

Install the CLI and hand it to your AI agent

There are three ways to integrate, choose as needed.

The simplest is pure CLI. Agents like Claude Code, Codex, Cursor, Windsurf, and Cline can already run terminal commands, so installing agent-device is all you need, no configuration.

For clients that support skills, one command wraps the official skill pack, and the agent follows the best practices inside:

npx skills add callstack/agent-device

For MCP, agent-device mcp starts a stdio server, and you add these lines to the client configuration:

{
  "mcpServers": {
    "agent-device": {
      "command": "agent-device",
      "args": ["mcp"]
    }
  }
}

All three routes share the same underlying runtime, so sessions, device occupancy, and evidence files behave identically. Choose whichever matches your agent's habits.

Quick start

Installation is one command, but a few environment prerequisites come first. Node.js 22.12 or higher (24+ for Web automation), Xcode for iOS features, ADB for Android, and the matching command-line tools for HarmonyOS.

npm install -g agent-device@latest

# First run a self-check yourself to confirm devices and toolchains are ready
agent-device doctor

# Then look at the workflow guide
agent-device help workflow

The official documentation stresses that you should run doctor yourself, confirm the local devices and toolchain are ready, and only then hand the command to the agent. Don't skip this step; if the environment lacks Xcode or ADB, the agent will just get a pile of errors, and debugging them back and forth wastes more time.

After install and a passing environment check, pick any system app and let the agent operate it. The Contacts example takes about five minutes; once it's green, you're good to go.

A few things to keep in mind

Support depth varies by platform. iOS and Android are the most complete; HarmonyOS and Vega OS currently only cover a subset of commands. Before taking over, run agent-device capabilities --platform <platform> to see the list, and don't apply iOS experience wholesale.

iOS real devices have a signing threshold. Simulators work out of the box, but real devices need a developer certificate and Team ID. The initial setup isn't beginner friendly, but the official docs give step-by-step guidance to follow.

Positioning: it's an "exploration and validation" tool, letting the agent observe state in real time and decide the next step, so each run's path may differ. For a stable regression suite, the official docs recommend something else; steps that pass can be saved as .ad replay scripts for CI, or exported as Maestro YAML. The two are complementary.

Wrap-up

If you're having AI agents write your apps every day, this tool is worth installing and trying, because it saves you the back-and-forth of installing and clicking through the UI.

Even if you don't install it, the idea is worth borrowing. A device tool for an agent that reads the app's real state beats one that just takes screenshots; accessibility snapshots save tokens and click accurately, and any team building its own tooling can copy this design.

The details of leaving evidence in the PR for human review, and managing device occupancy when multiple agents run in parallel, are both useful when building a testing platform.

GitHub project address:

https://github.com/callstack/agent-device
Comments

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

鱼翅x

Tried it, feels very slow.