| name | agent-browser |
| domain | agent-tools |
| skill_type | skill |
| description | Browser automation CLI for AI agents using the agent-browser tool. 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. |
| license | MIT |
| tags | ["browser","automation","playwright","web-scraping","testing","screenshots"] |
| metadata | {"version":"1.2.1","author":"Genius"} |
Browser Automation with agent-browser
Overview
Automate browser interactions using the agent-browser CLI tool. Every automation follows a consistent navigate → snapshot → interact → re-snapshot pattern. The browser persists between commands via a background daemon, making command chaining efficient.
Setup — run this FIRST (self-installing)
The agent-browser CLI is not preinstalled. This skill ships bootstrap.sh,
which is idempotent — run it at the start of every task; it no-ops if already set up:
source "$(dirname "$0")/bootstrap.sh" 2>/dev/null || source ./bootstrap.sh
If you only need the binary on PATH (no env persistence), run it as a subprocess:
bash <skill-dir>/bootstrap.sh.
What bootstrap handles (and why — validated 2026-06-10)
- Install with
pnpm, not npm. The bundled npm (Python nodejs_wheel) is
broken here. pnpm add -g agent-browser (public npm registry) works. pnpm prints
"Ignored build scripts" — harmless. The bin lands in $PNPM_HOME
(default ~/.local/share/pnpm), which bootstrap adds to PATH.
- Playwright Chromium is usually already cached at
~/.cache/ms-playwright
(PLAYWRIGHT_BROWSERS_PATH). Bootstrap only downloads it if absent.
Headless server / SSH environments (e.g. this homelab)
-
Headless is the default — do not pass --headed on a server with no display.
-
Containers need --no-sandbox. Bootstrap sets AGENT_BROWSER_ARGS=--no-sandbox.
Use a single flag here: multiple space-split flags in AGENT_BROWSER_ARGS trip
Chromium's Multiple targets are not supported in headless mode.
-
Internal / plain-HTTP sites are blocked by default. Homelab *.arpa hosts
(served by Caddy over http) — and any pure-http site — return
ERR_BLOCKED_BY_CLIENT and land on chrome-error://. Cause: Chromium's
HTTPS-Upgrade auto-upgrades http→https and won't fall back. --no-sandbox
alone does NOT fix this, and the needed --disable-features flag can't be added via
AGENT_BROWSER_ARGS (see the multi-flag bug above).
Working fix — pre-launch Chromium with the flags, then attach over CDP:
bash <skill-dir>/bootstrap.sh --connect
agent-browser open http://twenty.arpa/
Equivalent manual form:
CHROME=$(find ~/.cache/ms-playwright -name chrome -path '*chromium-*' | head -1)
"$CHROME" --headless=new --no-sandbox --disable-gpu \
--disable-features=HttpsUpgrades,HttpsFirstBalancedModeAutoEnable,HttpsFirstModeV2 \
--remote-debugging-port=9222 --user-data-dir="$(mktemp -d)" &
agent-browser connect 9222
-
Self-signed HTTPS: add --ignore-https-errors on open.
Daemon hygiene
- Reset the persistent browser with
agent-browser close --all.
- Do NOT
pkill -f agent-browser — the pattern matches your own shell/command
line and kills the session (seen as exit 144). Kill a pre-launched Chromium by
its unique --user-data-dir path instead (e.g. pkill -f /tmp/agent-browser-prof).
- A stale daemon is a common cause of
Multiple targets are not supported in headless mode; close --all (and, if needed, killing the CDP Chromium) clears it.
Core Workflow
Every browser automation task follows this pattern:
- Navigate:
agent-browser open <url>
- Snapshot:
agent-browser snapshot -i (get interactive 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 --load networkidle
agent-browser snapshot -i
Command Reference
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 click @e1 --new-tab
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 snapshot --baseline before.txt
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 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 networkidle
Authentication with State Persistence
agent-browser open https://app.example.com/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 https://app.example.com/dashboard
Session Persistence
agent-browser --session-name myapp open https://app.example.com/login
agent-browser close
agent-browser --session-name myapp open https://app.example.com/dashboard
Data Extraction
agent-browser open https://example.com/products
agent-browser snapshot -i
agent-browser get text @e5
agent-browser get text body > page.txt
agent-browser snapshot -i --json
agent-browser get text @e1 --json
Parallel Sessions
agent-browser --session site1 open https://site-a.com
agent-browser --session site2 open https://site-b.com
agent-browser --session site1 snapshot -i
agent-browser --session site2 snapshot -i
agent-browser session list
Command Chaining
Commands can be chained with && in a single shell invocation. The browser persists between commands, so chaining is safe and efficient.
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser screenshot page.png
When to chain: Use && when intermediate output isn't needed (e.g., open + wait + screenshot). Run commands separately when parsing output first (e.g., snapshot to discover refs, then interact using those refs).
Ref Lifecycle
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. Each label [N] maps to ref @eN. This also caches refs, so interactions can begin immediately without a separate snapshot.
agent-browser screenshot --annotate
agent-browser click @e2
Use annotated screenshots when:
- The page has unlabeled icon buttons or visual-only elements
- Canvas or chart elements are present (invisible to text snapshots)
- Spatial reasoning about element positions is needed
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"
agent-browser find testid "submit-btn" click
JavaScript Evaluation
Use eval to run JavaScript in the browser context. Use --stdin or -b for complex expressions to avoid shell quoting issues.
agent-browser eval 'document.title'
agent-browser eval 'document.querySelectorAll("img").length'
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
agent-browser eval -b "$(echo -n 'Array.from(document.querySelectorAll("a")).map(a => a.href)' | base64)"
Timeouts and Slow Pages
agent-browser wait --load networkidle
agent-browser wait "#content"
agent-browser wait --url "**/dashboard"
agent-browser wait --fn "document.readyState === 'complete'"
agent-browser wait 5000
Diffing (Verifying Changes)
Use diff snapshot after an action to verify it had the intended effect:
agent-browser snapshot -i
agent-browser click @e2
agent-browser diff snapshot
agent-browser screenshot baseline.png
agent-browser diff screenshot --baseline baseline.png
agent-browser diff url https://staging.example.com https://prod.example.com --screenshot
Best Practices
- Always re-snapshot after navigation — refs become invalid when the page changes
- Use
wait --load networkidle after opening slow or SPA-based pages
- Use named sessions when running concurrent agents to avoid conflicts
- Always close sessions when done to avoid leaked browser processes
- Prefer
--stdin for complex JavaScript to avoid shell escaping issues