Skip to main content

browser-cli

CLI-first browser automation for AI agents

Repo • Features • Installation • Quick Start • Task And Automation Model • Testing


browser-cli is a browser automation tool for AI agents and developers who need reliable browser control from the command line.

Architecture

┌──────────────────────────────────────────────────────────────────────┐
│  Task/Automation Layer  (task.py + task.meta.json + automation.toml) │
├──────────────────────────────────────────────────────────────────────┤
│  Browser Daemon  ──►  60+ commands  ──►  Semantic Ref System         │
│  ├─ read: one-shot page capture                                      │
│  ├─ open/snapshot/click/fill: interactive control                    │
│  ├─ console/network/trace: observation & debugging                   │
│  ├─ verify-*: assertions                                             │
│  └─ ... 60+ commands total                                           │
├──────────────────────────────────────────────────────────────────────┤
│  Dual Backend: Managed Profile (Playwright) ◄──► Chrome Extension    │
└──────────────────────────────────────────────────────────────────────┘
Component Purpose
Browser Daemon Long-lived browser instance with daemon-backed CLI commands
Semantic Refs Stable element identifiers using bridgic-style reconstruction
Task Runtime Reusable task.py execution through browser_cli.task_runtime
Automation Service Persistent local service for published automation snapshots

Features

  • Dual Backend Architecture: managed profile mode by default, extension mode when real Chrome is connected and healthy
  • Semantic Ref System: stable refs that survive many DOM re-renders
  • Agent Isolation: X_AGENT_ID isolates visible tabs while sharing browser storage
  • JSON-First API: daemon-backed commands return structured JSON
  • Task Runtime: package browser logic as task.py + task.meta.json
  • Automation Publish Layer: publish immutable task snapshots and operate them through a local Web UI

Installation

Requirements:

  • Python 3.10+
  • uv
  • Stable Google Chrome

Install as a tool:

uv tool install browser-control-and-automation-cli
browser-cli doctor
browser-cli paths
browser-cli read https://example.com

The published package name is browser-control-and-automation-cli. The installed command remains browser-cli.

Run without installing:

uvx --from browser-control-and-automation-cli browser-cli read https://example.com

Install from Git:

uv tool install git+https://github.com/hongv/browser-cli.git
browser-cli --help

Installed users should start with docs/installed-with-uv.md. For removal and local cleanup guidance, see docs/uninstall.md.

Install Browser CLI Skills

Browser CLI ships with three packaged skills that can be installed into an agent skills directory:

  • browser-cli-converge
  • browser-cli-delivery
  • browser-cli-explore

Install them into the default skills root:

browser-cli install-skills

By default, Browser CLI writes the packaged skills into ~/.agents/skills. Use --dry-run to preview the install and --target to override the destination:

browser-cli install-skills --dry-run
browser-cli install-skills --target ~/.codex/skills

You can rerun the command safely. Existing packaged Browser CLI skills at the target path are replaced with the packaged versions from the installed wheel. After you upgrade Browser CLI, rerun browser-cli install-skills to refresh the copied skill files. If you use a custom skills root, rerun the command with the same --target path. For a longer installed-user walkthrough, see docs/install-skills.md.

Development

Clone the repository and sync the managed development environment:

git clone https://github.com/hongv/browser-cli.git
cd browser-cli
uv sync --dev

The CLI targets stable Google Chrome. Playwright Chromium is mainly useful for local integration testing and is installed through the repo environment.

Optional: Extension Mode

For real-Chrome execution:

  1. Open chrome://extensions
  2. Enable Developer mode
  3. Click Load unpacked
  4. Select browser-cli-extension/

Once connected, browser-cli status reports extension capability state and the daemon can prefer the extension backend at safe idle points.

Quick Start

If you installed Browser CLI with uv, use the dedicated installed-user guide at docs/installed-with-uv.md. The short version is:

browser-cli doctor
browser-cli paths
browser-cli read https://example.com

One-Shot Read

browser-cli read https://example.com
browser-cli read https://example.com --snapshot
browser-cli read https://example.com --scroll-bottom

Interactive Control

browser-cli open https://example.com
browser-cli snapshot
browser-cli click @8d4b03a9
browser-cli fill @input_ref "value"
browser-cli html
browser-cli status
browser-cli reload

Multi-Agent Tabs

X_AGENT_ID=agent-a browser-cli open https://example.com
X_AGENT_ID=agent-a browser-cli tabs

X_AGENT_ID=agent-b browser-cli open https://example.org
X_AGENT_ID=agent-b browser-cli tabs

Task And Automation Model

Browser CLI separates local authoring from durable publication:

  • task is local editable source
  • automation is a published immutable snapshot

Typical task layout:

tasks/
  my_task/
    task.py
    task.meta.json
    automation.toml

Discover the shipped examples or scaffold a new task bundle:

browser-cli task examples
browser-cli task template --output tasks/my_task

Validate and run a task directly:

browser-cli task validate tasks/my_task
browser-cli task run tasks/my_task --set url=https://example.com

Publish the current task directory into the automation service:

browser-cli automation publish tasks/my_task
browser-cli automation status
browser-cli automation ui

Publication semantics:

  • automation publish snapshots task.py, task.meta.json, and automation.toml together under ~/.browser-cli/automations/<automation-id>/versions/<version>/
  • if source automation.toml exists, Browser CLI uses it as the publish-time configuration truth
  • if source automation.toml is absent, Browser CLI publishes generated defaults and reports that explicitly via manifest_source

