DEV Community

Deduped
Deduped

Posted on

Give Claude Code a browser with the agent-browser CLI

Browser automation for coding agents usually means a heavy Playwright setup and a lot of tokens spent on page dumps. vercel-labs/agent-browser is a native Rust CLI that gives an agent short commands instead. Here is the install and the loop from its README.

Install

The README recommends a global install, which pulls the native binary:

npm install -g agent-browser
agent-browser install  # Download Chrome from Chrome for Testing (first time only)
Enter fullscreen mode Exit fullscreen mode

On macOS you can use brew install agent-browser, and there is a Cargo option too. On Linux, add system libraries with agent-browser install --with-deps. To pin a version per project, use npm install agent-browser and then agent-browser install. Upgrade later with agent-browser upgrade.

The snapshot and ref loop

The core idea is that the agent reads an accessibility tree with short refs, then acts on a ref instead of writing a selector:

agent-browser open example.com
agent-browser snapshot                    # Get accessibility tree with refs
agent-browser click @e2                   # Click by ref from snapshot
agent-browser fill @e3 "test@example.com" # Fill by ref
agent-browser get text @e1                # Get text by ref
agent-browser screenshot page.png
agent-browser close
Enter fullscreen mode Exit fullscreen mode

Traditional selectors still work when you want them, for example agent-browser click "#submit" or agent-browser find role button click --name "Submit".

Why it suits Claude Code, Codex and similar agents

Each command is one shell call, so any agent that can run a terminal can drive a browser with no MCP server to register. The README also notes that clicks fail early when another element covers the target, such as a consent banner. Dismiss the covering element, then take a fresh snapshot before retrying.

To keep screenshots cheap, the README recommends:

agent-browser screenshot --if-changed
Enter fullscreen mode Exit fullscreen mode

That skips an image when the page has not visibly changed, so an agent polling a page does not pay for the same picture twice.

Skills that match your installed version

The CLI serves its own instructions for agents:

agent-browser skills list
agent-browser skills get <name>
Enter fullscreen mode Exit fullscreen mode

The README says this content always matches the installed CLI version, which avoids stale cached copies in your agent setup.

Things to check

  • The browser is Chrome for Testing, downloaded on first install. Existing Chrome, Brave, Playwright and Puppeteer installs are detected automatically.
  • Building from source needs Node.js 24+, pnpm 11+ and Rust. A normal install does not.
  • WebMCP support is experimental, and page-provided tool descriptions are untrusted data. Do not let an agent follow instructions found in page content.

What we did not verify

We followed the README and did not run these commands on a fresh machine for this post. Flags change between releases, so check agent-browser --help after installing.

Our step-by-step is on the let your agent browse with short CLI commands page, and the repo overview is here.

Want the setup commands for 50 AI repos people actually ship with? Get the free AI Repos That Actually Ship pack: https://dedupedai.com/ship-pack/?utm_source=devto&utm_medium=article&utm_campaign=shippack

Top comments (0)