English | Português Brasileiro
browser-automation-cli
One-shot Chrome CDP automation for AI agents. BORN, EXECUTE, FINALIZE, DIE.
What is it
- Single-process browser automation CLI for AI agents
- Talks to system Chrome or Chromium through chromiumoxide CDP
- No daemon, no npm packaging, no remote telemetry
- Lifecycle is always BORN, EXECUTE, FINALIZE, DIE
- JSON envelopes on stdout for programmatic agents
- XDG config and paths via
configcommands only
The Pain
- Agent workflows need multi-step browser work without a sticky daemon
- Node and npm browser stacks add runtime weight and supply-chain surface
- Session-based tools leave orphan Chrome processes and unclear ownership
- JSON contracts often drift from real CLI flags and exit codes
- Product settings outside XDG
configmake agent prompts fragile
Why browser-automation-cli
- One process owns one Chrome lifecycle from launch to kill fallback
- Multi-step work uses
run --scriptNDJSON or a JSON array of steps in the same process - Accessibility snapshot refs
@eNstay valid only inside that process --jsonenvelopes are stable for programmatic agents; clap usage errors also emit JSON when--jsonis on argv- Install path is pure Rust via cargo
- v0.1.4 hard-closes GAP-001…025:
run --json-steps, wait multi-selector/url,select-option/pickrun cmds, assert console kinds,schema <cmd>positional, MITMcapture-url+ global--mitm*, multi-format scrape, batch/crawl--engine browser, and residual-zero honesty from 0.1.3
Superpowers
- Navigation and page lifecycle:
goto(init-script, beforeunload accept|dismiss),back,forward,reload,page - Input:
press,write,type,keys,hover,drag,fill-form,upload - Multi-step only (run/schema inventory):
select-option,pickfor HIG badge/popover /role=option(not standalone clap subcommands) - Observation:
view(refuses empty about:blank unless--allow-empty),grab,extract,text,attr,scroll,assert - Wait: multi
--textOR; CSS multi-selector OR (#a, #b); run fieldsurl/url_contains/navigation - Assert:
url/text/consoleplusconsole_empty/console_no_match(CLIconsole-empty/console-no-match) - Scrape: multi-format
--format(CSV or repeatable) with--engine http|browser; browser applies formats via outerHTML - Local scrape/crawl/map/search/parse:
batch-scrapeandcrawlaccept--engine http|browser,map,search(cleansuddg=),parse(PDF/DOCX/xlsx/ods +--redact-pii) - Extract LLM:
extract --llm --question --schema-json(XDGopenrouter_api_key,llm_base_url,llm_model) - Capture:
console(dump always writes[]when empty) andnetwith optional global capture flags - DevTools depth:
eval,emulate,resize,perf,lighthouse(flag → XDG → PATH;binary_sourcereal|mock),heap - PDF print:
print-pdfone-shot and multi-steprun; refuses blank PDF without navigated content - Monitor:
monitor check --url --baseline [--write-baseline] - Utilities (no Chrome):
qr encode|decode,find-paths(--glob),sheet-write,sg-scan,sg-rewrite - Assert aliases:
url_contains/text_contains;attrfalls back to DOM properties - Scroll aliases in
run:dy/dxfordelta_y/delta_x - Optional categories: memory, extensions, third-party, webmcp
- Experimental: vision
click-at, screencast with ffmpeg export - MITM one-shot:
status|list|get|har|export|domains|apis|init-ca|start|capture-url|graphql|ws|block|allow|redact(binds127.0.0.1; global--mitm*) - Workflow DAG:
workflow run|resume|statuswith SQLite journal (resume skips ok) - XDG config:
config path|init|show|set|get|list-keysfor config.toml - Discovery:
doctor,commands(61 agent names),schema <cmd>orschema --cmd,completions - Multi-step observability:
run --jsonfinal envelope includesok+ fullsteps[].data; global--json-stepsstreams one NDJSON line per step - Fail-fast multi-step:
runreturns partialdata.stepson error envelopes - Lifecycle: FINALIZE scavenges owned Chromium
/tmporphans; residual e2e is residual-zero honest - Cache: XDG
cache_backend(sqlite|memory|redis) andcache_redis_url;rediss://fail-closed
Quick Start
Installation
- Local development install:
- From crates.io after the first publish:
- Runtime needs Chrome or Chromium on the shell path (or
config set chrome_path) - Optional:
ffmpegfor screencast file export - Optional:
lighthousebinary for lighthouse audits (orconfig set lighthouse_path)
Usage
- Always pass
--jsonfor agent pipelines - Keep human diagnostics on stderr with
-qwhen piping - Use
--timeoutfor wall-clock process budget in seconds - Use
run --script(NDJSON lines or a JSON array of steps) for multi-step sessions that need shared@eNrefs - Stream per-step progress with global
--json-steps(NDJSON lines:step,cmd,ok,result) - Prefer CLI flags for one-off agent calls; use
configfor durable XDG defaults - Logging detail:
--verbose/--debug/-q, orconfig set log_level - Localize human suggestions with
--lang pt-BRorconfig set lang pt-BR - Optional scrape
--webhook-urlposts the result once to an operator URL (not product telemetry) - Optional MITM: global
--mitm,--mitm-ca-dir,--mitm-har,--mitm-hosts,--mitm-ws,--mitm-max-body-bytes,--mitm-no-media-bodies,--mitm-redact-secrets
Commands
- Discovery:
doctor,commands,schema,version,completions - Config:
config path,config init,config show,config set,config get,config list-keys - Navigate:
goto,back,forward,reload - Snapshot and input:
view,press,write,type,keys,wait,hover,drag,fill-form,upload - Multi-step / schema inventory only:
select-option,pick(not standalone clap subcommands; use insiderun/exec/ schema discovery) - Content:
extract,text,scroll,attr,assert,grab - Scrape and discovery:
scrape,batch-scrape,crawl,map,search,parse - PDF and monitor:
print-pdf,monitor - Utilities:
qr,find-paths,sheet-write,sg-scan,sg-rewrite - Tabs and dialogs:
page,dialog,cookie - Capture:
console,net - MITM:
mitm status|list|get|har|export|domains|apis|init-ca|start|capture-url|graphql|ws|block|allow|redact - Workflow:
workflow run|resume|status - Advanced:
eval,emulate,resize,perf,lighthouse,screencast,heap - Categories:
extension,devtools3p,webmcp - Multi-step:
run,exec - Inventory: 61 agent-facing names via
commands --json(includesselect-optionandpick); clap top-level help lists 59 without those two as standalone subcommands; DevTools e2e covers 53 tools
Configuration
- Prefer CLI flags for one-off agent calls
- Use
config path|init|show|set|get|list-keysfor XDG config.toml - Product settings only via flags and
config set(XDG) - Logging:
--verbose/--debug/-q, or XDGconfig set log_level/log_to_file - Color:
config set color true|false - Chrome binary: shell path or XDG
config set chrome_path - Lighthouse binary: flag
--lighthouse-path, XDGconfig set lighthouse_path, or PATH (envelope reportsbinary_source) - Cache:
config set cache_backend sqlite|memory|redisand optionalcache_redis_url(redis://only;rediss://fail-closed) - Config keys (16):
lang,timeout,artifacts_dir,ignore_robots,namespace,encryption_key,color,log_level,log_to_file,chrome_path,lighthouse_path,openrouter_api_key,llm_base_url,llm_model,cache_backend,cache_redis_url config initcreates XDG layout and default config.tomlconfig pathprints resolved config, data, cache, state, and browsers_dir pathsconfig list-keyslists every supported key with defaults- CLI flags override values stored in config.toml
- Doctor reports browsers_dir, lighthouse source, and
cache_redisamong readiness checks
Features
- This crate has no Cargo feature flags
- Optional categories are process flags, not compile-time features
--category-memoryenables deep heap tools--category-extensionsenables extension tools--category-third-partyenables third-party DevTools helpers--category-webmcpenables webmcp tools--experimental-visionenablesclick-at--experimental-screencastenables screencast export with ffmpeg
Targets
- Documented for
x86_64-unknown-linux-gnu - Documented for
x86_64-apple-darwin - Documented for
aarch64-apple-darwin - Documented for
x86_64-pc-windows-msvc - Documented for
aarch64-unknown-linux-musl - Not supported on
wasm32-unknown-unknown(Chrome CDP requires a desktop browser) - docs.rs metadata declares these targets explicitly after the 2026-05-01 multi-target change
MSRV
- Minimum Supported Rust Version is 1.88.0
- Policy: bump MSRV only in minor or major releases with CHANGELOG note
- Local docs:
timeout 180 cargo doc --no-deps
Integration Patterns
- Claude Code, Codex, Cursor, and shell agents spawn one process per action
- Multi-step agent plans must use
run --script(NDJSON or JSON array) instead of chaining separate processes - Parse stdout with
jaqand ignore stderr unless diagnosing failures - Stream step progress with
--json-stepswhen agents need progressive feedback - Persist durable defaults with
config setunder XDG - See INTEGRATIONS.md and docs/AGENTS.md
Performance
- Cold start is dominated by Chrome launch, not Rust binary size
- Prefer
doctor --offline --quickfor install checks without network - Reuse multi-step scripts to avoid repeated Chrome launches
- Prefer
scrape --engine httpwhen CDP is not required - Use
batch-scrapeconcurrency for parallel fetches (--engine httpdefault;--engine browserwhen JS render is required)
Memory Requirements
- Expect Chrome process memory far above the CLI binary itself
- Heap tools need
--category-memoryand larger snapshots increase RAM use - Screencast export may invoke ffmpeg as an external helper
- Workflow journals and MITM captures land under XDG state/data paths
Troubleshooting FAQ
- Chrome not found: install Chromium or Google Chrome, ensure it is on the shell path, or
config set chrome_path, then re-rundoctor - Config / XDG: run
config initthenconfig pathto inspect layout; useconfig set|getfor values - Product settings only via flags and
config set(XDG) - Exit 69 unavailable: browser binary missing, blocked, or not launchable
- Exit 124 timeout: raise
--timeoutor shorten the script - Exit 2 usage: re-check flags with
browser-automation-cli help <cmd>; with--jsonon argv, clap usage errors emit JSON envelopes @eNrefs invalid across commands: keep steps inside onerunprocess; refs do not span processes- Network empty: pass
--capture-networkon the same process that navigates - Wait multi-text: repeat
--textfor OR semantics (any listed text unblocks) - Wait multi-selector / URL: CSS OR
#a, #b; inrunuseurl/url_contains/navigation - View empty blank: empty about:blank refuses silent success unless
--allow-empty/allow_empty:true - MITM bind:
mitm startandmitm capture-urllisten on127.0.0.1only with an ephemeral port - MITM HAR:
mitm har --out <path>(required); or global--mitm-haron FINALIZE; orcapture-url --har - MITM redact:
mitm redact --secretsand global--mitm-redact-secrets; CA under XDG data - Workflow resume:
workflow resumeskips steps alreadyokin the journal - Scrape multi-format:
--format markdown,html,links(CSV or repeatable) returns per-format fields - Scrape browser formats:
--engine browserapplies--formatvia outerHTML - Batch/crawl browser engine:
batch-scrape --engine browserandcrawl --engine browser(GAP-010) - Scroll aliases: in
runscripts usedy/dxas aliases fordelta_y/delta_x - Schema discovery:
schema runorschema --cmd run; expanded fragments for goto/eval/type/scroll/assert/wait - Lang:
--lang pt-BRorconfig set lang pt-BRlocalizes human suggestions - Fail-fast partial steps: failed
runerror envelopes may include partialdata.steps - JSON steps stream:
--json-stepsemits one NDJSON object per step; final--jsonenvelope still includes fullsteps[] - Lighthouse path: flag,
config set lighthouse_path, or PATH; envelopebinary_sourceisrealormock(mock is e2e-only honesty, not production) - Search redirects:
searchcleansuddg=wrappers to destination URLs - Parse documents:
parsesupports PDF/DOCX/xlsx/ods and--redact-pii - Extract LLM: requires XDG
openrouter_api_key(optionalllm_base_url,llm_model) - Print PDF:
print-pdf --url <url> --path <file>one-shot CDP; also valid insiderun - Monitor baseline:
monitor check --url <url> --baseline <file> [--write-baseline] - Assert console:
assert console-empty/assert console-no-match --pattern …(needs--capture-console) - Assert aliases:
url_contains/text_contains;attruses DOM property fallback when HTML attribute is null - Pick / select-option: only inside
run/exec({"cmd":"pick","target":"…","option":"…"}); not clap standalone - Inventory size:
commands --jsonlists 61 agent names; clap top-level is 59 withoutselect-option/pickas standalone file://+scrape --engine http: Usage error — use browser engine orparsefor local filesreload --ignore-cache: CDPPage.reloadwithignoreCache(not a JS no-op)runscript formats: NDJSON one object per line, or a single JSON array of steps- Redis cache: set
cache_backend redisandcache_redis_url; never userediss:// - Residual /tmp: FINALIZE scavenges owned Chromium singletons; e2e residual assert is residual-zero
- Sheet/lint utils:
sheet-write,sg-scan,sg-rewrite;find-paths --globfor shell globs - Dialog soft path:
dialog accept --if-present/ runif_present:truesoft-ok when no dialog is showing
Exit Codes
0success2usage or clap parse failure65data error66no input69unavailable70software, browser, or protocol failure74I/O failure78config error124timeout130cancelled by SIGINT141broken pipe255unexpected fatal path
Documentation Map
- docs/HOW_TO_USE.md first command in 60 seconds
- docs/AGENTS.md agent integration contract
- docs/COOKBOOK.md practical recipes
- docs/CROSS_PLATFORM.md platform matrix
- docs/MIGRATION.md version migration notes
- docs/TESTING.md test categories
- docs/schemas/README.md JSON schema index
- skills/browser-automation-cli-en/SKILL.md imperative agent skill
- CHANGELOG.md Keep a Changelog history
- SECURITY.md vulnerability reporting
- CONTRIBUTING.md contributor workflow
- CODE_OF_CONDUCT.md Contributor Covenant 2.1
- llms.txt short LLM discovery map
Contributing
- Read CONTRIBUTING.md before opening a PR
- Follow the Code of Conduct in CODE_OF_CONDUCT.md
Security
- Report vulnerabilities privately via SECURITY.md
- Maintainer contact: daniloaguiarbr@proton.me
Changelog
- Version history lives only in CHANGELOG.md
License
- Dual licensed under MIT OR Apache-2.0
- See LICENSE, LICENSE-MIT, and LICENSE-APACHE