Skip to main content

BAP CLI

CLI-first browser automation from the command line. BAP defaults to installed Chrome, an auto-detected profile when available, and a persistent daemon so agents can work against a real browser instead of starting fresh every time.

Install

npm i -g @browseragentprotocol/cli
Requires Node.js 20+ and Playwright browsers. Install browsers with npx playwright install chromium.

30-Second Demo

1

Navigate to a page

bap goto https://example.com --observe
The --observe flag fuses navigation and observation into a single server call, returning interactive elements with stable refs.
2

Click an element

bash bap click role:button:"Get Started" Semantic selectors target elements by purpose, not DOM position. They survive redesigns.
3

Fill a form with composite actions

bap act fill:label:"Email"="user@example.com" \ fill:label:"Password"="secret" \
click:role:button:"Sign in" ``` Three steps, one command, one server call. Fewer tokens, fewer
roundtrips.
</Step>

<Step title="Extract structured data">
  ```bash
  bap extract --fields="title,price,rating"
Returns validated JSON output.

Architecture

bap <command>
    | WebSocket (JSON-RPC 2.0)
BAP Playwright Server (auto-started as background daemon)
    | Playwright
Browser (Chromium / Firefox / WebKit)
The server starts automatically on first use and persists across commands. No manual setup needed.
Use bap close-all to stop the daemon and shut down all browser sessions.

Why BAP CLI?

Composite Actions

Execute multi-step flows in one command instead of one-at-a-time. A login flow is 1 bap act, not 3 separate fill/click calls.

Semantic Selectors

Target elements by ARIA role, visible text, label, or placeholder. Selectors survive DOM changes and redesigns.

Structured Extraction

Extract validated JSON from pages using field names, JSON Schema, or list mode. No HTML parsing needed.

Composite Actions vs playwright-cli

# playwright-cli: 3 commands, 3 snapshots, 3 LLM reasoning cycles
playwright-cli fill e5 "user@example.com"
playwright-cli fill e8 "password123"
playwright-cli click e12

# bap: 1 command, 1 snapshot, 1 LLM reasoning cycle
bap act fill:e5="user@example.com" fill:e8="password123" click:e12

Migrating from playwright-cli

BAP is a drop-in replacement. All e<N> refs from snapshots work identically:
playwright-clibap
playwright-cli open [url]bap open [url]
playwright-cli click e15bap click e15
playwright-cli fill e5 "text"bap fill e5 "text"
playwright-cli snapshotbap snapshot
playwright-cli screenshotbap screenshot
BAP adds composite actions, semantic selectors, smart observation, and structured extraction on top.

Output

Commands produce concise, AI-agent-friendly output. Files are saved to .bap/ in the current directory:
  • Snapshots: .bap/snapshot-<timestamp>.yml
  • Screenshots: .bap/screenshot-<timestamp>.png
  • Extractions: .bap/extraction-<timestamp>.json

Command Overview

CategoryCommands
Essentialsgoto, observe, act, extract, screenshot
Actionsclick, fill, type, press, select, check/uncheck, hover, scroll
Navigationopen, back, forward, reload, close, close-all
Observationobserve, snapshot
Sessions & Tabssessions, tabs, tab-new, tab-select, frames, frame-switch
Workflowsworkflow record/stop/run/list, run
Debuggingwatch, trace, demo, plan
Configurationconfig, install-skill, skill