--- name: core description: Core agent-browser usage guide. Read this before running any agent-browser commands. Covers the snapshot-and-ref workflow, navigating pages, interacting with elements (click, fill, type, select), extracting text and data, taking screenshots, managing tabs, handling forms and auth, waiting for content, running multiple browser sessions in parallel, and troubleshooting common failures. Use when the user asks to interact with a website, fill a form, click something, extract data, take a screenshot, log into a site, test a web app, or automate any browser task. allowed-tools: Bash(agent-browser:*), Bash(agent-browser-stealth:*), Bash(abs:*), Bash(npx agent-browser:*), Bash(npx agent-browser-stealth:*) --- # agent-browser core Fast browser automation CLI for AI agents. Chrome/Chromium via CDP, no Playwright or Puppeteer dependency. Accessibility-tree snapshots with compact `@eN` refs let agents interact with pages in ~200-400 tokens instead of parsing raw HTML. Most normal web tasks (navigate, read, click, fill, extract, screenshot) are covered here. Load a specialized skill when the task falls outside browser web pages — see [When to load another skill](#when-to-load-another-skill). ## The core loop ```bash agent-browser open # 1. Open a page agent-browser snapshot -i # 2. See what's on it (interactive elements only) agent-browser click @e3 # 3. Act on refs from the snapshot agent-browser snapshot -i # 4. Re-snapshot after any page change ``` Refs (`@e1`, `@e2`, ...) are assigned fresh on every snapshot. They become **stale the moment the page changes** — after clicks that navigate, form submits, dynamic re-renders, dialog opens. Always re-snapshot before your next ref interaction. ## Before you automate: pick the cheapest tool Driving a browser is the heavy option. agent-browser earns its keep when you need a **real, logged-in browser** — not for reading text off a public page. | You need | Use | |---|---| | Discover what exists / find sources | `WebSearch` | | Specific facts from a static or public page | `WebFetch` or `curl` (no browser) | | Login state, interaction, JS-rendered or anti-bot pages | **agent-browser** (this skill) | | A page the user saved before / an internal system | `agent-browser find-url ` (their bookmarks), then open it | | The user's **own already-open, logged-in** Chrome window | the **extension connect** flow (below) | Don't hand-build deep URLs with query params — links discovered by *interacting* with the site carry the right hidden context and dodge anti-bot checks; a hand-constructed URL often doesn't. ### Driving the user's real, already-open Chrome (extension) When the task needs the user's *live* logged-in window (their real session, the window they're looking at — not a fresh browser), use the extension connect flow: `agent-browser extension install` once, load `extensions/ab-connect` in `chrome://extensions` once (it shows up as **agent-browser-stealth**; a GUI step you can perform with a **computer-use / GUI-automation tool** like the `cua-driver` skill — see `references/commands.md` → "Drive your real, logged-in Chrome"). Once the extension is loaded, plain `agent-browser open ` auto-connects through it — `auto_connect_cdp` **prefers the live extension relay over a raw `--remote-debugging-port`**, so Chrome 136+'s "Allow remote debugging?" consent popup never fires. `agent-browser extension connect` is the explicit form of the same path. Zero-confirmation, zero-token. Use `--launch` instead when a fresh, isolated browser is fine. Each `--session` that connects gets its **own colored Chrome tab group** (named after the session) and drives only its own tabs — multiple agents share the one real browser without cross-talk, and the user's own tabs are never grouped. CDP drives the page without moving the user's mouse/keyboard, so it doesn't fight them for control. **Anti-detection ranking: this real logged-in Chrome (extension connect) > a headed launched browser > headless (forbidden).** A genuine human browser has no headless/automation tells at all, so prefer it for anything anti-bot-sensitive. ## Two ways to drive a page — and when to drop to `eval` You have a **real Chrome with the user's DOM**. Two layers, mix them freely: 1. **Structured** (`snapshot` + `@ref`, `find`, typed actions) — convenient and readable; best for straightforward forms and navigation. But the a11y view is *lossy and fragile*: refs go stale on any change, hidden inputs never show up, overlays can block coordinate clicks. 2. **eval-first** (`agent-browser eval ""`) — your eyes and hands on the real DOM: read hidden inputs, reach into Shadow DOM / iframes, inspect `form.elements` and `.validity`, extract the exact shape you want, or call `el.click()` directly. **The moment the structured path fights you, drop to `eval` instead of retrying it** — it's the fast way to find *why* something failed (e.g. a hidden `point_choice=none` the UI never exposes). ```bash # "what's actually in this form / why won't it submit?" agent-browser eval "[...document.forms[0].elements].map(e=>[e.name,e.type,e.value,e.checked])" agent-browser eval "document.querySelector('[name=point_choice]')?.value" agent-browser eval "[...document.forms[0].elements].filter(e=>!e.validity.valid).map(e=>e.name+': '+e.validationMessage)" agent-browser eval "document.querySelector('#stubborn').click()" # direct DOM click, bypasses overlays ``` ## Quickstart ```bash # Install once npm i -g agent-browser && agent-browser install # Take a screenshot of a page agent-browser open https://example.com agent-browser screenshot home.png agent-browser close # Search, click a result, and capture it agent-browser open https://duckduckgo.com agent-browser snapshot -i # find the search box ref agent-browser fill @e1 "agent-browser cli" agent-browser press Enter agent-browser wait --load networkidle agent-browser snapshot -i # refs now reflect results agent-browser click @e5 # click a result agent-browser screenshot result.png ``` The browser stays running across commands so these feel like a single session. Use `agent-browser close` (or `close --all`) when you're done. ## Reading a page ```bash agent-browser snapshot # full tree (verbose) agent-browser snapshot -i # interactive elements only (preferred) agent-browser snapshot -i -u # include href urls on links agent-browser snapshot -i -c # compact (no empty structural nodes) agent-browser snapshot -i -d 3 # cap depth at 3 levels agent-browser snapshot -s "#main" # scope to a CSS selector agent-browser snapshot -i --json # machine-readable output ``` Snapshot output looks like: ``` Page: Example - Log in URL: https://example.com/login @e1 [heading] "Log in" @e2 [form] @e3 [input type="email"] placeholder="Email" @e4 [input type="password"] placeholder="Password" @e5 [button type="submit"] "Continue" @e6 [link] "Forgot password?" ``` For unstructured reading (no refs needed): ```bash agent-browser get text @e1 # visible text of an element agent-browser get html @e1 # innerHTML agent-browser get attr @e1 href # any attribute agent-browser get value @e1 # input value agent-browser get title # page title agent-browser get url # current URL agent-browser get count ".item" # count matching elements ``` ## Interacting ```bash agent-browser click @e1 # click agent-browser click @e1 --new-tab # open link in new tab instead of navigating agent-browser dblclick @e1 # double-click agent-browser hover @e1 # hover agent-browser focus @e1 # focus (useful before keyboard input) agent-browser fill @e2 "hello" # clear then type agent-browser type @e2 " world" # type without clearing agent-browser press Enter # press a key at current focus agent-browser press Control+a # key combination agent-browser check @e3 # check checkbox agent-browser uncheck @e3 # uncheck agent-browser select @e4 "option-value" # select dropdown option agent-browser select @e4 "a" "b" # select multiple agent-browser upload @e5 file1.pdf # upload file(s) agent-browser scroll down 500 # scroll page (up/down/left/right) agent-browser scrollintoview @e1 # scroll element into view agent-browser drag @e1 @e2 # drag and drop ``` ### When refs don't work or you don't want to snapshot Use semantic locators: ```bash agent-browser find role button click --name "Submit" agent-browser find text "Sign In" click agent-browser find text "Sign In" click --exact # exact match only agent-browser find label "Email" fill "user@test.com" agent-browser find placeholder "Search" type "query" agent-browser find testid "submit-btn" click agent-browser find first ".card" click agent-browser find nth 2 ".card" hover ``` Or a raw CSS selector: ```bash agent-browser click "#submit" agent-browser fill "input[name=email]" "user@test.com" agent-browser click "button.primary" ``` Escalation ladder: snapshot + `@eN` refs are quickest for straightforward pages → `find role/text/label` when you'd rather skip the snapshot → raw CSS → **`eval` the moment any of those fight you** (stale refs, hidden state, occluded clicks). Don't retry a flaky structured locator three times; drop to `eval` and act on the DOM directly. `click` auto-scrolls into view and, if the coordinate click is occluded, falls back to a DOM `.click()`. If a click *reports success but nothing happened* — classic for an autocomplete/menu `
  • ` that closes on the input's blur — retry that one with `AGENT_BROWSER_CLICK_MODE=dom agent-browser click ...`, or just `agent-browser eval "