domains / agent-tooling / browser-automation / agent-browser

agent-browser

Skill card

combined

The copies share the same core agent-browser CLI workflow (open, snapshot -i, interact via @refs, re-snapshot), but each adds material steps or constraints the others lack. am-will/codex-skills adds real Chrome profile/CDP reuse and headed manual login for OAuth. LeoYeAI/openclaw-master-skills adds video recording, browser settings (viewport/device/geo/offline/headers/credentials/media), and more complete cookies/storage commands. brycewang-stanford/Auto-Empirical-Research-Skills adds command chaining guidance, state save/load with encryption, session management, and connecting to an existing Chrome instance. FreedomIntelligence/OpenClaw-Medical-Skills is a shorter variant with similar core commands but lacks the unique additions above. Crowning one copy would hide real alternatives for authentication, recording, state persistence, and chaining.

Repositories

RepositoryPath
am-will/codex-skillsskills/agent-browser/SKILL.md
LeoYeAI/openclaw-master-skillsskills/agent-browser/SKILL.md
brycewang-stanford/Auto-Empirical-Research-Skillsskills/67-econfin-workflow-toolkit/agent-browser/SKILL.md
FreedomIntelligence/OpenClaw-Medical-Skillsskills/agent-browser/SKILL.md

Other copies

RoleRepositoryPath
peeram-will/codex-skillsskills/agent-browser/SKILL.md
peerLeoYeAI/openclaw-master-skillsskills/agent-browser/SKILL.md
peerbrycewang-stanford/Auto-Empirical-Research-Skillsskills/67-econfin-workflow-toolkit/agent-browser/SKILL.md
peerFreedomIntelligence/OpenClaw-Medical-Skillsskills/agent-browser/SKILL.md
adapterLeoYeAI/openclaw-master-skillsskills/crab/agent-browser/SKILL.md

Combined skill

# Browser Automation with agent-browser

## Core Workflow

1. Navigate: `agent-browser open <url>`
2. Snapshot: `agent-browser snapshot -i` (returns elements with refs like `@e1`, `@e2`)
3. Interact using refs from the snapshot
4. Re-snapshot after navigation or significant DOM changes

## Command Chaining

Commands can be chained with `&&` in a single shell invocation. The browser persists between commands via a background daemon, so chaining is safe and more efficient than separate calls.

```bash
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
```

**When to chain:** Use `&&` when you don't need to read the output of an intermediate command before proceeding. Run commands separately when you need to parse the output first (e.g., snapshot to discover refs, then interact using those refs).

## Essential Commands

### Navigation

```bash
agent-browser open <url>              # Navigate (aliases: goto, navigate)
agent-browser back                    # Go back
agent-browser forward                 # Go forward
agent-browser reload                  # Reload page
agent-browser close                   # Close browser
```

### Snapshot (page analysis)

```bash
agent-browser snapshot            # Full accessibility tree
agent-browser snapshot -i         # Interactive elements only (recommended)
agent-browser snapshot -c         # Compact output
agent-browser snapshot -d 3       # Limit depth to 3
agent-browser snapshot -s "#main" # Scope to CSS selector
agent-browser snapshot -i -C      # Include cursor-interactive elements
```

### Interactions (use @refs from snapshot)

```bash
agent-browser click @e1           # Click
agent-browser click @e1 --new-tab # Click and open in new tab
agent-browser dblclick @e1        # Double-click
agent-browser focus @e1           # Focus element
agent-browser fill @e2 "text"     # Clear and type
agent-browser type @e2 "text"     # Type without clearing
agent-browser clear @e2           # Clear input
agent-browser press Enter         # Press key
agent-browser press Control+a     # Key combination
agent-browser keydown Shift       # Hold key down
agent-browser keyup Shift         # Release key
agent-browser hover @e1           # Hover
agent-browser check @e1           # Check checkbox
agent-browser uncheck @e1         # Uncheck checkbox
agent-browser select @e1 "value"  # Select dropdown option
agent-browser scroll down 500     # Scroll page
agent-browser scrollintoview @e1  # Scroll element into view
agent-browser drag @e1 @e2        # Drag and drop
agent-browser upload @e1 file.pdf # Upload files
```

### Get information

```bash
agent-browser get text @e1        # Get element text
agent-browser get html @e1        # Get innerHTML
agent-browser get value @e1       # Get input value
agent-browser get attr @e1 href   # Get attribute
agent-browser get title           # Get page title
agent-browser get url             # Get current URL
agent-browser get count ".item"   # Count matching elements
agent-browser get box @e1         # Get bounding box
```

### Check state

```bash
agent-browser is visible @e1      # Check if visible
agent-browser is enabled @e1      # Check if enabled
agent-browser is checked @e1      # Check if checked
```

### Screenshots & PDF

```bash
agent-browser screenshot          # Screenshot to temp dir
agent-browser screenshot path.png # Save to file
agent-browser screenshot --full   # Full page
agent-browser pdf output.pdf      # Save as PDF
```

