browser-harness-self-healing
```markdown
What this skill does
```markdown
---
name: browser-harness-self-healing
description: Self-healing browser harness that gives LLMs complete freedom to complete any browser task via CDP, with auto-written helpers.
triggers:
- set up browser harness
- automate browser with LLM
- self-healing browser agent
- use browser-harness for web tasks
- connect LLM to real browser
- browser automation with CDP
- install browser-use harness
- run browser task with AI agent
---
# Browser Harness (Self-Healing LLM Browser Agent)
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
Browser Harness is the simplest, thinnest self-healing harness that gives an LLM complete freedom to complete any browser task. It connects directly to Chrome via the Chrome DevTools Protocol (CDP) over a single WebSocket — no framework, no recipes, no rails. When a helper function is missing mid-task, the agent writes it into `helpers.py` and continues.
---
## Installation
### 1. Clone and read `install.md`
```bash
git clone https://github.com/browser-use/browser-harness
cd browser-harness
cat install.md
```
Always read `install.md` first — it covers the exact steps to install dependencies and connect to your real browser.
### 2. Install dependencies
```bash
pip install -r requirements.txt
```
### 3. Enable Chrome Remote Debugging
Launch Chrome with remote debugging enabled:
```bash
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--user-data-dir=/tmp/chrome-debug
# Linux
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
# Windows
"C:\Program Files\Google\Chrome\Application\chrome.exe" ^
--remote-debugging-port=9222 --user-data-dir=C:\tmp\chrome-debug
```
When the browser opens, tick the checkbox on the setup page to allow connection.
### 4. Start the daemon
```bash
python daemon.py
```
This launches the CDP WebSocket bridge and socket server that `run.py` and `admin.py` communicate through.
---
## Core Files
| File | Lines | Purpose |
|------|-------|---------|
| `run.py` | ~36 | Runs plain Python with helpers preloaded |
| `helpers.py` | ~195 | Starting tool calls; **the agent edits this** |
| `admin.py` | ~180 | Admin/bootstrap utilities |
| `daemon.py` | ~181 | CDP WebSocket + socket bridge |
| `install.md` | — | First-time install guide |
| `SKILL.md` | — | Day-to-day usage reference |
---
## Running Tasks
### Basic usage
```bash
python run.py
```
`run.py` imports `helpers.py` and drops into an interactive loop where the agent (or you, as the agent) can call any helper directly.
### Example: star a GitHub repository
```python
# Inside run.py context — helpers are already imported
navigate("https://github.com/browser-use/browser-harness")
click('[aria-label="Star this repository"]')
```
### Example: fill a form
```python
navigate("https://example.com/form")
type_text("#name", "Jane Doe")
type_text("#email", "[email protected]")
click('button[type="submit"]')
wait_for_selector(".success-message")
```
---
## helpers.py — Key Functions
Read `helpers.py` every time before writing a task — the agent edits it and functions evolve. Typical starting helpers:
```python
# Navigate to a URL
navigate(url: str)
# Click an element by CSS selector
click(selector: str)
# Type text into an input
type_text(selector: str, text: str)
# Wait for an element to appear
wait_for_selector(selector: str, timeout: int = 5000)
# Get text content of an element
get_text(selector: str) -> str
# Evaluate arbitrary JS in the page
evaluate(js: str) -> Any
# Take a screenshot (returns base64 PNG)
screenshot() -> str
# Scroll the page
scroll(x: int, y: int)
# Upload a file (agent writes this if missing)
upload_file(selector: str, path: str)
```
**Self-healing pattern:** If a function doesn't exist yet, the agent appends it to `helpers.py` and continues:
```
● agent: wants to upload a file
│
● helpers.py → upload_file() missing
│
● agent edits helpers.py helpers.py 192 → 199 lines
│ + upload_file()
✓ file uploaded
```
---
## CDP / WebSocket Architecture
```
Agent (Python) → run.py → helpers.py
│
socket bridge
│
daemon.py
│
CDP WebSocket (port 9222)
│
Chrome browser
```
- `daemon.py` holds the persistent CDP connection
- All helper calls go through the socket bridge — no direct CDP in user code
- The agent only touches `helpers.py` and `run.py`
---
## Remote Browsers (Free Tier)
For sub-agents or deployment without a local browser:
1. Get a free API key (3 concurrent browsers, no card): [cloud.browser-use.com/new-api-key](https://cloud.browser-use.com/new-api-key)
2. Or let the agent sign up via [docs.browser-use.com/llms.txt](https://docs.browser-use.com/llms.txt)
```python
# Set your key before starting daemon
import os
os.environ["BROWSER_USE_API_KEY"] = "your-key-here" # use env var, never hardcode
```
Or export in shell:
```bash
export BROWSER_USE_API_KEY=$BROWSER_USE_API_KEY
python daemon.py
```
---
## Domain Skills
Pre-learned skills for specific sites live in `domain-skills/`:
```
domain-skills/
github/
linkedin/
amazon/
...
```
Each skill teaches the agent site-specific selectors, flows, and edge cases. **Skills are written by the harness, not by you** — run your task, and when the agent figures out something non-obvious, it files the skill itself.
To use an existing skill, the agent reads it automatically when navigating to a matching domain. To contribute, open a PR with the generated `domain-skills/<site>/` folder.
---
## Setup Prompt (for Claude Code / Codex / Cursor)
Paste this to bootstrap the entire setup:
```text
Set up https://github.com/browser-use/browser-harness for me.
Read `install.md` first to install and connect this repo to my real browser.
Then read `SKILL.md` for normal usage. Always read `helpers.py` because that
is where the functions are. When you open a setup or verification tab, activate
it so I can see the active browser tab. After it is installed, if I am already
logged in to GitHub, star this repository as a small verification task; if I
am not logged in, just go to browser-use.com.
```
---
## Common Patterns
### Pattern: navigate and extract data
```python
navigate("https://news.ycombinator.com")
titles = evaluate("""
Array.from(document.querySelectorAll('.titleline > a'))
.map(a => a.textContent)
.slice(0, 10)
""")
print(titles)
```
### Pattern: wait and retry
```python
navigate("https://example.com/slow-page")
wait_for_selector(".data-table", timeout=10000)
rows = evaluate("""
Array.from(document.querySelectorAll('.data-table tr'))
.map(r => r.innerText)
""")
```
### Pattern: handle auth (already logged in)
```python
# The harness uses your real Chrome profile — cookies and sessions are live
navigate("https://github.com")
# If already logged in, your session is active immediately
click('a[href="/new"]')
```
### Pattern: agent writes a missing helper
```python
# Agent detects upload_file is missing, appends to helpers.py:
def upload_file(selector: str, path: str):
abs_path = os.path.abspath(path)
node_id = _get_node_id(selector)
_cdp("DOM.setFileInputFiles", {"files": [abs_path], "nodeId": node_id})
```
---
## Troubleshooting
### Daemon won't connect
- Confirm Chrome is running with `--remote-debugging-port=9222`
- Visit `http://localhost:9222/json` — you should see open tabs as JSON
- Make sure no other process owns port 9222
```bash
lsof -i :9222 # macOS/Linux
netstat -ano | findstr 9222 # Windows
```
### Helper function raises `AttributeError`
- Read `helpers.py` — the function may have been renamed or not yet written
- If missing, add it to `helpers.py` following the exiRelated in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.