# Table of Contents - [agent-browser | Browser Automation for AI](#agent-browser-browser-automation-for-ai) - [Installation | agent-browser](#installation-agent-browser) - [Skills | agent-browser](#skills-agent-browser) - [Selectors | agent-browser](#selectors-agent-browser) - [Configuration | agent-browser](#configuration-agent-browser) - [Commands | agent-browser](#commands-agent-browser) - [Dashboard | agent-browser](#dashboard-agent-browser) - [Snapshots | agent-browser](#snapshots-agent-browser) - [CDP Mode | agent-browser](#cdp-mode-agent-browser) - [Quick Start | agent-browser](#quick-start-agent-browser) - [Diffing | agent-browser](#diffing-agent-browser) - [Sessions | agent-browser](#sessions-agent-browser) - [Profiler | agent-browser](#profiler-agent-browser) - [iOS Simulator | agent-browser](#ios-simulator-agent-browser) - [Security | agent-browser](#security-agent-browser) - [Browser Use | agent-browser](#browser-use-agent-browser) - [Browserless | agent-browser](#browserless-agent-browser) - [Browserbase | agent-browser](#browserbase-agent-browser) - [Kernel | agent-browser](#kernel-agent-browser) - [AgentCore | agent-browser](#agentcore-agent-browser) - [Native Mode | agent-browser](#native-mode-agent-browser) - [Chrome | agent-browser](#chrome-agent-browser) - [Lightpanda | agent-browser](#lightpanda-agent-browser) - [Streaming | agent-browser](#streaming-agent-browser) - [Changelog | agent-browser](#changelog-agent-browser) - [Next.js + Vercel | agent-browser](#next-js-vercel-agent-browser) --- # agent-browser | Browser Automation for AI Introduction Copy Page agent-browser ============= Browser automation CLI designed for AI agents. Compact text output minimizes context usage. 100% native Rust. npm install -g agent-browser # all platforms brew install agent-browser # macOS agent-browser install # Download Chrome (first time) # or try without installing npx agent-browser open example.com Features -------- * **Agent-first** - Compact text output uses fewer tokens than JSON, designed for AI context efficiency * **Ref-based** - Snapshot returns accessibility tree with refs for deterministic element selection * **Fast** - Native Rust CLI for instant command parsing * **Complete** - 50+ commands for navigation, forms, screenshots, network, storage * **Sessions** - Multiple isolated browser instances with separate auth * **Cross-platform** - macOS, Linux, Windows with native binaries Works with ---------- Claude Code, Cursor, GitHub Copilot, OpenAI Codex, Google Gemini, opencode, and any agent that can run shell commands. Example ------- # Navigate and get snapshot agent-browser open example.com agent-browser snapshot -i # Output: # - heading "Example Domain" [ref=e1] # - link "More information..." [ref=e2] # Interact using refs agent-browser click @e2 agent-browser screenshot page.png agent-browser close Why refs? --------- The `snapshot` command returns a compact accessibility tree where each element has a unique ref like `@e1`, `@e2`. This provides: * **Context-efficient** - Text output uses ~200-400 tokens vs ~3000-5000 for full DOM * **Deterministic** - Ref points to exact element from snapshot * **Fast** - No DOM re-query needed * **AI-friendly** - LLMs parse text output naturally Architecture ------------ Client-daemon architecture for optimal performance: 1. **Rust CLI** - Parses commands, communicates with daemon 2. **Native Daemon** - Pure Rust daemon using direct CDP, manages Chrome via Chrome DevTools Protocol Daemon starts automatically and persists between commands. Platforms --------- Native Rust binaries for macOS (ARM64, x64), Linux (ARM64, x64), and Windows (x64). Ask AI⌘I --- # Installation | agent-browser Installation Copy Page Installation ============ Global installation (recommended) --------------------------------- Installs the native Rust binary for maximum performance: npm install -g agent-browser agent-browser install # Download Chrome from Chrome for Testing (first time) This is the fastest option -- commands run through the native Rust CLI directly with sub-millisecond parsing overhead. Quick start (no install) ------------------------ npx agent-browser install # Download Chrome (first time only) npx agent-browser open example.com Project installation (local dependency) --------------------------------------- For projects that want to pin the version in `package.json`: npm install agent-browser npx agent-browser install # Download Chrome (first time) Then use via `npx` or `package.json` scripts. Homebrew (macOS) ---------------- brew install agent-browser agent-browser install # Download Chrome (first time) Cargo (Rust) ------------ cargo install agent-browser agent-browser install # Download Chrome (first time) Compiles from source (~2-3 min). Requires the Rust toolchain ([rustup.rs](https://rustup.rs/) ). From source ----------- git clone https://github.com/vercel-labs/agent-browser cd agent-browser pnpm install pnpm build pnpm build:native ./bin/agent-browser install pnpm link --global Linux dependencies ------------------ On Linux, install system dependencies: agent-browser install --with-deps Updating -------- Upgrade to the latest version: agent-browser upgrade Detects your installation method (npm, Homebrew, or Cargo) and runs the appropriate update command automatically. Displays the version change on success, or informs you if you are already on the latest version. Custom browser -------------- Use a custom browser executable instead of bundled Chromium: * **Serverless** - Use `@sparticuz/chromium` (~50MB vs ~684MB) * **System browser** - Use existing Chrome installation * **Custom builds** - Use modified browser builds # Via flag agent-browser --executable-path /path/to/chromium open example.com # Via environment variable AGENT_BROWSER_EXECUTABLE_PATH=/path/to/chromium agent-browser open example.com ### Serverless example Use `@sparticuz/chromium` or similar to obtain a Chromium executable path, then pass it via `--executable-path` or `AGENT_BROWSER_EXECUTABLE_PATH`. AI agent setup -------------- agent-browser works with any AI agent out of the box. For richer context: ### AI coding assistants (recommended) Install the skill for your AI coding assistant: npx skills add vercel-labs/agent-browser This works with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Goose, OpenCode, and Windsurf. The skill is fetched from the repository and stays up to date automatically. > **Do not** copy `SKILL.md` from `node_modules` -- it will become stale as new features are added. Always use `npx skills add` or reference the repository version. ### AGENTS.md / CLAUDE.md Add to your instructions file: ## Browser Automation Use `agent-browser` for web automation. Run `agent-browser --help` for all commands. Core workflow: 1. `agent-browser open ` - Navigate to page 2. `agent-browser snapshot -i` - Get interactive elements with refs (@e1, @e2) 3. `agent-browser click @e1` / `fill @e2 "text"` - Interact using refs 4. Re-snapshot after page changes Ask AI⌘I --- # Skills | agent-browser Skills Copy Page Skills ====== agent-browser ships with skills that teach AI coding agents how to use it for specific workflows. Install a skill and your agent in Cursor, Claude Code, or Codex can automate browser tasks without manual guidance. Available Skills ---------------- * **agent-browser** — General browser automation: navigation, snapshots, forms, screenshots, data extraction, sessions, authentication, diffing, and the full command reference. * **dogfood** — Systematic exploratory testing. Navigates an app like a real user, finds bugs and UX issues, and produces a structured report with screenshots and repro videos. * **electron** — Automate any Electron app (VS Code, Slack, Discord, Figma, etc.) by connecting to its built-in Chrome DevTools Protocol port. This is how agent-browser drives native desktop apps like the Slack macOS app. * **slack** — Browser-based Slack automation. Check unreads, navigate channels, search conversations, send messages, and extract data — no API tokens needed. * **vercel-sandbox** — Run agent-browser + headless Chrome inside ephemeral Vercel Sandbox microVMs. Works with any Vercel-deployed framework (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.). Installation ------------ npx skills add vercel-labs/agent-browser --skill agent-browser npx skills add vercel-labs/agent-browser --skill dogfood npx skills add vercel-labs/agent-browser --skill electron npx skills add vercel-labs/agent-browser --skill slack npx skills add vercel-labs/agent-browser --skill vercel-sandbox After installing, your AI agent will automatically activate the right skill when it encounters a matching request. agent-browser ------------- The core skill. Teaches agents the full agent-browser API: the navigate-snapshot-interact-re-snapshot workflow, all commands, command chaining, authentication (auth vault and state persistence), sessions, diffing, JavaScript evaluation, annotated screenshots, semantic locators, and configuration. Example agent interactions: * "Open example.com and fill out the contact form" * "Take a screenshot of the dashboard after logging in" * "Compare staging and production versions of the homepage" dogfood ------- A structured workflow for exploratory testing. The agent opens a target URL, systematically explores the app (navigating pages, testing forms, clicking buttons, checking console errors), and documents every issue it finds with: * Numbered repro steps * Step-by-step screenshots * Repro videos for interactive bugs * Severity classification The output is a markdown report in an output directory, ready to hand to the responsible team. Run it with a single prompt like "dogfood vercel.com" or "QA http://localhost:3000 — focus on the billing page". electron -------- Electron apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) are built on Chromium and expose a Chrome DevTools Protocol (CDP) port that agent-browser can connect to. This skill teaches agents how to launch or connect to any Electron app, then use the standard snapshot-interact workflow to automate it. Launch the app with `--remote-debugging-port`, connect, and use the standard snapshot-interact workflow. This is the foundation that the **slack** skill builds on. slack ----- Browser-based Slack automation. Connects to an existing Slack session (via `agent-browser connect 9222`) or opens Slack in a new browser, then uses snapshots and element refs to navigate the UI. Covers checking unreads, navigating channels and DMs, searching conversations, extracting message data, and taking screenshots — all without needing Slack API tokens or bot setup. vercel-sandbox -------------- Run agent-browser + headless Chrome inside ephemeral Vercel Sandbox microVMs. A Linux VM spins up on demand, executes browser commands, and shuts down automatically. Works with any Vercel-deployed framework (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.). Key features: * Sandbox snapshots for sub-second startup (pre-install system deps, agent-browser, and Chromium) * Multi-step workflows with persistent state between commands * Automatic OIDC authentication on Vercel, or explicit credentials for local dev * Scheduled workflows via Vercel Cron Jobs Get started with the `@vercel/sandbox` package and the `withBrowser` helper pattern. See the `examples/environments/` directory in the repo for a working demo app. Source ------ All skill files are in the [`skills/`](https://github.com/vercel-labs/agent-browser/tree/main/skills) directory of the repository. Ask AI⌘I --- # Selectors | agent-browser Selectors Copy Page Selectors ========= Refs (recommended) ------------------ Refs provide deterministic element selection from snapshots. Best for AI agents. # 1. Get snapshot with refs agent-browser snapshot # Output: # - heading "Example Domain" [ref=e1] [level=1] # - button "Submit" [ref=e2] # - textbox "Email" [ref=e3] # - link "Learn more" [ref=e4] # 2. Use refs to interact agent-browser click @e2 # Click the button agent-browser fill @e3 "test@example.com" # Fill the textbox agent-browser get text @e1 # Get heading text agent-browser hover @e4 # Hover the link ### Why refs? * **Deterministic** - Ref points to exact element from snapshot * **Fast** - No DOM re-query needed * **AI-friendly** - LLMs can reliably parse and use refs CSS selectors ------------- agent-browser click "#id" agent-browser click ".class" agent-browser click "div > button" agent-browser click "[data-testid='submit']" Text & XPath ------------ agent-browser click "text=Submit" agent-browser click "xpath=//button[@type='submit']" Semantic locators ----------------- Find elements by role, label, or other semantic properties: agent-browser find role button click --name "Submit" agent-browser find label "Email" fill "test@test.com" agent-browser find placeholder "Search..." fill "query" agent-browser find testid "submit-btn" click Ask AI⌘I --- # Configuration | agent-browser Configuration Copy Page Configuration ============= Create an `agent-browser.json` file to set persistent defaults instead of repeating flags on every command. Config File Locations --------------------- agent-browser checks two locations, merged in priority order: | Priority | Location | Scope | | --- | --- | --- | | 1 (lowest) | `~/.agent-browser/config.json` | User-level defaults | | 2 | `./agent-browser.json` | Project-level overrides | | 3 | `AGENT_BROWSER_*` env vars | Override config values | | 4 (highest) | CLI flags | Override everything | Project-level values override user-level values. Environment variables override both. CLI flags always win. Use `--config ` or the `AGENT_BROWSER_CONFIG` environment variable to load a specific config file instead of the default locations: agent-browser --config ./ci-config.json open example.com AGENT_BROWSER_CONFIG=./ci-config.json agent-browser open example.com Example Config -------------- { "headed": true, "proxy": "http://localhost:8080", "profile": "./browser-data", "userAgent": "my-agent/1.0", "ignoreHttpsErrors": true } All Options ----------- Every CLI flag can be set in the config file using its camelCase equivalent: | Config Key | CLI Flag | Type | | --- | --- | --- | | `headed` | `--headed` | boolean | | `json` | `--json` | boolean | | `full` | `--full, -f` | boolean | | `debug` | `--debug` | boolean | | `session` | `--session` | string | | `sessionName` | `--session-name` | string | | `executablePath` | `--executable-path` | string | | `extensions` | `--extension` | string\[\] | | `profile` | `--profile` | string | | `state` | `--state` | string | | `proxy` | `--proxy` | string | | `proxyBypass` | `--proxy-bypass` | string | | `args` | `--args` | string | | `userAgent` | `--user-agent` | string | | `provider` | `-p, --provider` | string | | `device` | `--device` | string | | `ignoreHttpsErrors` | `--ignore-https-errors` | boolean | | `allowFileAccess` | `--allow-file-access` | boolean | | `cdp` | `--cdp` | string | | `autoConnect` | `--auto-connect` | boolean | | `colorScheme` | `--color-scheme` | string (`dark`, `light`, `no-preference`) | | `downloadPath` | `--download-path` | string | | `contentBoundaries` | `--content-boundaries` | boolean | | `maxOutput` | `--max-output` | number | | `allowedDomains` | `--allowed-domains` | string\[\] | | `actionPolicy` | `--action-policy` | string | | `confirmActions` | `--confirm-actions` | string | | `confirmInteractive` | `--confirm-interactive` | boolean | | `engine` | `--engine` | string (`chrome`, `lightpanda`) | | `noAutoDialog` | `--no-auto-dialog` | boolean | | `headers` | `--headers` | string (JSON) | Common Configurations --------------------- ### Local Development { "headed": true, "profile": "./browser-data" } ### Behind a Proxy { "proxy": "http://proxy.corp.example.com:8080", "proxyBypass": "localhost,*.internal.com", "ignoreHttpsErrors": true } ### CI / Devcontainer { "args": "--no-sandbox,--disable-gpu", "ignoreHttpsErrors": true } ### iOS Testing { "provider": "ios", "device": "iPhone 16 Pro" } ### AI Agent Security { "contentBoundaries": true, "maxOutput": 50000, "allowedDomains": ["your-app.com", "*.your-app.com"], "actionPolicy": "./policy.json" } Overriding Boolean Options -------------------------- Boolean flags accept an optional `true`/`false` value to override config settings: agent-browser --headed false open example.com A bare flag is equivalent to passing `true`: agent-browser --headed open example.com # same as --headed true agent-browser --headed true open example.com # explicit This applies to all boolean flags: `--headed`, `--debug`, `--json`, `--ignore-https-errors`, `--allow-file-access`, `--auto-connect`, `--content-boundaries`, `--confirm-interactive`. Extensions Merging ------------------ Extensions from user-level and project-level configs are **concatenated**, not replaced. For example, if `~/.agent-browser/config.json` specifies `["/ext1"]` and `./agent-browser.json` specifies `["/ext2"]`, the result is `["/ext1", "/ext2"]`. The `AGENT_BROWSER_EXTENSIONS` environment variable and CLI `--extension` flags follow the standard priority rules (env replaces config, CLI appends). Environment Variables --------------------- These environment variables configure additional daemon and runtime behavior: | Variable | Description | Default | | --- | --- | --- | | `AGENT_BROWSER_AUTO_CONNECT` | Auto-discover and connect to a running Chrome instance. | (disabled) | | `AGENT_BROWSER_ALLOW_FILE_ACCESS` | Allow `file://` URLs to access local files. | (disabled) | | `AGENT_BROWSER_COLOR_SCHEME` | Color scheme preference (`dark`, `light`, `no-preference`). | (none) | | `AGENT_BROWSER_DOWNLOAD_PATH` | Default directory for browser downloads. | (temp directory) | | `AGENT_BROWSER_DEFAULT_TIMEOUT` | Default timeout in ms. Keep below 30000 to avoid IPC timeouts. | `25000` | | `AGENT_BROWSER_SESSION_NAME` | Auto-save/load state persistence name. | (none) | | `AGENT_BROWSER_STATE_EXPIRE_DAYS` | Auto-delete saved session states older than N days. | `30` | | `AGENT_BROWSER_ENCRYPTION_KEY` | 64-char hex key for AES-256-GCM session encryption. | (none) | | `AGENT_BROWSER_EXTENSIONS` | Comma-separated browser extension paths. Extensions work in both headed and headless mode. | (none) | | `AGENT_BROWSER_HEADED` | Show browser window instead of running headless (`1` to enable). | (disabled) | | `AGENT_BROWSER_STREAM_PORT` | Override the WebSocket streaming port. By default, an OS-assigned port is used. Set this to bind to a specific port (e.g., `9223`). | OS-assigned | | `AGENT_BROWSER_IDLE_TIMEOUT_MS` | Auto-shutdown the daemon after N ms of inactivity (no commands received). Useful for ephemeral environments. | (disabled) | | `AGENT_BROWSER_IOS_DEVICE` | Default iOS device name for the `ios` provider. | (none) | | `AGENT_BROWSER_IOS_UDID` | Default iOS device UDID for the `ios` provider. | (none) | | `AGENT_BROWSER_DEBUG` | Enable debug output (`1` to enable). | (disabled) | | `AGENT_BROWSER_CONTENT_BOUNDARIES` | Wrap page output in boundary markers for LLM safety. | (disabled) | | `AGENT_BROWSER_MAX_OUTPUT` | Max characters for page output (truncates beyond limit). | (unlimited) | | `AGENT_BROWSER_ALLOWED_DOMAINS` | Comma-separated allowed domain patterns (e.g., `example.com,*.example.com`). | (unrestricted) | | `AGENT_BROWSER_ACTION_POLICY` | Path to action policy JSON file. | (none) | | `AGENT_BROWSER_CONFIRM_ACTIONS` | Comma-separated action categories requiring confirmation. | (none) | | `AGENT_BROWSER_CONFIRM_INTERACTIVE` | Enable interactive confirmation prompts (auto-denies if stdin is not a TTY). | (disabled) | | `AGENT_BROWSER_ENGINE` | Browser engine to use: `chrome` (default), `lightpanda`. | `chrome` | | `AGENT_BROWSER_NO_AUTO_DIALOG` | Disable automatic dismissal of `alert`/`beforeunload` dialogs. | (disabled) | Error Handling -------------- * **Auto-discovered config files** (`~/.agent-browser/config.json`, `./agent-browser.json`) that are missing are silently ignored. * **`--config `** with a missing or malformed file exits with an error. * **Malformed JSON** in auto-discovered files prints a warning to stderr and continues without that file. * **Unknown keys** are silently ignored for forward compatibility. > **Tip:** If your project-level `agent-browser.json` contains environment-specific values (paths, proxies), consider adding it to `.gitignore`. Ask AI⌘I --- # Commands | agent-browser Commands Copy Page Commands ======== Core ---- agent-browser open # Navigate (aliases: goto, navigate) agent-browser click # Click element (--new-tab to open in new tab) agent-browser dblclick # Double-click agent-browser fill # Clear and fill agent-browser type # Type into element agent-browser press # Press key (Enter, Tab, Control+a) (alias: key) agent-browser keyboard type # Type at current focus (no selector needed) agent-browser keyboard inserttext # Insert text without key events agent-browser keydown # Hold key down agent-browser keyup # Release key agent-browser hover # Hover element agent-browser focus # Focus element agent-browser select # Select dropdown option agent-browser check # Check checkbox agent-browser uncheck # Uncheck checkbox agent-browser scroll [px] # Scroll (up/down/left/right, --selector ) agent-browser scrollintoview # Scroll element into view agent-browser drag # Drag and drop agent-browser upload # Upload files agent-browser screenshot [path] # Screenshot (--full for full page) agent-browser screenshot --annotate # Annotated screenshot with numbered element labels agent-browser screenshot --screenshot-dir ./shots # Save to custom directory agent-browser screenshot --screenshot-format jpeg --screenshot-quality 80 agent-browser pdf # Save page as PDF agent-browser snapshot # Accessibility tree with refs agent-browser eval # Run JavaScript agent-browser connect ​​port|url​​ # Connect to browser via CDP agent-browser stream enable [--port ] # Start runtime WebSocket streaming agent-browser stream status # Show runtime streaming state and bound port agent-browser stream disable # Stop runtime WebSocket streaming agent-browser close # Close browser (aliases: quit, exit) agent-browser close --all # Close all active sessions Get info -------- agent-browser get text # Get text content agent-browser get html # Get innerHTML agent-browser get value # Get input value agent-browser get attr # Get attribute agent-browser get title # Get page title agent-browser get url # Get current URL agent-browser get cdp-url # Get CDP WebSocket URL agent-browser get count # Count matching elements agent-browser get box # Get bounding box agent-browser get styles # Get computed styles Check state ----------- agent-browser is visible # Check if visible agent-browser is enabled # Check if enabled agent-browser is checked # Check if checked Find elements ------------- Semantic locators with actions (`click`, `fill`, `type`, `hover`, `focus`, `check`, `uncheck`, `text`): agent-browser find role [value] agent-browser find text agent-browser find label