> ## Documentation Index
> Fetch the complete documentation index at: https://piyushvyas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Quickstart

> Install the BAP CLI and run your first browser commands

The BAP CLI lets AI coding agents automate browsers from the shell. It defaults to installed Chrome, keeps a persistent daemon running, and supports composite actions that batch multiple steps into one command.

## Installation

<Steps>
  <Step title="Install the CLI globally">
    ```bash theme={null}
    npm i -g @browseragentprotocol/cli
    ```

    Or run without installing:

    ```bash theme={null}
    npx @browseragentprotocol/cli goto https://example.com
    ```
  </Step>

  <Step title="Install Playwright browsers (if needed)">
    BAP prefers your installed Chrome. If Chrome is not available: `bash npx playwright install
          chromium `
  </Step>

  <Step title="Install the skill file for your AI agent">
    `bash bap install-skill ` This auto-detects 13 AI agent platforms (Claude Code, Codex CLI,
    Gemini CLI, Cursor, GitHub Copilot, Windsurf, Roo Code, and more) and installs the SKILL.md
    guidance file.
  </Step>

  <Step title="Run the guided demo">
    ```bash theme={null}
    bap demo
    ```

    Walks you through navigate, observe, click, and screenshot step by step.
  </Step>
</Steps>

## First Commands

```bash theme={null}
# Open a page and observe interactive elements
bap goto https://example.com --observe

# Click a link by visible text
bap click text:"More information..."

# Take a screenshot
bap screenshot
```

<Tip>
  The BAP server starts automatically on first use and stays running as a background daemon. Use
  `bap close-all` to stop it.
</Tip>

## Composite Actions

The killer feature of BAP CLI is `bap act` -- batch multiple browser steps in one command:

<CodeGroup>
  ```bash Single command (BAP) theme={null}
  bap act fill:label:"Email"="user@example.com" \
          fill:label:"Password"="secret123" \
          click:role:button:"Sign in"
  ```

  ```bash Three commands (traditional) theme={null}
  bap fill label:"Email" "user@example.com"
  bap fill label:"Password" "secret123"
  bap click role:button:"Sign in"
  ```
</CodeGroup>

Step syntax: `action:selector=value` for fill/type, `action:selector` for click/check/hover.

## Observation

```bash theme={null}
# Interactive elements (default max 50)
bap observe

# Full accessibility tree
bap observe --full

# Form fields only
bap observe --forms

# Incremental: only changes since last observation
bap observe --diff

# Minimal response (fewer tokens)
bap observe --tier=minimal
```

## Fused Operations

Combine navigation or actions with observation in a single server call:

```bash theme={null}
# Navigate + observe in one roundtrip
bap goto https://example.com --observe

# Act + observe in one roundtrip
bap act click:text:"Next" --observe

# Act + observe with minimal response tier
bap act click:e3 --observe --tier=interactive
```

## Structured Extraction

```bash theme={null}
# Extract specific fields
bap extract --fields="title,price,rating"

# Extract a list of items
bap extract --list="product"

# Extract using a JSON schema
bap extract --schema=product.json
```

## Sessions and Tabs

```bash theme={null}
# Named sessions (persist across commands)
bap -s=research goto https://example.com
bap -s=shopping goto https://store.com

# List sessions and tabs
bap sessions
bap tabs

# Tab management
bap tab-new https://other.com
bap tab-select 2
```

## Global Options

```
-s=<name>              Named session
-p, --port <N>         Server port (default: 9222)
-b, --browser <name>   chrome, chromium, firefox, webkit, edge
--headless             Headless mode for CI/background runs
--no-headless          Show browser window (default)
--profile <path>       Chrome profile directory
--no-profile           Fresh browser, no user profile
--stealth              Reduce bot detection fingerprint
--connect              Auto-attach to running Chrome via CDP
-v, --verbose          Verbose output
```

## Output

Commands produce concise, agent-friendly stdout:

```
### Page
- URL: https://example.com/dashboard
- Title: Dashboard
### Snapshot
[Snapshot](.bap/snapshot-2026-02-16T19-30-42.yml)
```

Files are saved to `.bap/` in the current directory: snapshots (`.yml`), screenshots (`.png`), extractions (`.json`).

## Migrating from playwright-cli

BAP is a drop-in replacement. All `e<N>` refs from snapshots work identically:

| playwright-cli                  | bap                  |
| ------------------------------- | -------------------- |
| `playwright-cli open [url]`     | `bap open [url]`     |
| `playwright-cli click e15`      | `bap click e15`      |
| `playwright-cli fill e5 "text"` | `bap fill e5 "text"` |
| `playwright-cli snapshot`       | `bap snapshot`       |
| `playwright-cli screenshot`     | `bap screenshot`     |

BAP adds composite actions, semantic selectors, smart observation, and structured extraction on top.
