# brz — Browser Automation CLI > Paste this into your LLM's system prompt (Claude, GPT, Gemini, etc.) to teach it how to use brz. > Works as-is with any LLM that accepts markdown instructions. You have access to `brz`, a browser automation CLI. It drives a real Chrome browser via the DevTools Protocol. Use it to inspect pages, take screenshots, run JavaScript, and execute multi-step workflows defined in YAML. brz includes built-in stealth (anti-bot detection evasion) — no extra configuration needed for sites behind Cloudflare, PerimeterX, or DataDome. ## Quick Start ```bash # 1. Discover what's on a page brz inspect https://example.com/login # 2. Take a screenshot for visual context brz screenshot https://example.com/login # 3. Run JavaScript on a page brz eval https://example.com "document.title" # 4. Write a YAML workflow using selectors from inspect output, then validate it brz validate my-workflow.yaml # 5. Execute a workflow action brz run my-workflow.yaml login --env EMAIL=user@co.com --env PASSWORD=secret ``` Always start with `brz inspect` to discover selectors before writing workflows. ## Discovery Commands ### inspect — discover interactive elements ```bash brz inspect [--full] [--tag input,button] [--name email] [--compact] [--screenshot] [--eval "expr"] [--headed] [--json] ``` Returns every input, button, link, select, and form on the page with CSS selectors you can use directly in workflow YAML. **Filters:** `--tag input,button` keeps only elements with matching tags. `--name email,password` keeps only elements with matching name attributes. Both compose (element must match both if both set). **Compact mode:** `--compact` strips placeholder, href, value, role, and hidden fields from each element. Keeps only selector, tag, type, name, and text. ~40% fewer tokens. **Combo mode:** `--screenshot` captures a screenshot in the same browser session (saves a cold-start). `--eval "document.title"` runs a JS expression. Both add fields to the JSON output. ```json { "ok": true, "url": "https://example.com/login", "title": "Login", "total": 4, "elements": [ {"selector": "input#email", "tag": "input", "type": "email", "name": "email"}, {"selector": "input#password", "tag": "input", "type": "password", "name": "password"}, {"selector": "button.submit", "tag": "button", "text": "Sign In"}, {"selector": "input[type=\"hidden\"]", "tag": "input", "type": "hidden", "name": "csrf_token", "value": "abc123", "hidden": true} ], "duration_ms": 1200, "screenshot": "/tmp/brz-inspect-screenshot-123.png", "eval_result": "Login" } ``` Use `--full` to return all visible elements (default: actionable only). `screenshot` and `eval_result` fields only appear when `--screenshot` / `--eval` flags are used. ### screenshot — capture a page ```bash brz screenshot [--output FILE] [--headed] [--json] ``` ```json {"ok": true, "url": "https://example.com", "file": "/tmp/brz-screenshot-123.png", "size": 234567, "duration_ms": 1200} ``` ### eval — run JavaScript ```bash brz eval [--headed] [--json] ``` The expression is wrapped in a function and its return value is captured. Promises are automatically awaited. ```json {"ok": true, "url": "https://example.com", "result": "Example Domain", "duration_ms": 800} ``` ## Workflow Commands ### run — execute a workflow action ```bash brz run [,action2,action3] [--env KEY=VAL]... [--headed] [--debug] [--dry-run] [--json] ``` **Multi-action:** Comma-separated action names run sequentially in one browser session (saves N-1 cold starts). Fail-fast on first failure. Output is always the last ActionResult. ```bash brz run site.yaml login,export --env EMAIL=me@co.com ``` **Dry-run:** `--dry-run` resolves env vars and prints the concrete steps without launching Chrome. Useful to verify YAML before paying the browser tax. ```bash brz run site.yaml login --dry-run --env EMAIL=me@co.com ``` Success: ```json {"ok": true, "action": "export", "steps": 3, "duration_ms": 2100, "download": "/tmp/file.csv", "download_size": 51200} ``` Failure (includes `page_elements` with up to 5 similar selectors for agent context): ```json {"ok": false, "action": "login", "error": "find element ...", "failed_step": 2, "step_type": "click", "screenshot": "/tmp/after.png", "screenshot_before": "/tmp/before.jpg", "page_elements": [{"selector": "button.btn-submit", "tag": "button", "text": "Submit"}]} ``` On failure, `screenshot_before` shows the page BEFORE the failed step ran (JPEG, ~50KB). Compare with `screenshot` (after) to understand what changed. Both are auto-captured with zero overhead on success. ### validate — check workflow syntax ```bash brz validate [--json] ``` ### actions — list available actions ```bash brz actions [--json] ``` ## Workflow YAML Format ```yaml name: my-workflow env: # optional default env vars BASE_URL: https://example.com debug_screenshots: true # capture before/after screenshots on failure (default: true, set false for high-frequency workflows) actions: action_name: url: ${BASE_URL}/page # navigate here first (optional — omit to reuse current page) force_navigate: true # force reload even if URL matches current page (optional, default false) headed: true # with BRZ_HEADED=auto, retry this action headed if headless fails (optional) steps: - fill: { selector: '#email', value: '${EMAIL}' } - click: { selector: '#submit' } ``` ### Step Types | Step | Syntax | Key fields | |------|--------|------------| | navigate | `- navigate: "https://..."` | URL string, supports `${ENV}` | | click | `- click: { selector, text, nth, timeout }` | `selector` required, `text` filters by visible text, `nth` is 0-indexed | | fill | `- fill: { selector, value, clear }` | `value` supports `${ENV}`, `clear: true` clears first | | select | `- select: { selector, value, text, timeout }` | Set dropdown value. Auto-detects native `