| name | agent-browser |
| description | Browser automation CLI for AI agents. Use when the user needs to interact with websites, verify dev server output, test web apps, navigate pages, fill forms, click buttons, take screenshots, extract data, or automate any browser task. Also triggers when a dev server starts so you can verify it visually. |
| metadata | {"priority":3,"docs":["https://openai.com/index/introducing-codex/"],"pathPatterns":["agent-browser.json","playwright.config.*","e2e/**","tests/e2e/**","test/e2e/**","cypress/**","cypress.config.*"],"bashPatterns":["\\bagent-browser\\b","\\bnext\\s+dev\\b","\\bnpm\\s+run\\s+dev\\b","\\bpnpm\\s+dev\\b","\\bbun\\s+run\\s+dev\\b","\\byarn\\s+dev\\b","\\bvite\\b","\\bnuxt\\s+dev\\b","\\bvercel\\s+dev\\b","\\blocalhost:\\d+","\\b127\\.0\\.0\\.1:\\d+","\\bcurl\\s+.*localhost","\\bopen\\s+https?://","\\bplaywright\\b","\\bcypress\\b"]} |
Browser Automation with agent-browser
When a dev server is running or the user asks to verify, test, or interact with a web page, use agent-browser to automate the browser.
Core Workflow
Every browser automation follows this pattern:
- 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 http://localhost:3000
agent-browser wait --load networkidle
agent-browser snapshot -i
Dev Server Verification
When a dev server starts, use agent-browser to verify it's working:
agent-browser open http://localhost:3000
agent-browser wait --load networkidle
agent-browser screenshot dev-check.png
agent-browser snapshot -i
Command Chaining
Commands can be chained with &&. The browser persists between commands via a background daemon.
agent-browser open http://localhost:3000 && agent-browser wait --load networkidle && agent-browser snapshot -i
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 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
Common Patterns
Form Submission
agent-browser open http://localhost:3000/signup
agent-browser snapshot -i
agent-browser fill @e1 "Jane Doe"
agent-browser fill @e2 "jane@example.com"
agent-browser click @e5
agent-browser wait --load networkidle
Authentication with State Persistence
agent-browser open http://localhost:3000/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 http://localhost:3000/dashboard
Data Extraction
agent-browser open http://localhost:3000/products
agent-browser snapshot -i
agent-browser get text @e5
agent-browser get text body > page.txt
Visual Debugging
agent-browser --headed open http://localhost:3000
agent-browser highlight @e1
agent-browser record start demo.webm
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 for screenshots with numbered labels on interactive elements:
agent-browser screenshot --annotate
agent-browser click @e2
Semantic Locators (Alternative to Refs)
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find role button click --name "Submit"
JavaScript Evaluation
agent-browser eval 'document.title'
agent-browser eval --stdin <<'EVALEOF'
JSON.stringify(
Array.from(document.querySelectorAll("img"))
.filter(i => !i.alt)
.map(i => ({ src: i.src.split("/").pop(), width: i.width }))
)
EVALEOF
Session Management
agent-browser --session site1 open http://localhost:3000
agent-browser --session site2 open http://localhost:3001
agent-browser session list
agent-browser close
Timeouts and Slow Pages
agent-browser wait --load networkidle
agent-browser wait "#content"
agent-browser wait --url "**/dashboard"
agent-browser wait 5000