agent-browser · git:20260407.503d5c4 · 2026-04-07 · sha256 6fafbb65a6608f09
agent-browser git:20260407.503d5c4A
Immutable. This exact content never changes and is served at /api/v1/blob/6fafbb65a6608f09.
--- name: agent-browser description: Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. allowed-tools: Bash(npx agent-browser:*), Bash(agent-browser:*) --- # Browser Automation with agent-browser The CLI uses Chrome/Chromium via CDP directly. Install via `npm i -g agent-browser`, `brew install agent-browser`, or `cargo install agent-browser`. Run `agent-browser install` to download Chrome. Existing Chrome, Brave, Playwright, and Puppeteer installations are detected automatically. Run `agent-browser upgrade` to update to the latest version. ## Core Workflow Every browser automation follows this pattern: 1. **Navigate**: `agent-browser open <url>` 2. **Snapshot**: `agent-browser snapshot -i` (get element refs like `@e1`, `@e2`) 3. **Interact**: Use refs to click, fill, select 4. **Re-snapshot**: After navigation or DOM changes, get fresh refs ```bash agent-browser open https://example.com/form agent-browser snapshot -i # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit" agent-browser fill @e1 "user@example.com" agent-browser fill @e2 "password123" agent-browser click @e3 agent-browser wait 2000 agent-browser snapshot -i # Check result ``` ## Command Chaining Commands can be chained with `&&` in a single shell invocation. The browser persists between commands via a background daemon, so chaining is safe and more efficient than separate calls. ```bash # Chain open + snapshot in one call (open already waits for page load) agent-browser open https://example.com && agent-browser snapshot -i # Chain multiple interactions agent-browser fill @e1 "user@example.com" && agent-browser fill @e2 "password123" && agent-browser click @e3 # Navigate and capture agent-browser open https://example.com && agent-browser screenshot ``` **When to chain:** Use `&&` when you don't need to read the output of an intermediate command before proceeding (e.g., open + wait + screenshot). Run commands separately when you need to parse the output first (e.g., snapshot to discover refs, then interact using those refs). ## Batch Execution ALWAYS use `batch` when running 2+ commands in sequence. Batch executes commands in order, so dependent commands (like navigate then screenshot) work correctly. Each quoted argument is a separate command. ```bash # Navigate and take a snapshot agent-browser batch "open https://example.com" "snapshot -i" # Navigate, snapshot, and screenshot in one call agent-browser batch "open https://example.com" "snapshot -i" "screenshot" # Click, wait, then screenshot agent-browser batch "click @e1" "wait 1000" "screenshot" ``` ## Essential Commands ```bash # Navigation agent-browser open <url> # Navigate (aliases: goto, navigate) agent-browser close # Close browser # Snapshot agent-browser snapshot -i # Interactive elements with refs (recommended) agent-browser snapshot -i --urls # Include href URLs for links # Interaction (use @refs from snapshot) agent-browser click @e1 # Click element agent-browser fill @e2 "text" # Clear and type text agent-browser select @e1 "option" # Select dropdown option agent-browser press Enter # Press key agent-browser scroll down 500 # Scroll page # Capture agent-browser screenshot # Screenshot to temp dir agent-browser screenshot --full # Full page screenshot agent-browser screenshot --annotate # Annotated screenshot with numbered element labels agent-browser pdf output.pdf # Save as PDF # Wait agent-browser wait @e1 # Wait for element agent-browser wait 2000 # Wait milliseconds agent-browser wait --url "**/page" # Wait for URL pattern agent-browser wait --text "Welcome" # Wait for text to appear ``` ## Authentication ```bash # Save credentials once (encrypted) echo "pass" | agent-browser auth save myapp --url https://example.com/login --username user --password-stdin # Login using saved profile agent-browser auth login myapp # Import auth from running Chrome (already logged in) agent-browser --auto-connect state save ./auth.json agent-browser --state ./auth.json open https://app.example.com/dashboard # Reuse Chrome profile agent-browser --profile Default open https://app.example.com ``` ## Session Management ```bash # Named sessions for concurrent automation agent-browser --session site1 open https://site-a.com agent-browser --session site2 open https://site-b.com # Close when done agent-browser close --all ``` ## Security ```bash # Content boundaries (recommended for AI agents) export AGENT_BROWSER_CONTENT_BOUNDARIES=1 # Domain allowlist export AGENT_BROWSER_ALLOWED_DOMAINS="example.com,*.example.com" # Output limits export AGENT_BROWSER_MAX_OUTPUT=50000 ``` ## Ref Lifecycle Refs (`@e1`, `@e2`, etc.) are invalidated when the page changes. Always re-snapshot after clicking links, form submissions, or dynamic content loading.