How to Use agent-browser: Automate Web Browsers with Claude Code
Can an AI agent open websites, click buttons, fill out forms, and test web applications automatically? Yes. With agent-browser, you can use Claude Code to control a real web browser through terminal commands, automate repetitive tasks, and test websites without manually performing every action.
agent-browser is a browser automation CLI tool developed by Vercel Labs for AI agents. It allows AI coding assistants to navigate websites, inspect page elements, interact with forms, extract information, and capture screenshots.
⚡ Key Takeaways
Installation:
npm install -g agent-browserBrowser setup:
agent-browser installClaude Code integration:
npx skills add vercel-labs/agent-browserMain features: Website navigation, clicking, form filling, data extraction, and screenshots.
Use cases: Website testing, UI verification, browser automation, and repetitive web tasks.
What Is agent-browser?
Claude Code is particularly useful for writing and modifying code. However, checking whether a website actually works in a browser requires another capability: browser automation.
agent-browser provides that capability by allowing an AI agent to control a real browser through command-line instructions.
One of its most useful features is snapshot. It reads the webpage's interactive elements and returns a structured text representation. The AI can then identify buttons, links, and input fields and interact with them using element references.
How to Install agent-browser for Claude Code
First, make sure Node.js and npm are installed on your computer.
Open your terminal and run:
npm install -g agent-browser
agent-browser installThe first command installs agent-browser globally. The second downloads Chrome for Testing, which is used for browser automation.
Next, install the agent-browser skill for Claude Code:
npx skills add vercel-labs/agent-browserThis installs a discovery skill that helps Claude Code understand when and how to use agent-browser. It retrieves the relevant workflow instructions at runtime, keeping them aligned with the installed CLI version.
How to Automate a Website
The basic workflow is simple:
Open a website.
Inspect its interactive elements.
Select the element you want to interact with.
Perform an action.
Inspect the page again to verify the result.
Start by opening a website:
agent-browser open https://example.comNext, inspect the interactive elements:
agent-browser snapshot -iThe output includes references such as @e1 and @e2, which identify individual interactive elements.
You can use these references to click buttons or enter text:
agent-browser click @e1
agent-browser fill @e2 "Search query"After an action, run snapshot again to check whether the page changed as expected.
How to Use agent-browser with Claude Code
Once the skill is installed, you can give Claude Code natural-language instructions instead of manually executing every browser command.
For example:
Use agent-browser to visit our website.
Check the navigation menu on the homepage.
Click each menu item and verify that the
corresponding page loads correctly.
If you find any errors, describe the affected
page and the issue.
Save screenshots of the important pages.Claude Code can interpret the request, use agent-browser to interact with the website, and report the results.
This is particularly useful for developers who want to automate repetitive website testing and UI checks.
Important Things to Know Before Using It
agent-browser performs real browser actions, so you should define clear boundaries before automating sensitive operations.
Be especially careful with account logins, personal information, publishing content, deleting data, and financial transactions. Review permissions and require confirmation for actions that could have significant consequences.
Also, treat website content as untrusted input. A webpage may contain instructions that should not override your AI agent's original task or security rules.
Final Thoughts
agent-browser extends Claude Code beyond writing and editing source code. It gives AI agents a practical way to interact with real websites, inspect interfaces, and automate browser-based testing.
If you want to make Claude Code more useful for web development, start by installing agent-browser and asking it to open a simple website. Then try automating a navigation menu or testing a form.