### Video recording

```bash
agent-browser record start ./demo.webm    # Start recording
agent-browser click @e1                   # Perform actions
agent-browser record stop                 # Stop and save video
agent-browser record restart ./take2.webm # Stop current + start new recording
```

Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it automatically returns to your current page. For smooth demos, explore first, then start recording.

### Wait

```bash
agent-browser wait @e1                     # Wait for element
agent-browser wait 2000                    # Wait milliseconds
agent-browser wait --text "Success"        # Wait for text
agent-browser wait --url "**/dashboard"    # Wait for URL pattern
agent-browser wait --load networkidle      # Wait for network idle
agent-browser wait --fn "window.ready"     # Wait for JS condition
```

### Mouse control

```bash
agent-browser mouse move 100 200      # Move mouse
agent-browser mouse down left         # Press button
agent-browser mouse up left           # Release button
agent-browser mouse wheel 100         # Scroll wheel
```

### Semantic locators (alternative to refs)

```bash
agent-browser find role button click --name "Submit"
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find placeholder "Search" type "query"
agent-browser find first ".item" click
agent-browser find nth 2 "a" text
```

### Browser settings

```bash
agent-browser set viewport 1920 1080      # Set viewport size
agent-browser set device "iPhone 14"      # Emulate device
agent-browser set geo 37.7749 -122.4194   # Set geolocation
agent-browser set offline on              # Toggle offline mode
agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
agent-browser set credentials user pass   # HTTP basic auth
agent-browser set media dark              # Emulate color scheme
```

### Cookies & Storage

```bash
agent-browser cookies                     # Get all cookies
agent-browser cookies set name value      # Set cookie
agent-browser cookies clear               # Clear cookies
agent-browser storage local               # Get all localStorage
agent-browser storage local key           # Get specific key
agent-browser storage local set k v       # Set value
```

### JavaScript

```bash
agent-browser eval "document.title"   # Run JavaScript
```

## Authentication and State Persistence

### Method 1: State save/load

```bash
# Login once and save state
agent-browser open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "$USERNAME"
agent-browser fill @e2 "$PASSWORD"
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser state save auth.json

# Reuse in future sessions
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard
```

### Method 2: Session persistence with auto-save

```bash
# Auto-save/restore cookies and localStorage across browser restarts
agent-browser --session-name myapp open https://app.example.com/login
# ... login flow ...
agent-browser close  # State auto-saved to ~/.agent-browser/sessions/

# Next time, state is auto-loaded
agent-browser --session-name myapp open https://app.example.com/dashboard

# Encrypt state at rest
export AGENT_BROWSER_ENCRYPTION_KEY=$(openssl rand -hex 32)
agent-browser --session-name secure open https://app.example.com

# Manage saved states
agent-browser state list
agent-browser state show myapp-default.json
agent-browser state clear myapp
agent-browser state clean --older-than 7
```

### Method 3: Connect to existing Chrome (CDP)

```bash
# Auto-discover running Chrome with remote debugging enabled
agent-browser --auto-connect open https://example.com

# Or connect to a specific port
agent-browser --cdp 9222 open "https://example.com"
agent-browser --cdp 9222 snapshot -i
agent-browser --cdp 9222 click @e2
```

### Method 4: Headed manual login (first-time)

```bash
# First time: headed mode, login manually
agent-browser --headed --session myapp open "https://app.example.com/login"
# Complete OAuth manually in the browser window
# Close when done

# Future runs: cookies persist!
agent-browser --session myapp open "https://app.example.com/dashboard"
```

## Parallel Sessions

```bash
agent-browser --session site1 open https://site-a.com
agent-browser --session site2 open https://site-b.com

agent-browser --session site1 snapshot -i
agent-browser --session site2 snapshot -i

agent-browser session list
```

## Agent Mode

Use `--json` for machine readable output.

```bash
agent-browser snapshot --json
agent-browser get text @e1 --json
```

### Optimal AI Workflow

- Navigate with `agent-browser open <url>`
- Observe with `agent-browser snapshot -i --json`
- Act with @ref from the snapshot
- Verify with `agent-browser snapshot`

## Troubleshooting

- If the command is not found on Linux ARM64, use the full path in the bin folder.
- If an element is not found, use snapshot to find the correct ref.
- If the page is not loaded, add a wait command after navigation.
- Use `--headed` to see the browser window for debugging.

## Options

- `--session <name>` uses an isolated session.
- `--json` provides JSON output.
- `--full` takes a full page screenshot.
- `--headed` shows the browser window.
- `--timeout` sets the command timeout in milliseconds.
- `--cdp <port>` connects to an existing Chrome instance.
- `--auto-connect` auto-discovers a running Chrome with remote debugging.

## Notes

- Refs are stable per page load but change on navigation.
- Always snapshot after navigation to get new refs.
- Use `fill` instead of `type` for input fields to ensure existing text is cleared.