Export a persisted automation back to automation.toml:

browser-cli automation export my_task --output /tmp/my_task.automation.toml

Included examples:

Real-site publish example:

browser-cli task validate tasks/douyin_video_download
browser-cli automation publish tasks/douyin_video_download
browser-cli automation inspect douyin_video_download
browser-cli automation status

Inspect semantics:

  • browser-cli automation inspect <automation-id> shows the current live automation-service configuration
  • browser-cli automation inspect <automation-id> --version <n> shows snapshot_config for the immutable published version and live_config for the current service state
  • latest_run remains a separate operational view

Output Contracts

read

  • stdout: final rendered result only
  • stderr: diagnostics only

Exit codes:

  • 0: success
  • 1: unexpected internal error
  • 2: usage error
  • 66: empty content
  • 69: browser unavailable
  • 73: profile unavailable
  • 75: temporary read failure

Daemon-backed Commands

  • success stdout: JSON only
  • failure stderr: short error summary
  • stable machine-readable error codes include:
    • NO_ACTIVE_TAB
    • AGENT_ACTIVE_TAB_BUSY
    • TAB_NOT_FOUND
    • NO_SNAPSHOT_CONTEXT
    • REF_NOT_FOUND
    • STALE_SNAPSHOT
    • AMBIGUOUS_REF

Runtime Notes

  • Managed profile mode is the default backend.
  • Extension mode is the preferred real-Chrome backend when connected and healthy.
  • Driver rebinding happens only at safe idle points and is reported as state_reset.
  • runtime.timeout_seconds is the total wall-clock timeout for one automation run in the automation service.

Documentation

Testing

Run lint:

./scripts/lint.sh

Run tests:

./scripts/test.sh

Run guards:

./scripts/guard.sh

Run the full local validation flow:

./scripts/check.sh

If local version metadata looks stale after code changes, refresh the editable install before the validation flow:

uv sync --dev --reinstall-package browser-control-and-automation-cli

Fast Python 3.10 compatibility check:

uv run python scripts/guards/python_compatibility.py

When the runtime behaves unexpectedly, use:

browser-cli status
browser-cli reload
browser-cli status

The integration coverage is fixture-driven and local-first. It exercises:

  • navigation, tabs, and history
  • snapshot and rendered HTML capture
  • semantic ref reconstruction after DOM re-render
  • stale and ambiguous ref failures
  • iframe refs
  • ref-driven element actions
  • console, network, dialogs, trace, video, screenshot, and PDF
  • cookies, storage save/load, and X_AGENT_ID isolation
  • task runtime and automation publishing/service flows

Controlled captures and Node.js automation

Use browser-cli screenshot output.png --clip 0,120,800,600 --dpr 2 for a page rectangle, or add --viewport-width 1280 --viewport-height 720 for a temporary viewport that is restored after capture. Responses include actual image dimensions and capture geometry. Full-page captures preserve the current page viewport.

browser-cli batch --file commands.json --context-file context.json runs ordered actions in a disposable context with fixed viewport, DPR, CSS zoom, locale, timezone, and fonts. The context closes after success or failure. --result-mode last and --result-mode summary keep results compact.

A dependency-free Node.js client ships with the Python package; discover its ESM entrypoint and the actual daemon socket with browser-cli paths --json. status --json and doctor --json report service, extension, configuration, managed-profile, and output-directory health separately. Runtime status remains independent of filesystem permissions in the calling process.

See the capture and automation API guide for complete CLI and Node.js examples, JSON contracts, context defaults, and driver transitions.

Acknowledgements

This project is deeply inspired by bridgic-browser. Browser CLI keeps the semantic ref and daemon-backed strengths while pushing the product toward a CLI-first, agent-first surface with reusable task and automation layers.

Metadata

Release files for browser-control-and-automation-cli 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for browser-control-and-automation-cli 0.1.6
File Size Uploaded Provenance Actions
browser_control_and_automation_cli-0.1.6.tar.gz 631.8 kB Without provenance Details for browser_control_and_automation_cli-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for browser-control-and-automation-cli 0.1.6
File Interpreter ABI Platform Actions
browser_control_and_automation_cli-0.1.6-py3-none-any.whl Python 3 none any Details for browser_control_and_automation_cli-0.1.6-py3-none-any.whl

Total release size: 819.1 kB

Release files / browser_control_and_automation_cli-0.1.6.tar.gz

Download URL browser_control_and_automation_cli-0.1.6.tar.gz
Size 631.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d0a06afaf8ae56cf84b145da41511ec3bcd6cc2aad42c84d432a2f84edb3b7fb
BLAKE2b-256 checksum
How to use checksums
6c658082fcda2827174ea37bbe3f385b8f2153e829e3546b9b29dce897416dfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / browser_control_and_automation_cli-0.1.6-py3-none-any.whl

Download URL browser_control_and_automation_cli-0.1.6-py3-none-any.whl
Size 187.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
431c46a54550e92c629af702b9bf3c3e8caec52624195f927a1b2b181637f6de
BLAKE2b-256 checksum
How to use checksums
70cf94df52dc28f512b9bee1103dbd2234481cbdf3a09927c108a8b0d305b517
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for browser-control-and-automation-cli 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page