| name | agent-browser |
| description | Fast, persistent browser automation with session continuity. Use when automating browsers, scraping websites, filling forms, taking screenshots, testing UIs, extracting data, or when the user says "open browser", "scrape", "screenshot", "fill form", "browser automation", or "test this page." Based on vercel-labs/agent-browser (164K weekly installs). |
Browser Automation with agent-browser
CLI browser automation via Chrome/Chromium CDP. Install: npm i -g agent-browser. Run agent-browser install to download Chrome.
Core Workflow
- Navigate:
agent-browser open <url>
- Snapshot:
agent-browser snapshot -i (get element refs like @e1, @e2)
- Interact: Use refs to click, fill, select
- Re-snapshot: After navigation or DOM changes, get fresh refs
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 2000
agent-browser snapshot -i
Batch Execution
ALWAYS use batch for 2+ sequential commands:
agent-browser batch "open https://example.com" "snapshot -i"
agent-browser batch "click @e1" "wait 1000" "screenshot"
agent-browser batch "open https://example.com" "snapshot -i" "screenshot"
Only run a single command when you need to read output before deciding the next step.
Essential Commands
agent-browser open <url>
agent-browser close
agent-browser close --all
agent-browser snapshot -i
agent-browser snapshot -i --urls
agent-browser snapshot -s "#selector"
agent-browser click @e1
agent-browser fill @e2 "text"
agent-browser select @e1 "option"
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 2000
agent-browser wait --text "Welcome"
agent-browser wait --url "**/page"
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 tab list
agent-browser tab new https://example.com
agent-browser tab 2
agent-browser tab close
agent-browser --session site1 open https://site-a.com
agent-browser session list
Authentication
echo "$PASSWORD" | agent-browser auth save github --url https://github.com/login --username user --password-stdin
agent-browser auth login github
agent-browser --session-name myapp open https://app.example.com/login
agent-browser state save ./auth.json
agent-browser state load ./auth.json
agent-browser --auto-connect open https://example.com
Efficiency Patterns
- Use
--urls with snapshot to get all href URLs upfront — visit directly instead of clicking and navigating back
- Snapshot once, act many times — never re-snapshot the same page
- Multi-page: get URLs in one snapshot, then batch each target site separately
Ref Lifecycle
Refs (@e1, @e2) are invalidated when the page changes. Always re-snapshot after clicks that navigate, form submissions, or dynamic content loading.
Security
export AGENT_BROWSER_CONTENT_BOUNDARIES=1
export AGENT_BROWSER_ALLOWED_DOMAINS="example.com,*.example.com"
export AGENT_BROWSER_MAX_OUTPUT=50000
JavaScript Evaluation
agent-browser eval 'document.title'
agent-browser eval --stdin <<'EVALEOF'
JSON.stringify(Array.from(document.querySelectorAll("a")).map(a => a.href))
EVALEOF
Related Skills
playwright — Playwright-based browser automation (alternative)
seo-audit — SEO auditing (uses browser for schema detection)
web-design-guidelines — UI compliance checking