| name | use-agent-browser |
| description | Browse the web, interact with pages, take screenshots, and extract content using the agent-browser CLI. Use when asked to "open a website", "take a screenshot", "check a page", "fill a form", "click a button", "scrape content", or any browser automation task. |
| metadata | {"version":"1.0.0","argument-hint":"<url-or-action>"} |
Agent Browser
Automate browser interactions using the agent-browser CLI (Playwright-based headless browser).
When to Use
- Opening and inspecting web pages
- Taking screenshots or saving PDFs
- Filling forms, clicking buttons, navigating sites
- Extracting text, HTML, or attribute values from pages
- Checking element visibility or state
- Debugging frontend apps in the browser
- Testing deployed web applications
Quick Reference
Navigation
agent-browser open <url>
agent-browser back
agent-browser forward
agent-browser reload
Interaction
agent-browser click <selector>
agent-browser type <selector> <text>
agent-browser fill <selector> <text>
agent-browser press <key>
agent-browser hover <selector>
agent-browser check <selector>
agent-browser uncheck <selector>
agent-browser select <selector> <val>
agent-browser scroll <direction> [px]
agent-browser upload <selector> <files...>
Get Information
agent-browser get text [selector]
agent-browser get html [selector]
agent-browser get value <selector>
agent-browser get attr <name> <sel>
agent-browser get title
agent-browser get url
agent-browser get count <selector>
Check State
agent-browser is visible <selector>
agent-browser is enabled <selector>
agent-browser is checked <selector>
Capture
agent-browser screenshot [path]
agent-browser pdf <path>
AI-Optimized Inspection
agent-browser snapshot
agent-browser snapshot -i
agent-browser snapshot -c
agent-browser snapshot -d <n>
agent-browser snapshot -s <selector>
Find Elements
agent-browser find role <value> click
agent-browser find text <value> click
agent-browser find label <value> fill <txt>
agent-browser find placeholder <value> fill <txt>
agent-browser find testid <value> click
JavaScript
agent-browser eval <js>
Sessions & Tabs
agent-browser tab new
agent-browser tab list
agent-browser tab <n>
agent-browser tab close
agent-browser --session <name> <cmd>
Browser Settings
agent-browser set viewport <w> <h>
agent-browser set device <name>
agent-browser set media dark
agent-browser set media light
agent-browser set offline on
Network
agent-browser network requests
agent-browser network route <url> --abort
agent-browser cookies get
agent-browser cookies clear
Debug
agent-browser console
agent-browser errors
agent-browser highlight <selector>
agent-browser trace start
agent-browser trace stop [path]
Workflow Patterns
Pattern 1: Inspect a Page
agent-browser open "https://example.com"
agent-browser snapshot -i -c
agent-browser screenshot ./page.png
Pattern 2: Fill and Submit a Form
agent-browser open "https://example.com/form"
agent-browser snapshot -i
agent-browser fill @ref "value"
agent-browser click @ref
agent-browser screenshot ./result.png
Pattern 3: Extract Content
agent-browser open "https://example.com"
agent-browser get text "main"
agent-browser get html ".article"
agent-browser get count "li.item"
Pattern 4: Test a Deployed App
agent-browser open "http://localhost:3000"
agent-browser snapshot -i
agent-browser click "button:has-text('Connect Wallet')"
agent-browser screenshot ./after-click.png
agent-browser console
agent-browser errors
Important Notes
set media vs class-based dark mode
agent-browser set media dark emulates prefers-color-scheme: dark at the browser level. This only works for sites that use @media (prefers-color-scheme: dark). Many apps (e.g., Tailwind CSS apps with .dark class toggle) use class-based dark mode instead. For those, click the app's own theme toggle button rather than using set media. Use snapshot -i to find the toggle.
--session is required for multi-command workflows
Without --session, each command launches a fresh browser. To maintain state (login, navigation, theme) across multiple commands, always pass --session <name> to every command in the workflow. Every command in the chain must use the same session name.
Output format
open prints the page title and URL on success
snapshot outputs an indented accessibility tree with [ref=eN] annotations for interactive elements
screenshot prints the saved file path — use the Read tool to view it (Claude can see images)
get text returns plain text; get html returns raw HTML
is visible/enabled/checked returns a boolean-style message
click/fill/type print a checkmark on success
Command chaining
Each command is a separate process invocation. You can chain independent commands with && in a single Bash call, but add sleep 1 between navigation/click and screenshot to let the page settle:
agent-browser open "http://localhost:3000" --session s1 && sleep 1 && agent-browser screenshot /tmp/page.png --session s1
Selectors
Selectors can be:
- CSS selectors:
button, .class, #id, [data-testid="foo"]
- Snapshot refs:
@e1, @e2 (from snapshot output)
- Text selectors:
"text=Submit" or "button:has-text('Submit')"
Tips
- Always start with
snapshot -i -c to get a quick map of interactive elements before interacting
- Use
--session <name> on every command to maintain browser state across a workflow
- Screenshots are useful for visual verification — read them with the Read tool to see the result
- Add
sleep 1-2 between actions that trigger page transitions and subsequent screenshots
- Use
agent-browser close --session <name> when done to clean up the browser process
- For long pages, use
scroll down or scrollintoview <sel> before screenshotting below-fold content
eval can run arbitrary JS — useful for reading localStorage, checking document.documentElement.classList, etc.