agent-browser: Let Claude Code Drive a Browser with Fewer Tokens
Vercel's agent-browser lets Claude Code and Codex click by reference. Setup, usage, and token costs for reading and interacting with pages.

When you build a website with an AI coding agent like Claude Code or Codex, you often need it to actually look at the page: does the button respond when clicked, does the language menu switch, does the form submit? For research, the built-in web fetch is enough. But to click, fill in forms and move between pages, the agent needs to drive a real browser.
agent-browser is a tool built for exactly that. I installed it on my own machine and tested it on an article page from this blog: how many tokens the agent spends reading a page and operating it, and whether that beats the alternatives.
What is agent-browser?
agent-browser is an open-source browser automation tool from Vercel, officially described as a "browser automation CLI for AI agents". It's a command-line program: each command the agent runs performs one action, and the browser stays open between commands. Details below were checked on 2026-11-22:
Item | Details |
|---|---|
Developer | Vercel (GitHub account vercel-labs) |
License | Apache-2.0, free, commercial use allowed |
Form | Command-line program (CLI), can also run as an MCP server |
Platforms | macOS, Linux, Windows |
Browser | Downloads Chrome for Testing by default, can also connect to the Chrome you already have open |
Supported agents | Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, Windsurf and more |
Its core idea is a snapshot plus reference numbers: it turns the page into a compact text list in which every button, link and input gets a number, such as @e1. After reading the list, the agent simply says "click @e1" instead of guessing coordinates from a screenshot.
How to install agent-browser
You need Node.js. Install it globally with npm, then download its dedicated Chrome (first time only):
npm install -g agent-browser
agent-browser installOn Linux, if you get errors about missing shared libraries, use agent-browser install --with-deps instead, which also installs the system packages the browser needs. On macOS you can also use brew install agent-browser; if you'd rather not install anything, npx agent-browser open example.com runs it directly.
Install the agent-browser skill (works for Claude Code and Codex)
Once it's installed, teach your agent how to use it:
npx skills add vercel-labs/agent-browserThis adds a skill to Claude Code, Codex and similar tools. The skill is only an entry point: the agent reads the full usage guide itself by running agent-browser skills get core, so the instructions always match the version you have installed. The docs specifically warn against copying SKILL.md out of node_modules. In my test, the guide was about 4,600 tokens, and the agent reads it once the first time it uses the tool.
To update later, run agent-browser upgrade; if something goes wrong, agent-browser doctor checks your setup.
Using agent-browser: snapshots and @refs
The most basic flow is: open a page, take a snapshot, click an element, confirm the result, close the browser.
agent-browser open https://terryl.in/en/blog/free-commercial-fonts
agent-browser snapshot -i
agent-browser select @e9 日本語
agent-browser get url
agent-browser closesnapshot -i lists only the elements you can interact with. Here's the beginning of what my article page returned:
- link "Skip to main content" [ref=e1]
- link "Visit the moon studio ↗" [ref=e2]
- combobox "Choose language" [expanded=false, ref=e9]: English
- option "English" [selected, ref=e66]
- option "日本語" [ref=e68]
- navigation "Sections" [ref=e4]
- link "Latest" [ref=e10]
- link "AI tools" [ref=e11]The language menu is @e9, so select @e9 日本語 switches to Japanese in one step. Then get url returns https://terryl.in/ja/blog/free-commercial-fonts, confirming the switch worked.
Common commands:
Command | Purpose |
|---|---|
| Open a page |
| List only interactive elements (officially recommended) |
| List the whole page, minus empty structure |
| Click, fill in, select |
| Turn the current page into AI-friendly text |
| Get an element's text, the current URL |
| Take a screenshot |
| Close the browser |
Refs stop working once the page changes. After navigating or a major change on screen, run snapshot again. If an element is covered, disabled or off screen, the click reports an error right away instead of pretending it succeeded.
Test: how many tokens does reading or operating a page use?
I compared the different approaches on the Chinese version of one of my blog posts, Free Fonts for Commercial Use. Token counts are estimated from character counts (roughly one token per Chinese character), so treat them as orders of magnitude:
Approach | What the agent receives | Approx. tokens |
|---|---|---|
Fetch the raw page source | The full HTML source | 168,000 |
agent-browser | The full page accessibility tree | 9,300 |
agent-browser | The article text | 4,500 |
agent-browser | Interactive elements only | 2,100 |
One 1280×577 screenshot | An image | 1,000 |
Claude Code's built-in WebFetch | Just the answer (12 fonts and their licenses) | 200 |
The table shows two things.
For reading, agent-browser doesn't save anything. Claude Code's WebFetch first hands the whole page to another model to process, and the agent only gets the answer to its question, about 200 tokens. agent-browser's read hands the entire article to the agent, roughly twenty times more. For looking things up in docs or reading a GitHub README, stick with the built-in web fetch.
For operating a page, agent-browser is very economical. Each look at the page with snapshot -i costs about 2,100 tokens, and the next step clicks directly by ref. A single screenshot is only about 1,000 tokens, but the agent sees nothing but pixels: it has to work out which coordinates to click from the image, and a misclick is hard to notice. snapshot -i gives the element's type, name and state directly (for example, that the menu currently shows "English"), so clicks are more accurate too.
When should you use agent-browser?
Good fits:
- Checking your own site: after publishing, actually open the page and check the language switcher, collapsible sections and audio player, and use the
consoleanderrorscommands to look for JavaScript errors. - Testing front-end flows: run through sign-up, forms or checkout on your local dev server and make sure nothing is broken before a human looks at it.
- Admin panels behind a login: for tasks with no API, or that an MCP server can't handle, it can click around with your login state (see the next section).
- Pages that only have content after JavaScript runs: a plain web fetch gets an empty shell, while agent-browser waits for the page to actually finish loading.
Poor fits:
- Research, reading docs, catching up on news. The agent's built-in search and web fetch use far fewer tokens.
Using your own Chrome login: --profile and --auto-connect
By default agent-browser opens a clean Chrome with no logins. To work on sites that need you to be signed in, there are three ways:
- Borrow your Chrome profile:
agent-browser --profile Default open https://gmail.com. It copies the profile to a temporary folder and uses that, so your original profile is left untouched. - Connect to the Chrome you have open: start Chrome with
--remote-debugging-port=9222, then runagent-browser connect 9222; or use--auto-connectto let it find the browser on its own. From Chrome 144 on, a permission prompt appears when it connects. - Save the login state:
agent-browser state save ./auth.jsonsaves the cookies, and--state ./auth.jsonloads them later.
Two things to watch out for:
- The docs state plainly that once
--remote-debugging-portis on, any program on your machine can fully control that browser. Remember to close it when you're done. - The saved login state file is plain text and contains your login tokens. You can set the
AGENT_BROWSER_ENCRYPTION_KEYenvironment variable to encrypt it. Keep the file out of git.
Security settings: limit where the agent can go and what it can do
The docs are blunt about it: by default agent-browser places no limits on URLs, actions or output. When you let an agent drive the browser on its own, you can add these settings:
Setting | Effect |
|---|---|
| Only these domains can be opened |
| Block certain actions, e.g. |
| These actions run only after you approve them with |
| Usernames and passwords are kept in an encrypted vault; the docs say passwords never enter the AI's context |
The domain restriction can't be combined with --cdp, --auto-connect, --profile or other options that connect to your own browser. The docs also note that the domain restriction is not an OS-level firewall and shouldn't be your only line of defense.
agent-browser vs Claude in Chrome vs Playwright MCP
All three let an AI drive a browser. The differences are who makes them, how they plug in and which browser they use. Details below were checked on 2026-11-22:
Item | agent-browser | Claude in Chrome | Playwright MCP |
|---|---|---|---|
Developer | Vercel | Anthropic | Microsoft's Playwright team |
Form | Command-line program (also works as MCP) | Chrome extension | MCP server |
Cost | Free, open source | Requires a paid Claude plan (Pro, Max, Ultra, Team, Enterprise) | Free, open source |
Works with | Claude Code, Codex, Cursor and more | Claude (side panel, Cowork, Claude Code) | Agents that support MCP |
Browser | Opens a separate clean Chrome by default, can connect to yours | The Chrome you use every day, with your existing logins | A browser controlled by Playwright |
How it sees the page | Text snapshot with refs | Screenshots, and can also read page text, the DOM and the console | Text snapshot |
Claude in Chrome is Anthropic's official extension. Start it in Claude Code with claude --chrome and it opens new tabs in your Chrome to work in. It can see the sites you're already signed in to, and it stops and asks you to take over when it hits a login page or a CAPTCHA. It has built-in safety checks: every action is checked before it runs, it never does things like purchases, payments or creating accounts, and it asks you before downloading files or entering sensitive information.
agent-browser isn't tied to any particular AI service, so Codex and Cursor can use it too, and by default it opens a separate clean browser that never touches your everyday accounts. When you need to be signed in, bring the login state with --profile or --auto-connect.
How to choose:
- If you're on a paid Claude plan and want to work on sites you're already signed in to (admin panels, email), Claude in Chrome is the least hassle, and its safety checks are more thorough.
- If you use Codex or another agent, or want to test your own site in a clean environment, use agent-browser.
- If your workflow already runs on MCP, consider Playwright MCP.
FAQ
What is agent-browser? Is it free?
An open-source browser automation CLI from Vercel, built for AI agents like Claude Code and Codex. It turns a web page into a compact numbered list, and the agent clicks, fills in forms and switches pages by number. It's free under the Apache-2.0 license, and commercial use is allowed.
How do I install the agent-browser skill?
First install the program with npm install -g agent-browser and agent-browser install, then run npx skills add vercel-labs/agent-browser. It works with Claude Code, Codex, Cursor and others, and the agent reads the full usage guide itself with agent-browser skills get core.
Does agent-browser support Windows?
Yes. There are official builds for macOS, Linux and Windows, and npm install -g agent-browser picks the right one automatically.
Can agent-browser use accounts I'm already logged in to?
Yes. Use --profile Default to borrow your Chrome profile, or --auto-connect to connect to the Chrome you have open. The saved login state file is plain text, so keep it safe.
Does agent-browser save tokens when reading web pages?
No. For plain reading, Claude Code's built-in WebFetch returns only a processed answer, which is far cheaper than agent-browser reading the whole article. Where agent-browser saves tokens is operating a page: looking at it with snapshot -i at each step is cheaper and more accurate than taking a screenshot at every step.
agent-browser or Claude in Chrome: which is better?
It depends on your agent. Claude in Chrome is Anthropic's extension: it needs a paid Claude plan, works directly in your everyday Chrome with your existing logins, and has built-in safety checks. agent-browser is free and open source, works with Codex and other agents too, and opens a separate clean browser by default, which makes it a good fit for testing websites.
Wrap-up: WebFetch for reading, agent-browser for operating pages
Since installing agent-browser, I've kept the division of tasks simple: for research and reading docs I still use the agent's built-in web fetch, and agent-browser only comes in when something needs clicking, filling in or checking on a page. The agent no longer has to guess coordinates from screenshots; it operates the page precisely by ref.
If you want to know how I develop with Claude Code, see Claude Code vs Codex Pricing. If you've built some fun automation with agent-browser too, tell me about it on Threads or X.
