browser-harness
Direct browser control via CDP. Use when the user wants to automate, scrape, test, or interact with web pages. Connects to the user's already-running Chrome.
git clone https://github.com/browser-use/browser-harness
git clone --depth=1 https://github.com/browser-use/browser-harness ~/.claude/skills/browser-use-browser-harness-browser-harness
SKILL.mdbrowser-harness
Easiest and most powerful way to interact with the browser. Read this file in full before using or editing the harness — it has to be in context.
Fast start
Read
helpers.py first. For first-time install or reconnect/bootstrap, read install.md first.
browser-harness <<'PY' new_tab("https://docs.browser-use.com") wait_for_load() print(page_info()) PY
- Invoke as
— it's onbrowser-harness
. No$PATH
, nocd
.uv run - First navigation is
, notnew_tab(url)
—goto(url)
runs in the user's active tab and clobbers their work.goto
The code is the doc.
Available interaction skills:
— startup sequence, tab visibility, omnibox popup fixinteraction-skills/connection.md
Available domain skills:
tiktok/upload.md
Tool call shape
browser-harness <<'PY' # any python. helpers pre-imported. daemon auto-starts. PY
run.py calls ensure_daemon() before exec — you never start/stop manually unless you want to.
Remote browsers
Use remote for parallel sub-agents (each gets its own isolated browser via a distinct
BU_NAME) or on a headless server. BROWSER_USE_API_KEY must be set. start_remote_daemon, list_cloud_profiles, list_local_profiles, sync_local_profile are pre-imported.
browser-harness <<'PY' start_remote_daemon("work") # default — clean browser, no profile # start_remote_daemon("work", profileName="my-work") # reuse a cloud profile (already logged in) # start_remote_daemon("work", profileId="<uuid>") # same, but by UUID # start_remote_daemon("work", proxyCountryCode="de", timeout=120) # DE proxy, 2-hour timeout # start_remote_daemon("work", proxyCountryCode=None) # disable the Browser Use proxy PY BU_NAME=work browser-harness <<'PY' new_tab("https://example.com") print(page_info()) PY
start_remote_daemon prints liveUrl and auto-opens it in the local browser (if a GUI is detected) so the user can watch along. Headless servers print only — share the URL with the user. The daemon PATCHes the cloud browser to stop on shutdown, which persists profile state. Running remote daemons bill until timeout.
Profiles (cookies-only login state) live in
interaction-skills/profile-sync.md — covers list_cloud_profiles(), the chat-driven "which profile?" pattern, and sync_local_profile() for uploading a local Chrome profile.
Search first
After cloning the repo, search
domain-skills/ first for the domain you are working on before inventing a new approach.
Only if you start struggling with a specific mechanic while navigating, look in
interaction-skills/ for helpers. The available interaction skills are:
cookies.mdcross-origin-iframes.mddialogs.mddownloads.mddrag-and-drop.mddropdowns.mdiframes.mdnetwork-requests.mdprint-as-pdf.mdprofile-sync.mdscreenshots.mdscrolling.mdshadow-dom.mdtabs.mduploads.mdviewport.md
Useful commands:
rg --files domain-skills rg -n "tiktok|upload" domain-skills
Always contribute back
If you learned anything non-obvious about how a site works, open a PR to
before you finish. Default to contributing. The harness gets better only because agents file what they learn. If figuring something out cost you a few steps, the next run should not pay the same tax.domain-skills/<site>/
Examples of what's worth a PR:
- A private API the page calls (XHR/fetch endpoint, request shape, auth) — often 10× faster than DOM scraping.
- A stable selector that beats the obvious one, or an obfuscated CSS-module class to avoid.
- A framework quirk — "the dropdown is a React combobox that only commits on Escape", "this Vue list only renders rows inside its own scroll container, so
on the row doesn't work — you have to scroll the container".scrollIntoView - A URL pattern — direct route, required query params (
,?lang=en
), a variant that skips a loader.?th=1 - A wait that
misses, with the reason.wait_for_load() - A trap — stale drafts, legacy IDs that now return null, unicode quirks, beforeunload dialogs, CAPTCHA surfaces.
What a domain skill should capture
The durable shape of the site — the map, not the diary. Focus on what the next agent on this site needs to know before it starts:
- URL patterns and query params.
- Private APIs and their payload shape.
- Stable selectors (
,data-*
,aria-*
, semantic classes).role - Site structure — containers, items per page, framework, where state lives.
- Framework/interaction quirks unique to this site.
- Waits and the reasons they're needed.
- Traps and the selectors that don't work.
Do not write
- Raw pixel coordinates. They break on viewport, zoom, and layout changes. Describe how to locate the target (selector,
,scrollIntoView
, visible text) — never where it happened to be on your screen.aria-label - Run narration or step-by-step of the specific task you just did.
- Secrets, cookies, session tokens, user-specific state.
is shared and public.domain-skills/
What actually works
- Screenshots first: use
to understand the current page quickly, find visible targets, and decide whether you need a click, a selector, or more navigation.screenshot() - Clicking:
→ look →screenshot()
→click(x, y)
again to verify the result. Coordinate clicks pass through iframes/shadow/cross-origin at the compositor level.screenshot() - Bulk HTTP:
+http_get(url)
. No browser for static pages (249 Netflix pages in 2.8s).ThreadPoolExecutor - After goto:
.wait_for_load() - Wrong/stale tab:
. Use it when the current tab is stale or internal; the daemon also auto-recovers from stale sessions on the next call.ensure_real_tab() - Verification:
is the simplest "is this alive?" check, but screenshots are the default way to verify whether a visible action actually worked.print(page_info()) - DOM reads: use
for inspection and extraction when the screenshot shows that coordinates are the wrong tool.js(...) - Iframe sites (Azure blades, Salesforce):
passes through; only drop to iframe DOM work when coordinate clicks are the wrong tool.click(x, y) - Auth wall: redirected to login → stop and ask the user. Don't type credentials from screenshots.
- Raw CDP for anything helpers don't cover:
.cdp("Domain.method", **params)
Design constraints
- Coordinate clicks default.
goes through iframes/shadow/cross-origin at the compositor level.Input.dispatchMouseEvent - Connect to the user's running Chrome. Don't launch your own browser.
is only forcdp-use
. Prefer raw CDP strings over typed wrappers.CDPClient.send_raw
stays tiny. No argparse, subcommands, or extra control layer.run.py- Helpers stay short. Browser primitives in
; daemon/bootstrap and remote session admin live inhelpers.py
.admin.py - Don't add a manager layer. No retries framework, session manager, daemon supervisor, config system, or logging framework.
Architecture
Chrome / Browser Use cloud -> CDP WS -> daemon.py -> /tmp/bu-<NAME>.sock -> run.py
- Protocol is one JSON line each way.
- Requests are
for CDP or{method, params, session_id}
for daemon control.{meta: ...} - Responses are
/{result}
/{error}
/{events}
.{session_id}
namespaces socket, pid, and log files.BU_NAME
overrides local Chrome discovery for remote browsers.BU_CDP_WS
+BU_BROWSER_ID
lets the daemon stop a Browser Use cloud browser on shutdown.BROWSER_USE_API_KEY
Gotchas (field-tested)
- Chrome 144+
does NOT servechrome://inspect/#remote-debugging
. Read/json/version
instead.DevToolsActivePort - Try attaching before asking for setup. If
already works, skip the remote-debugging instructions entirely. Decide what to escalate from the harness's error message, not from whether Chrome is visibly running.uv run browser-harness - The remote-debugging checkbox is per-profile sticky in Chrome. Once ticked on a profile, every future Chrome launch auto-enables CDP — only navigate to
whenchrome://inspect/#remote-debugging
is genuinely missing on a fresh profile.DevToolsActivePort - The first connect may block on Chrome's Allow dialog. If setup hangs, explicitly tell the user to click
in Chrome if it appears, then keep polling for up to 30 seconds instead of treating follow-on errors as a new failure.Allow
can exist before the port is actually listening. Treat connection refused as "still enabling" and keep polling for up to 30 seconds.DevToolsActivePort- Chrome may open the profile picker before any real tab exists. If Chrome opens both a profile picker and the remote-debugging page, tell the user to choose their normal profile first, then tick the checkbox and click
if shown.Allow - On macOS, if Chrome is already running, prefer AppleScript
overopen location
. It reuses the current profile and avoids creating an extra startup path through the profile picker.open -a ... URL - Omnibox popups are fake
targets. Filterpage
and other internals when you need a real tab.chrome://omnibox-popup... - CDP target order != Chrome's visible tab-strip order. Use UI automation when the user means "the first/second tab I can see";
only shows a known target.Target.activateTarget - Default daemon sessions can go stale.
re-attaches to a real page.ensure_real_tab()
usually means a stale daemon / websocket. Restart the daemon once with:no close frame received or sentuv run python - <<'PY'from admin import restart_daemonrestart_daemon()
before assuming setup is wrong.PY- If
also hangs, kill Chrome entirely (restart_daemon()
), clean sockets (pkill -9 -f "Google Chrome"
), reopen Chrome (rm -f /tmp/bu-default.sock /tmp/bu-default.pid
), wait 5s, then reconnect. This resets all CDP state.open -a "Google Chrome" - Browser Use API is camelCase on the wire.
,cdpUrl
, etc.proxyCountryCode - Remote
is HTTPS, not ws. Resolve the websocket URL viacdpUrl
./json/version - Stop cloud browsers with
+PATCH /browsers/{id}
.{\"action\":\"stop\"} - After every meaningful action, re-screenshot before assuming it worked. Use the image to verify changed state, open menus, navigation, visible errors, and whether the page is in the state you expected.
- Use screenshots to drive exploration. They are often the fastest way to find the next click target, notice hidden blockers, and decide if a selector is even worth writing.
- Prefer compositor-level actions over framework hacks. Try screenshots, coordinate clicks, and raw key input before adding DOM-specific workarounds.
- If you need framework-specific DOM tricks, check
first. That is where dropdown, dialog, iframe, shadow DOM, and form-specific guidance belongs.interaction-skills/
Interaction notes
holds reusable UI mechanics such as dialogs, tabs, dropdowns, iframes, and uploads.interaction-skills/
holds site-specific workflows and should be updated when you discover reusable patterns for a website.domain-skills/