agent-browser - Browser Automation for AI Agents
When to use this skill
- Open websites and automate UI actions
- Fill forms, click controls, and verify outcomes
- Capture screenshots/PDFs or extract content
- Run deterministic web checks with accessibility refs
- Execute parallel browser tasks via isolated sessions
Core workflow
Always use the deterministic ref loop:
agent-browser open <url>
agent-browser snapshot -i
- interact with refs (
@e1, @e2, ...)
agent-browser snapshot -i again after page/DOM changes
agent-browser open https://example.com/form
agent-browser wait --load networkidle
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser click @e2
agent-browser snapshot -i
Command patterns
Use && chaining when intermediate output is not needed.
# Good chaining: open -> wait -> snapshot
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
# Separate calls when output is needed first
agent-browser snapshot -i
# parse refs
agent-browser click @e2
High-value commands:
- Navigation:
open, close
- Snapshot:
snapshot -i, snapshot -i -C, snapshot -s "#selector"
- Interaction:
click, fill, type, select, check, press
- Verification:
diff snapshot, diff screenshot --baseline <file>
- Capture:
screenshot, screenshot --annotate, pdf
- Wait:
wait --load networkidle, wait <selector|@ref|ms>
Verification patterns
Use explicit evidence after actions.
# Baseline -> action -> verify structure
agent-browser snapshot -i
agent-browser click @e3
agent-browser diff snapshot
# Visual regression
agent-browser screenshot baseline.png
agent-browser click @e5
agent-browser diff screenshot --baseline baseline.png
Safety and reliability
- Refs are invalid after navigation or significant DOM updates; re-snapshot before next action.
- Prefer
wait --load networkidle or selector/ref waits over fixed sleeps.
- For multi-step JS, use
eval --stdin (or base64) to avoid shell escaping breakage.
- For concurrent tasks, isolate with
--session <name>.
- Use output controls in long pages to reduce context flooding.
- Optional hardening in sensitive flows: domain allowlist and action policies.
Optional hardening examples:
# Wrap page content with boundaries to reduce prompt-injection risk
export AGENT_BROWSER_CONTENT_BOUNDARIES=1
# Limit output volume for long pages
export AGENT_BROWSER_MAX_OUTPUT=50000
# Restrict navigation and network to trusted domains
export AGENT_BROWSER_ALLOWED_DOMAINS="example.com,*.example.com"
# Restrict allowed action types
export AGENT_BROWSER_ACTION_POLICY=./policy.json
Example policy.json:
{"default":"deny","allow":["navigate","snapshot","click","fill","scroll","wait","get"],"deny":["eval","download","upload","network","state"]}
CLI-flag equivalent:
agent-browser --content-boundaries --max-output 50000 --allowed-domains "example.com,*.example.com" --action-policy ./policy.json open https://example.com
Troubleshooting
command not found: install and run agent-browser install.
- Wrong element clicked: run
snapshot -i again and use fresh refs.
- Dynamic SPA content missing: wait with
--load networkidle or targeted wait selector.
- Session collisions: assign unique
--session names and close each session.
- Large output pressure: narrow snapshots (
-i, -c, -d, -s) and extract only needed text.
References
Deep-dive docs in this skill:
Related resources:
Ready templates:
./templates/form-automation.sh
./templates/capture-workflow.sh
Metadata
- Version: 1.1.0
- Last updated: 2026-02-26
- Scope: deterministic browser automation for agent workflows
1---
2name: agent-browser-8
3description: "Browser automation CLI for AI agents. Use for website interaction, form automation, screenshots, scraping, and web app verification. Prefer snapshot refs (@e1, @e2) for deterministic actions."
4allowed-tools: Read Write Bash Grep Glob
5metadata:
6 tags: browser-automation, headless-browser, ai-agent, web-testing, web-scraping, verification
7 platforms: Claude, Gemini, Codex, ChatGPT
8 version: 1.1.0
9 source: vercel-labs/agent-browser
10---
11
12
13# agent-browser - Browser Automation for AI Agents
14
15## When to use this skill
16
17- Open websites and automate UI actions
18- Fill forms, click controls, and verify outcomes
19- Capture screenshots/PDFs or extract content
20- Run deterministic web checks with accessibility refs
21- Execute parallel browser tasks via isolated sessions
22
23## Core workflow
24
25Always use the deterministic ref loop:
26
271. `agent-browser open <url>`
282. `agent-browser snapshot -i`
293. interact with refs (`@e1`, `@e2`, ...)
304. `agent-browser snapshot -i` again after page/DOM changes
31
32```bash
33agent-browser open https://example.com/form
34agent-browser wait --load networkidle
35agent-browser snapshot -i
36agent-browser fill @e1 "user@example.com"
37agent-browser click @e2
38agent-browser snapshot -i
39```
40
41## Command patterns
42
43Use `&&` chaining when intermediate output is not needed.
44
45```bash
46# Good chaining: open -> wait -> snapshot
47agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
48
49# Separate calls when output is needed first
50agent-browser snapshot -i
51# parse refs
52agent-browser click @e2
53```
54
55High-value commands:
56- Navigation: `open`, `close`
57- Snapshot: `snapshot -i`, `snapshot -i -C`, `snapshot -s "#selector"`
58- Interaction: `click`, `fill`, `type`, `select`, `check`, `press`
59- Verification: `diff snapshot`, `diff screenshot --baseline <file>`
60- Capture: `screenshot`, `screenshot --annotate`, `pdf`
61- Wait: `wait --load networkidle`, `wait <selector|@ref|ms>`
62
63## Verification patterns
64
65Use explicit evidence after actions.
66
67```bash
68# Baseline -> action -> verify structure
69agent-browser snapshot -i
70agent-browser click @e3
71agent-browser diff snapshot
72
73# Visual regression
74agent-browser screenshot baseline.png
75agent-browser click @e5
76agent-browser diff screenshot --baseline baseline.png
77```
78
79## Safety and reliability
80
81- Refs are invalid after navigation or significant DOM updates; re-snapshot before next action.
82- Prefer `wait --load networkidle` or selector/ref waits over fixed sleeps.
83- For multi-step JS, use `eval --stdin` (or base64) to avoid shell escaping breakage.
84- For concurrent tasks, isolate with `--session <name>`.
85- Use output controls in long pages to reduce context flooding.
86- Optional hardening in sensitive flows: domain allowlist and action policies.
87
88Optional hardening examples:
89
90```bash
91# Wrap page content with boundaries to reduce prompt-injection risk
92export AGENT_BROWSER_CONTENT_BOUNDARIES=1
93
94# Limit output volume for long pages
95export AGENT_BROWSER_MAX_OUTPUT=50000
96
97# Restrict navigation and network to trusted domains
98export AGENT_BROWSER_ALLOWED_DOMAINS="example.com,*.example.com"
99
100# Restrict allowed action types
101export AGENT_BROWSER_ACTION_POLICY=./policy.json
102```
103
104Example `policy.json`:
105
106```json
107{"default":"deny","allow":["navigate","snapshot","click","fill","scroll","wait","get"],"deny":["eval","download","upload","network","state"]}
108```
109
110CLI-flag equivalent:
111
112```bash
113agent-browser --content-boundaries --max-output 50000 --allowed-domains "example.com,*.example.com" --action-policy ./policy.json open https://example.com
114```
115
116## Troubleshooting
117
118- `command not found`: install and run `agent-browser install`.
119- Wrong element clicked: run `snapshot -i` again and use fresh refs.
120- Dynamic SPA content missing: wait with `--load networkidle` or targeted `wait` selector.
121- Session collisions: assign unique `--session` names and close each session.
122- Large output pressure: narrow snapshots (`-i`, `-c`, `-d`, `-s`) and extract only needed text.
123
124## References
125
126Deep-dive docs in this skill:
127- [commands](./references/commands.md)
128- [snapshot-refs](./references/snapshot-refs.md)
129- [session-management](./references/session-management.md)
130- [authentication](./references/authentication.md)
131
132Related resources:
133- https://github.com/vercel-labs/agent-browser
134- https://agent-browser.dev
135
136Ready templates:
137- `./templates/form-automation.sh`
138- `./templates/capture-workflow.sh`
139
140## Metadata
141
142- Version: 1.1.0
143- Last updated: 2026-02-26
144- Scope: deterministic browser automation for agent workflows