| name | agent-browser |
| description | Browser automation CLI for direct website interaction. Use when the user needs to open URLs, click buttons, fill forms, take screenshots, log in, or test web apps. NOT for web search. |
| dependencies | ["agent-browser"] |
| tags | ["browser","automation"] |
| priority | normal |
| install | {"bun":"bun install -g agent-browser"} |
Browser Automation with agent-browser
Performance Rules (CRITICAL)
- ALWAYS chain commands with
&& when you don't need intermediate output. Each separate tool call costs seconds of round-trip latency.
- ALWAYS combine open + wait + snapshot into one call:
agent-browser open <url> && agent-browser wait --load load && agent-browser snapshot -i
- ALWAYS batch multiple interactions (fill, click, select) into one
&& chain when refs are already known.
- Use
--load load (DOM load event) by default. Only use networkidle when you specifically need all XHR/fetch to complete (e.g., waiting for API-driven content).
- Do NOT snapshot after every interaction — only re-snapshot when you need to discover new element refs (after navigation or major DOM changes).
Core Workflow
Every browser automation follows this pattern:
- Navigate + Snapshot (one call):
agent-browser open <url> && agent-browser wait --load load && agent-browser snapshot -i
- Interact: Batch all interactions using known refs in one
&& chain
- Re-snapshot: Only after navigation or major DOM changes
agent-browser open https://example.com/form && agent-browser wait --load load && agent-browser snapshot -i
agent-browser fill @e1 "user@example.com" && agent-browser fill @e2 "password123" && agent-browser click @e3 && agent-browser wait --load load
agent-browser snapshot -i
This reduces 7+ round-trips to just 2-3.
Essential Commands
agent-browser open <url>
agent-browser close
agent-browser snapshot -i
agent-browser snapshot -i -C
agent-browser snapshot -s "#selector"
agent-browser click @e1
agent-browser fill @e2 "text"
agent-browser type @e2 "text"
agent-browser select @e1 "option"
agent-browser check @e1
agent-browser press Enter
agent-browser scroll down 500
agent-browser get text @e1
agent-browser get url
agent-browser get title
agent-browser wait @e1
agent-browser wait --load load
agent-browser wait --load networkidle
agent-browser wait --url "**/page"
agent-browser wait 2000
agent-browser screenshot
agent-browser screenshot --full
agent-browser screenshot --annotate
agent-browser pdf output.pdf
agent-browser diff snapshot
agent-browser diff screenshot --baseline before.png
agent-browser diff url <url1> <url2>
Common Patterns
Form Submission
agent-browser open https://example.com/signup && agent-browser wait --load load && agent-browser snapshot -i
agent-browser fill @e1 "Jane Doe" && agent-browser fill @e2 "jane@example.com" && agent-browser select @e3 "California" && agent-browser check @e4 && agent-browser click @e5 && agent-browser wait --load load
Authentication with State Persistence
agent-browser open https://app.example.com/login && agent-browser wait --load load && 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
Data Extraction
agent-browser open https://example.com/products && agent-browser wait --load load && agent-browser snapshot -i
agent-browser get text @e5
agent-browser get text body > page.txt
agent-browser snapshot -i --json
Ref Lifecycle (Important)
Refs (@e1, @e2, etc.) are invalidated when the page changes. Always re-snapshot after:
- Clicking links or buttons that navigate
- Form submissions
- Dynamic content loading (dropdowns, modals)
agent-browser click @e5
agent-browser snapshot -i
agent-browser click @e1
Annotated Screenshots (Vision Mode)
Use --annotate to take a screenshot with numbered labels overlaid on interactive elements.
agent-browser screenshot --annotate
agent-browser click @e2
Semantic Locators (Alternative to Refs)
When refs are unavailable or unreliable, use semantic locators:
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find role button click --name "Submit"
agent-browser find placeholder "Search" type "query"
Session Management
Always close your browser session when done:
agent-browser close
agent-browser --session agent1 close
Browser Profile (Persistent Login)
If the system prompt provides --session, --profile, --headed, and/or --executable-path parameters, you MUST include them in every agent-browser command. This allows reusing persistent login state (cookies, localStorage, etc.).
agent-browser --session my-profile --profile /path/to/profile --headed open https://app.example.com
agent-browser --session my-profile --profile /path/to/profile --headed snapshot -i
Troubleshooting
If agent-browser fails to launch:
- Try
agent-browser install chrome then retry once
- If headed mode fails, try without
--headed (headless) while keeping --profile and --session
- Do NOT retry the same failing command more than 2 times
Default Mode (No Profile)
When no browser profile is specified in the system prompt, use agent-browser without --headed, --profile, or --session flags. The browser runs in headless mode by default.