| name | agent-browser |
| description | A fast Rust-based headless browser automation CLI with Node.js fallback that enables AI agents to navigate, click, type, and snapshot pages via structured commands. Is a better choice for AI agent workflows - compact snapshots save tokens, the auth vault handles credentials securely, and React DevTools integration is valuable for frontend debugging. |
| read_when | ["Automating web interactions","Extracting structured data from pages","Filling forms programmatically","Testing web UIs","Debugging React applications","Measuring Core Web Vitals","Managing browser auth state"] |
| metadata | {"clawdbot":{"emoji":"๐","requires":{"bins":["node","npm"]}}} |
| allowed-tools | Bash(agent-browser:*) |
Browser Automation with agent-browser
Version: 0.29.1 (Rust-based CLI with Node.js fallback)
Installation
npm (recommended)
npm install -g agent-browser
agent-browser install
agent-browser install --with-deps
Homebrew
brew install agent-browser
Cargo
cargo install agent-browser
From Source
git clone https://github.com/vercel-labs/agent-browser
cd agent-browser
pnpm install
pnpm build
agent-browser install
Maintenance
agent-browser upgrade
agent-browser doctor
agent-browser doctor --fix
agent-browser profiles
Quick start
agent-browser open <url>
agent-browser snapshot -i
agent-browser click @e1
agent-browser fill @e2 "text"
agent-browser close
Core workflow
- Navigate:
agent-browser open <url>
- Snapshot:
agent-browser snapshot -i (returns elements with refs like @e1, @e2)
- Interact using refs from the snapshot
- Re-snapshot after navigation or significant DOM changes
Commands
Navigation
agent-browser open <url>
agent-browser back
agent-browser forward
agent-browser reload
agent-browser close [--all]
SPA / Client-side Navigation
For single-page applications (Next.js, React Router, etc.) where open would trigger a full page reload:
agent-browser pushstate <url>
pushstate auto-detects window.next.router.push (triggers RSC fetch on Next.js) and falls back to history.pushState + popstate/navigate events for other frameworks.
Snapshot (page analysis)
agent-browser snapshot
agent-browser snapshot -i
agent-browser snapshot -c
agent-browser snapshot -d 3
agent-browser snapshot -s "#main"
Snapshot options:
| Flag | Description |
|---|
-i, --interactive | Only interactive elements |
-c, --compact | Remove empty structural elements |
-d, --depth <n> | Limit tree depth |
-s, --selector <sel> | Scope to CSS selector |
Interactions (use @refs from snapshot)
agent-browser click @e1
agent-browser dblclick @e1
agent-browser focus @e1
agent-browser fill @e2 "text"
agent-browser type @e2 "text"
agent-browser press Enter
agent-browser press Control+a
agent-browser keyboard type <text>
agent-browser keyboard inserttext <text>
agent-browser hover @e1
agent-browser check @e1
agent-browser uncheck @e1
agent-browser select @e1 "value"
agent-browser scroll <dir> [px]
agent-browser scrollintoview @e1
agent-browser drag @e1 @e2
agent-browser upload @e1 file.pdf
agent-browser download @e1 <path>
Get information
agent-browser get text @e1
agent-browser get html @e1
agent-browser get value @e1
agent-browser get attr @e1 href
agent-browser get title
agent-browser get url
agent-browser get count ".item"
agent-browser get box @e1
agent-browser get styles @e1
agent-browser get cdp-url
Check state
agent-browser is visible @e1
agent-browser is enabled @e1
agent-browser is checked @e1
Find elements (semantic locators, alternative to refs)
agent-browser find role button click --name "Submit"
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find placeholder "Search" fill "query"
agent-browser find alt "Logo" click
agent-browser find title "Tooltip" hover
agent-browser find testid "submit-btn" click
agent-browser find first ".item" click
agent-browser find last ".item" click
agent-browser find nth 2 "a" text
Screenshots & PDF
agent-browser screenshot
agent-browser screenshot path.png
agent-browser screenshot --full
agent-browser screenshot --annotate
agent-browser pdf output.pdf
Video recording
agent-browser record start <path> [url]
agent-browser record stop
Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it automatically returns to your current page. For smooth demos, explore first, then start recording.
Wait
agent-browser wait @e1
agent-browser wait 2000
agent-browser wait --text "Success"
agent-browser wait --url "/dashboard"
agent-browser wait --load networkidle
agent-browser wait --fn "window.ready"
Mouse control
agent-browser mouse move <x> <y>
agent-browser mouse down [btn]
agent-browser mouse up [btn]
agent-browser mouse wheel <dy> [dx]
Browser settings
agent-browser set viewport <w> <h>
agent-browser set device <name>
agent-browser set geo <lat> <lng>
agent-browser set offline [on|off]
agent-browser set headers '<json>'
agent-browser set credentials <user> <pass>
agent-browser set media [dark|light] [reduced-motion]
Cookies & Storage
agent-browser cookies
agent-browser cookies set <name> <value>
agent-browser cookies set <name> <value> --url <u> --domain <d> --path <p>
agent-browser cookies set <name> <value> --httpOnly --secure --sameSite strict --expires <unix>
agent-browser cookies set --curl <file> [--domain <host>]
agent-browser cookies clear
agent-browser storage local
agent-browser storage local key
agent-browser storage local set <k> <v>
agent-browser storage local clear
agent-browser storage session
Network
agent-browser network route <url>
agent-browser network route <url> --abort
agent-browser network route <url> --body '<json>'
agent-browser network route <url> --resource-type <csv>
agent-browser network unroute [url]
agent-browser network requests
agent-browser network requests --filter <pattern>
agent-browser network requests --clear
agent-browser network har start [path]
agent-browser network har stop [path]
Tabs
agent-browser tab
agent-browser tab new [url]
agent-browser tab <n>
agent-browser tab close
JavaScript
agent-browser eval "<js>"
Clipboard
agent-browser clipboard read
agent-browser clipboard write <text>
agent-browser clipboard copy
agent-browser clipboard paste
State management
agent-browser state save <path>
agent-browser state load <path>
State files can be encrypted with AGENT_BROWSER_ENCRYPTION_KEY (64-char hex AES-256-GCM key).
Auth Vault
Securely store and replay credentials. Never pass passwords as CLI arguments โ use the vault.
agent-browser auth save <name> --url <login-url> --username <user>
agent-browser auth save <name> --url <login-url> --username <user> --password <pass>
agent-browser auth save <name> --url <login-url> --username <user> --password-stdin
agent-browser auth login <name>
agent-browser auth login <name> --username-selector "#email" --password-selector "#pass"
agent-browser auth login <name> --credential-provider <plugin> [--item <ref>] [--url <url>]
agent-browser auth list
agent-browser auth show <name>
agent-browser auth delete <name>
React DevTools Integration
Requires opening with --enable react-devtools:
agent-browser open <url> --enable react-devtools
agent-browser react tree
agent-browser react inspect <id>
agent-browser react renders start
agent-browser react renders stop [--json]
agent-browser react suspense [--only-dynamic] [--json]
Performance (Core Web Vitals)
agent-browser vitals [url] [--json]
Returns metrics with letter grades. --json returns full data for programmatic use.
Streaming (WebSocket)
Stream browser events to external consumers in real-time:
agent-browser stream enable [--port <n>]
agent-browser stream disable
agent-browser stream status
MCP Server Mode
Expose agent-browser as an MCP (Model Context Protocol) tool server via stdio:
agent-browser mcp
Dashboard (Observability)
Start the web-based observability dashboard:
agent-browser dashboard [start]
agent-browser dashboard start --port <n>
agent-browser dashboard stop
Plugins
agent-browser plugin add <ref>
agent-browser plugin [list]
agent-browser plugin show <name>
agent-browser plugin run <name> <type>
Diff (Page Comparison)
agent-browser diff snapshot
agent-browser diff screenshot --baseline <path>
agent-browser diff url <u1> <u2>
Sessions (parallel browsers)
agent-browser --session <name> open site-a.com
agent-browser --session <name> open site-b.com
agent-browser session list
agent-browser session
Session persistence (auto-save/restore state)
agent-browser --session-name myapp open example.com
State auto-saves on close and restores on next open with the same name. Controlled by AGENT_BROWSER_STATE_EXPIRE_DAYS (default: 30).
Confirmation (Action Policy)
Require explicit approval for sensitive actions:
agent-browser confirm <id>
agent-browser deny <id>
Configure categories requiring confirmation:
agent-browser --confirm-actions "navigate,download,upload" open example.com
agent-browser --confirm-interactive open example.com
Load policy from file:
agent-browser --action-policy policy.json open example.com
Batch execution
Execute multiple commands sequentially in a single call:
agent-browser batch ["cmd1" "cmd2" "cmd3"]
agent-browser batch --bail ["cmd1" "cmd2"]
echo 'open example.com\nsnapshot -i' | agent-browser batch
Init scripts
Register JavaScript that runs before first navigation:
agent-browser --init-script ./setup.js open example.com
agent-browser removeinitscript <id>
Multiple scripts via AGENT_BROWSER_INIT_SCRIPTS env (comma-separated).
JSON output (for parsing)
Add --json for machine-readable output:
agent-browser snapshot -i --json
agent-browser get text @e1 --json
agent-browser vitals --json
Debugging
agent-browser open example.com --headed
agent-browser console
agent-browser console --clear
agent-browser errors
agent-browser errors --clear
agent-browser highlight @e1
agent-browser inspect
agent-browser trace start
agent-browser trace stop [path]
agent-browser profiler start
agent-browser profiler stop [path]
agent-browser record start <path> [url]
agent-browser record stop
agent-browser --cdp 9222 snapshot
agent-browser --auto-connect snapshot
Chat (AI-driven)
Send natural language instructions to an AI model that controls the browser:
agent-browser chat "open google.com and search for cats"
agent-browser chat
agent-browser chat --model <name> "summarize this page"
agent-browser -q chat "click the login button"
Requires AI_GATEWAY_API_KEY or equivalent model provider credentials.
Examples
Form submission
agent-browser open https://example.com/form
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "password123"
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i
Authentication with saved state
agent-browser open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "username"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser wait --url "/dashboard"
agent-browser state save auth.json
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard
Authentication with vault (recommended)
agent-browser auth save myapp --url https://app.example.com/login --username user
agent-browser auth login myapp
agent-browser wait --url "/dashboard"
Next.js SPA navigation
agent-browser open http://localhost:3000/
agent-browser snapshot -i
agent-browser click @e5
agent-browser pushstate http://localhost:3000/dashboard
agent-browser wait --load networkidle
agent-browser snapshot -i
React debugging
agent-browser open http://localhost:3000/ --enable react-devtools
agent-browser react tree
agent-browser react inspect 42
agent-browser react renders start
agent-browser react renders stop
agent-browser react suspense --only-dynamic
Performance audit
agent-browser open https://example.com
agent-browser vitals --json
Parallel sessions
agent-browser --session test1 open site-a.com
agent-browser --session test2 open site-b.com
agent-browser --session test1 snapshot -i
agent-browser --session test2 snapshot -i
agent-browser session list
Connect to running Chrome
agent-browser --auto-connect snapshot
agent-browser --cdp 9222 snapshot
agent-browser --auto-connect state save ./auth.json
Full Options Reference
Session & Browser
| Flag | Description |
|---|
--session <name> | Isolated session (or AGENT_BROWSER_SESSION) |
--session-name <name> | Auto-save/restore state persistence name (or AGENT_BROWSER_SESSION_NAME) |
--profile <name|path> | Chrome profile to reuse login state, or custom profile directory (or AGENT_BROWSER_PROFILE) |
--state <path> | Load saved auth state from JSON file (or AGENT_BROWSER_STATE) |
--auto-connect | Connect to running Chrome to reuse auth state |
--headed | Show browser window, not headless (or AGENT_BROWSER_HEADED) |
--executable-path <path> | Custom browser executable (or AGENT_BROWSER_EXECUTABLE_PATH) |
--engine <name> | Browser engine: chrome (default), lightpanda (or AGENT_BROWSER_ENGINE) |
--cdp <port> | Connect via CDP port |
Network & Security
| Flag | Description |
|---|
--proxy <server> | Proxy server URL. Supports auth: http://user:pass@host:port (or AGENT_BROWSER_PROXY, HTTP_PROXY, HTTPS_PROXY, ALL_PROXY) |
--proxy-bypass <hosts> | Bypass proxy for hosts (or AGENT_BROWSER_PROXY_BYPASS, NO_PROXY) |
--ignore-https-errors | Ignore HTTPS certificate errors |
--headers <json> | HTTP headers scoped to URL's origin |
--allow-file-access | Allow file:// URLs to access local files (Chromium only) |
Appearance & Media
| Flag | Description |
|---|
--color-scheme <scheme> | dark, light, no-preference (or AGENT_BROWSER_COLOR_SCHEME) |
--hide-scrollbars <bool> | Hide native scrollbars in headless screenshots (default: true) |
Output Control
| Flag | Description |
|---|
--json | JSON output (or AGENT_BROWSER_JSON) |
--annotate | Annotated screenshot with numbered labels (or AGENT_BROWSER_ANNOTATE) |
--content-boundaries | Wrap page output in boundary markers (or AGENT_BROWSER_CONTENT_BOUNDARIES) |
--max-output <chars> | Truncate page output to N chars (or AGENT_BROWSER_MAX_OUTPUT) |
--debug | Debug output (or AGENT_BROWSER_DEBUG) |
Screenshot Options
| Flag | Description |
|---|
--screenshot-dir <path> | Default screenshot directory (or AGENT_BROWSER_SCREENSHOT_DIR) |
--screenshot-quality <n> | JPEG quality 0-100 (or AGENT_BROWSER_SCREENSHOT_QUALITY) |
--screenshot-format <fmt> | png, jpeg (or AGENT_BROWSER_SCREENSHOT_FORMAT) |
Extensions & Scripts
| Flag | Description |
|---|
--extension <path> | Load browser extension (repeatable) |
--init-script <path> | Register page init script before first navigation (repeatable) |
--enable <feature> | Built-in init scripts: react-devtools (repeatable or comma-separated) |
--args <args> | Browser launch args, comma/newline separated (or AGENT_BROWSER_ARGS) |
Safety & Policy
| Flag | Description |
|---|
--allowed-domains <list> | Restrict navigation domains (or AGENT_BROWSER_ALLOWED_DOMAINS) |
--action-policy <path> | Action policy JSON file (or AGENT_BROWSER_ACTION_POLICY) |
--confirm-actions <list> | Categories requiring confirmation (or AGENT_BROWSER_CONFIRM_ACTIONS) |
--confirm-interactive | Interactive confirmation prompts; auto-denies if non-TTY (or AGENT_BROWSER_CONFIRM_INTERACTIVE) |
--no-auto-dialog | Disable automatic dismissal of alert/beforeunload dialogs (or AGENT_BROWSER_NO_AUTO_DIALOG) |
Miscellaneous
| Flag | Description |
|---|
--user-agent <ua> | Custom User-Agent (or AGENT_BROWSER_USER_AGENT) |
--download-path <path> | Default download directory (or AGENT_BROWSER_DOWNLOAD_PATH) |
--model <name> | AI model for chat (or AI_GATEWAY_MODEL) |
-v, --verbose | Show tool commands and raw output |
-q, --quiet | Show only AI text responses (hide tool calls) |
--config <path> | Custom config file (or AGENT_BROWSER_CONFIG) |
--version, -V | Show version |
Provider Options
| Flag | Description |
|---|
-p, --provider <name> | Browser provider: ios, browserbase, kernel, browseruse, browserless, agentcore, or plugin name |
--device <name> | iOS device name (e.g., "iPhone 15 Pro") |
Environment Variables
| Variable | Description |
|---|
AGENT_BROWSER_CONFIG | Path to config file |
AGENT_BROWSER_SESSION | Session name (default: "default") |
AGENT_BROWSER_SESSION_NAME | Auto-save/restore state persistence name |
AGENT_BROWSER_ENCRYPTION_KEY | 64-char hex key for AES-256-GCM state encryption |
AGENT_BROWSER_STATE_EXPIRE_DAYS | Auto-delete states older than N days (default: 30) |
AGENT_BROWSER_EXECUTABLE_PATH | Custom browser executable path |
AGENT_BROWSER_EXTENSIONS | Comma-separated browser extension paths |
AGENT_BROWSER_INIT_SCRIPTS | Comma-separated page init script paths |
AGENT_BROWSER_ENABLE | Comma-separated built-in init script features |
AGENT_BROWSER_HEADED | Show browser window (not headless) |
AGENT_BROWSER_JSON | JSON output |
AGENT_BROWSER_ANNOTATE | Annotated screenshot with numbered labels |
AGENT_BROWSER_DEBUG | Debug output |
AGENT_BROWSER_IGNORE_HTTPS_ERRORS | Ignore HTTPS certificate errors |
AGENT_BROWSER_PROVIDER | Browser provider |
AGENT_BROWSER_AUTO_CONNECT | Auto-discover and connect to running Chrome |
AGENT_BROWSER_ALLOW_FILE_ACCESS | Allow file:// URLs to access local files |
AGENT_BROWSER_HIDE_SCROLLBARS | Hide scrollbars in headless screenshots (default: true) |
AGENT_BROWSER_COLOR_SCHEME | Color scheme preference |
AGENT_BROWSER_DOWNLOAD_PATH | Default download directory |
AGENT_BROWSER_DEFAULT_TIMEOUT | Default action timeout in ms (default: 25000) |
AGENT_BROWSER_STREAM_PORT | Override WebSocket streaming port (default: OS-assigned) |
AGENT_BROWSER_IDLE_TIMEOUT_MS | Auto-shutdown daemon after N ms of inactivity (disabled by default) |
AGENT_BROWSER_IOS_DEVICE | Default iOS device name |
AGENT_BROWSER_IOS_UDID | Default iOS device UDID |
AGENT_BROWSER_CONTENT_BOUNDARIES | Wrap page output in boundary markers |
AGENT_BROWSER_MAX_OUTPUT | Max characters for page output |
AGENT_BROWSER_ALLOWED_DOMAINS | Comma-separated allowed domain patterns |
AGENT_BROWSER_ACTION_POLICY | Path to action policy JSON file |
AGENT_BROWSER_CONFIRM_ACTIONS | Action categories requiring confirmation |
AGENT_BROWSER_CONFIRM_INTERACTIVE | Enable interactive confirmation prompts |
AGENT_BROWSER_NO_AUTO_DIALOG | Disable automatic dismissal of dialogs |
AGENT_BROWSER_ENGINE | Browser engine: chrome (default), lightpanda |
AGENT_BROWSER_PLUGINS | JSON plugin registry override |
AGENT_BROWSER_SCREENSHOT_DIR | Default screenshot output directory |
AGENT_BROWSER_SCREENSHOT_QUALITY | JPEG quality 0-100 |
AGENT_BROWSER_SCREENSHOT_FORMAT | Screenshot format: png, jpeg |
AGENT_BROWSER_PROXY | Proxy server URL |
AGENT_BROWSER_PROXY_BYPASS | Bypass proxy for hosts |
HTTP_PROXY / HTTPS_PROXY | Standard proxy env vars (fallback) |
ALL_PROXY | SOCKS proxy (fallback) |
NO_PROXY | Bypass proxy for hosts (fallback) |
AI_GATEWAY_URL | Vercel AI Gateway base URL (default: https://ai-gateway.vercel.sh) |
AI_GATEWAY_API_KEY | API key for AI Gateway (enables chat + dashboard AI) |
AI_GATEWAY_MODEL | Default AI model (default: anthropic/claude-sonnet-4.6) |
Configuration File
agent-browser looks for agent-browser.json in these locations (lowest to highest priority):
~/.agent-browser/config.json โ User-level defaults
./agent-browser.json โ Project-level overrides
- Environment variables โ Override config file values
- CLI flags โ Override everything
Use --config <path> to load a specific config file. Boolean flags accept true/false to override config:
--headed false
--hide-scrollbars false
Example agent-browser.json:
{
"headed": true,
"hideScrollbars": false,
"proxy": "http://localhost:8080"
}
Plugin config example:
{
"plugins": [
{ "name": "vault", "command": "agent-browser-plugin-vault", "capabilities": ["credential.read"] },
{ "name": "stealth", "command": "agent-browser-plugin-stealth", "capabilities": ["launch.mutate"] }
]
}
Extensions from user and project configs are merged (not replaced).
iOS Simulator (requires Xcode + Appium)
agent-browser -p ios open example.com
agent-browser -p ios --device "iPhone 15 Pro" open url
agent-browser -p ios device list
agent-browser -p ios swipe up
agent-browser -p ios tap @e1
Troubleshooting
| Issue | Solution |
|---|
| Command not found on Linux ARM64 | Use full path in the bin folder |
| Element not found | Use snapshot to find the correct ref |
| Page not loaded | Add wait --load network idle after navigation |
| Need to see the browser | Use --headed to show the window |
| Auth state lost between runs | Use --session-name or state save/load |
| Stale install | Run agent-browser doctor --fix |
| Need latest version | Run agent-browser upgrade |
| Cross-origin blocked in dev | Add origin to allowedDevOrigins in next.config.ts |
| HTTPS certificate errors | Use --ignore-https-errors |
Notes
- Refs are stable per page load but change on navigation.
- Always snapshot after navigation to get new refs.
- Use
fill instead of type for input fields to ensure existing text is cleared.
keyboard type bypasses the selector system entirely โ useful for non-input elements.
pushstate is preferred over open for SPA routes to avoid full page reloads.
- State files auto-expire after
AGENT_BROWSER_STATE_EXPIRE_DAYS (default: 30).
- Boolean flags accept optional
true/false to override config file values.
Reporting Issues