Skill Overview
Start with fit, limitations, and setup before diving into the repository.
적합한 상황: Ideal for AI agents that need browser automation with agent-browser. 현지화된 요약: # Browser Automation with agent-browser The CLI uses Chrome/Chromium via CDP directly. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.
이 스킬을 사용하는 이유
추천 설명: agent-browser helps agents browser automation with agent-browser. Browser Automation with agent-browser The CLI uses Chrome/Chromium via CDP directly. This AI agent skill supports Claude Code, Cursor, and
최적의 용도
적합한 상황: Ideal for AI agents that need browser automation with agent-browser.
↓ 실행 가능한 사용 사례 for agent-browser
! 보안 및 제한 사항
- 제한 사항: When automating a site that requires login, choose the approach that fits:
- 제한 사항: Requires repository-specific context from the skill documentation
- 제한 사항: Works best when the underlying tools and dependencies are already configured
About The Source
The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.
Browser Sandbox Environment
⚡️ Ready to unleash?
Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.
FAQ 및 설치 단계
These questions and steps mirror the structured data on this page for better search understanding.
? 자주 묻는 질문
agent-browser은 무엇인가요?
적합한 상황: Ideal for AI agents that need browser automation with agent-browser. 현지화된 요약: # Browser Automation with agent-browser The CLI uses Chrome/Chromium via CDP directly. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.
agent-browser은 어떻게 설치하나요?
다음 명령을 실행하세요: npx killer-skills add YunosukeYoshino/harness/agent-browser. Cursor, Windsurf, VS Code, Claude Code와 19개 이상의 다른 IDE에서 동작합니다.
agent-browser은 어디에 쓰이나요?
주요 활용 사례는 다음과 같습니다: 사용 사례: Applying Browser Automation with agent-browser, 사용 사례: Applying Every browser automation follows this pattern:, 사용 사례: Applying Navigate : agent-browser open <url.
agent-browser 와 호환되는 IDE는 무엇인가요?
이 스킬은 Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer 와 호환됩니다. 통합 설치에는 Killer-Skills CLI를 사용하세요.
agent-browser에 제한 사항이 있나요?
제한 사항: When automating a site that requires login, choose the approach that fits:. 제한 사항: Requires repository-specific context from the skill documentation. 제한 사항: Works best when the underlying tools and dependencies are already configured.
↓ 이 스킬 설치 방법
-
1. 터미널 열기
프로젝트 디렉터리에서 터미널 또는 명령줄을 여세요.
-
2. 설치 명령 실행
npx killer-skills add YunosukeYoshino/harness/agent-browser 를 실행하세요. CLI가 IDE 또는 에이전트를 자동으로 감지하고 스킬을 설정합니다.
-
3. 스킬 사용 시작
스킬이 이제 활성화되었습니다. 현재 프로젝트에서 agent-browser을 바로 사용할 수 있습니다.
! Source Notes
This page is still useful for installation and source reference. Before using it, compare the fit, limitations, and upstream repository notes above.
Upstream Repository Material
The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.
agent-browser
# Browser Automation with agent-browser The CLI uses Chrome/Chromium via CDP directly. This AI agent skill supports Claude Code, Cursor, and Windsurf
Browser Automation with agent-browser
The CLI uses Chrome/Chromium via CDP directly. Install via npm i -g agent-browser, brew install agent-browser, or cargo install agent-browser. Run agent-browser install to download Chrome. Run agent-browser upgrade to update to the latest version.
Core Workflow
Every browser automation follows this pattern:
- Navigate:
agent-browser open <url> - Snapshot:
agent-browser snapshot -i(get element refs like@e1,@e2) - Interact: Use refs to click, fill, select
- Re-snapshot: After navigation or DOM changes, get fresh refs
bash1agent-browser open https://example.com/form 2agent-browser snapshot -i 3# Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit" 4 5agent-browser fill @e1 "user@example.com" 6agent-browser fill @e2 "password123" 7agent-browser click @e3 8agent-browser wait --load networkidle 9agent-browser snapshot -i # Check result
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.
bash1# Chain open + wait + snapshot in one call 2agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i 3 4# Chain multiple interactions 5agent-browser fill @e1 "user@example.com" && agent-browser fill @e2 "password123" && agent-browser click @e3 6 7# Navigate and capture 8agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser screenshot page.png
When to chain: Use && when you don't need to read the output of an intermediate command before proceeding (e.g., open + wait + screenshot). Run commands separately when you need to parse the output first (e.g., snapshot to discover refs, then interact using those refs).
Handling Authentication
When automating a site that requires login, choose the approach that fits:
Option 1: Import auth from the user's browser (fastest for one-off tasks)
bash1# Connect to the user's running Chrome (they're already logged in) 2agent-browser --auto-connect state save ./auth.json 3# Use that auth state 4agent-browser --state ./auth.json open https://app.example.com/dashboard
State files contain session tokens in plaintext -- add to .gitignore and delete when no longer needed. Set AGENT_BROWSER_ENCRYPTION_KEY for encryption at rest.
Option 2: Persistent profile (simplest for recurring tasks)
bash1# First run: login manually or via automation 2agent-browser --profile ~/.myapp open https://app.example.com/login 3# ... fill credentials, submit ... 4 5# All future runs: already authenticated 6agent-browser --profile ~/.myapp open https://app.example.com/dashboard
Option 3: Session name (auto-save/restore cookies + localStorage)
bash1agent-browser --session-name myapp open https://app.example.com/login 2# ... login flow ... 3agent-browser close # State auto-saved 4 5# Next time: state auto-restored 6agent-browser --session-name myapp open https://app.example.com/dashboard
Option 4: Auth vault (credentials stored encrypted, login by name)
bash1echo "$PASSWORD" | agent-browser auth save myapp --url https://app.example.com/login --username user --password-stdin 2agent-browser auth login myapp
auth login navigates with load and then waits for login form selectors to appear before filling/clicking, which is more reliable on delayed SPA login screens.
Option 5: State file (manual save/load)
bash1# After logging in: 2agent-browser state save ./auth.json 3# In a future session: 4agent-browser state load ./auth.json 5agent-browser open https://app.example.com/dashboard
See references/authentication.md for OAuth, 2FA, cookie-based auth, and token refresh patterns.
Essential Commands
bash1# Navigation 2agent-browser open <url> # Navigate (aliases: goto, navigate) 3agent-browser close # Close browser 4agent-browser close --all # Close all active sessions 5 6# Snapshot 7agent-browser snapshot -i # Interactive elements with refs (recommended) 8agent-browser snapshot -s "#selector" # Scope to CSS selector 9 10# Interaction (use @refs from snapshot) 11agent-browser click @e1 # Click element 12agent-browser click @e1 --new-tab # Click and open in new tab 13agent-browser fill @e2 "text" # Clear and type text 14agent-browser type @e2 "text" # Type without clearing 15agent-browser select @e1 "option" # Select dropdown option 16agent-browser check @e1 # Check checkbox 17agent-browser press Enter # Press key 18agent-browser keyboard type "text" # Type at current focus (no selector) 19agent-browser keyboard inserttext "text" # Insert without key events 20agent-browser scroll down 500 # Scroll page 21agent-browser scroll down 500 --selector "div.content" # Scroll within a specific container 22 23# Get information 24agent-browser get text @e1 # Get element text 25agent-browser get url # Get current URL 26agent-browser get title # Get page title 27agent-browser get cdp-url # Get CDP WebSocket URL 28 29# Wait 30agent-browser wait @e1 # Wait for element 31agent-browser wait --load networkidle # Wait for network idle 32agent-browser wait --url "**/page" # Wait for URL pattern 33agent-browser wait 2000 # Wait milliseconds 34agent-browser wait --text "Welcome" # Wait for text to appear (substring match) 35agent-browser wait --fn "!document.body.innerText.includes('Loading...')" # Wait for text to disappear 36agent-browser wait "#spinner" --state hidden # Wait for element to disappear 37 38# Downloads 39agent-browser download @e1 ./file.pdf # Click element to trigger download 40agent-browser wait --download ./output.zip # Wait for any download to complete 41agent-browser --download-path ./downloads open <url> # Set default download directory 42 43# Network 44agent-browser network requests # Inspect tracked requests 45agent-browser network requests --type xhr,fetch # Filter by resource type 46agent-browser network requests --method POST # Filter by HTTP method 47agent-browser network requests --status 2xx # Filter by status (200, 2xx, 400-499) 48agent-browser network request <requestId> # View full request/response detail 49agent-browser network route "**/api/*" --abort # Block matching requests 50agent-browser network har start # Start HAR recording 51agent-browser network har stop ./capture.har # Stop and save HAR file 52 53# Viewport & Device Emulation 54agent-browser set viewport 1920 1080 # Set viewport size (default: 1280x720) 55agent-browser set viewport 1920 1080 2 # 2x retina (same CSS size, higher res screenshots) 56agent-browser set device "iPhone 14" # Emulate device (viewport + user agent) 57 58# Capture 59agent-browser screenshot # Screenshot to temp dir 60agent-browser screenshot --full # Full page screenshot 61agent-browser screenshot --annotate # Annotated screenshot with numbered element labels 62agent-browser screenshot --screenshot-dir ./shots # Save to custom directory 63agent-browser screenshot --screenshot-format jpeg --screenshot-quality 80 64agent-browser pdf output.pdf # Save as PDF 65 66# Live preview / streaming 67agent-browser stream enable # Start runtime WebSocket streaming on an auto-selected port 68agent-browser stream enable --port 9223 # Bind a specific localhost port 69agent-browser stream status # Inspect enabled state, port, connection, and screencasting 70agent-browser stream disable # Stop runtime streaming and remove the .stream metadata file 71 72# Clipboard 73agent-browser clipboard read # Read text from clipboard 74agent-browser clipboard write "Hello, World!" # Write text to clipboard 75agent-browser clipboard copy # Copy current selection 76agent-browser clipboard paste # Paste from clipboard 77 78# Dialogs (alert, confirm, prompt, beforeunload) 79# By default, alert and beforeunload dialogs are auto-accepted so they never block the agent. 80# confirm and prompt dialogs still require explicit handling. 81# Use --no-auto-dialog to disable automatic handling. 82agent-browser dialog accept # Accept dialog 83agent-browser dialog accept "my input" # Accept prompt dialog with text 84agent-browser dialog dismiss # Dismiss/cancel dialog 85agent-browser dialog status # Check if a dialog is currently open 86 87# Diff (compare page states) 88agent-browser diff snapshot # Compare current vs last snapshot 89agent-browser diff snapshot --baseline before.txt # Compare current vs saved file 90agent-browser diff screenshot --baseline before.png # Visual pixel diff 91agent-browser diff url <url1> <url2> # Compare two pages 92agent-browser diff url <url1> <url2> --wait-until networkidle # Custom wait strategy 93agent-browser diff url <url1> <url2> --selector "#main" # Scope to element
Streaming
Every session automatically starts a WebSocket stream server on an OS-assigned port. Use agent-browser stream status to see the bound port and connection state. Use stream disable to tear it down, and stream enable --port <port> to re-enable on a specific port.
Batch Execution
Execute multiple commands in a single invocation by piping a JSON array of string arrays to batch. This avoids per-command process startup overhead when running multi-step workflows.
bash1echo '[ 2 ["open", "https://example.com"], 3 ["snapshot", "-i"], 4 ["click", "@e1"], 5 ["screenshot", "result.png"] 6]' | agent-browser batch --json 7 8# Stop on first error 9agent-browser batch --bail < commands.json
Use batch when you have a known sequence of commands that don't depend on intermediate output. Use separate commands or && chaining when you need to parse output between steps (e.g., snapshot to discover refs, then interact).
Common Patterns
Form Submission
bash1agent-browser open https://example.com/signup 2agent-browser snapshot -i 3agent-browser fill @e1 "Jane Doe" 4agent-browser fill @e2 "jane@example.com" 5agent-browser select @e3 "California" 6agent-browser check @e4 7agent-browser click @e5 8agent-browser wait --load networkidle
Authentication with Auth Vault (Recommended)
bash1# Save credentials once (encrypted with AGENT_BROWSER_ENCRYPTION_KEY) 2# Recommended: pipe password via stdin to avoid shell history exposure 3echo "pass" | agent-browser auth save github --url https://github.com/login --username user --password-stdin 4 5# Login using saved profile (LLM never sees password) 6agent-browser auth login github 7 8# List/show/delete profiles 9agent-browser auth list 10agent-browser auth show github 11agent-browser auth delete github
auth login waits for username/password/submit selectors before interacting, with a timeout tied to the default action timeout.
Authentication with State Persistence
bash1# Login once and save state 2agent-browser open https://app.example.com/login 3agent-browser snapshot -i 4agent-browser fill @e1 "$USERNAME" 5agent-browser fill @e2 "$PASSWORD" 6agent-browser click @e3 7agent-browser wait --url "**/dashboard" 8agent-browser state save auth.json 9 10# Reuse in future sessions 11agent-browser state load auth.json 12agent-browser open https://app.example.com/dashboard
Session Persistence
bash1# Auto-save/restore cookies and localStorage across browser restarts 2agent-browser --session-name myapp open https://app.example.com/login 3# ... login flow ... 4agent-browser close # State auto-saved to ~/.agent-browser/sessions/ 5 6# Next time, state is auto-loaded 7agent-browser --session-name myapp open https://app.example.com/dashboard 8 9# Encrypt state at rest 10export AGENT_BROWSER_ENCRYPTION_KEY=$(openssl rand -hex 32) 11agent-browser --session-name secure open https://app.example.com 12 13# Manage saved states 14agent-browser state list 15agent-browser state show myapp-default.json 16agent-browser state clear myapp 17agent-browser state clean --older-than 7
Working with Iframes
Iframe content is automatically inlined in snapshots. Refs inside iframes carry frame context, so you can interact with them directly.
bash1agent-browser open https://example.com/checkout 2agent-browser snapshot -i 3# @e1 [heading] "Checkout" 4# @e2 [Iframe] "payment-frame" 5# @e3 [input] "Card number" 6# @e4 [input] "Expiry" 7# @e5 [button] "Pay" 8 9# Interact directly — no frame switch needed 10agent-browser fill @e3 "4111111111111111" 11agent-browser fill @e4 "12/28" 12agent-browser click @e5 13 14# To scope a snapshot to one iframe: 15agent-browser frame @e2 16agent-browser snapshot -i # Only iframe content 17agent-browser frame main # Return to main frame
Data Extraction
bash1agent-browser open https://example.com/products 2agent-browser snapshot -i 3agent-browser get text @e5 # Get specific element text 4agent-browser get text body > page.txt # Get all page text 5 6# JSON output for parsing 7agent-browser snapshot -i --json 8agent-browser get text @e1 --json
Parallel Sessions
bash1agent-browser --session site1 open https://site-a.com 2agent-browser --session site2 open https://site-b.com 3 4agent-browser --session site1 snapshot -i 5agent-browser --session site2 snapshot -i 6 7agent-browser session list
Connect to Existing Chrome
bash1# Auto-discover running Chrome with remote debugging enabled 2agent-browser --auto-connect open https://example.com 3agent-browser --auto-connect snapshot 4 5# Or with explicit CDP port 6agent-browser --cdp 9222 snapshot
Auto-connect discovers Chrome via DevToolsActivePort, common debugging ports (9222, 9229), and falls back to a direct WebSocket connection if HTTP-based CDP discovery fails.
Color Scheme (Dark Mode)
bash1# Persistent dark mode via flag (applies to all pages and new tabs) 2agent-browser --color-scheme dark open https://example.com 3 4# Or via environment variable 5AGENT_BROWSER_COLOR_SCHEME=dark agent-browser open https://example.com 6 7# Or set during session (persists for subsequent commands) 8agent-browser set media dark
Viewport & Responsive Testing
bash1# Set a custom viewport size (default is 1280x720) 2agent-browser set viewport 1920 1080 3agent-browser screenshot desktop.png 4 5# Test mobile-width layout 6agent-browser set viewport 375 812 7agent-browser screenshot mobile.png 8 9# Retina/HiDPI: same CSS layout at 2x pixel density 10# Screenshots stay at logical viewport size, but content renders at higher DPI 11agent-browser set viewport 1920 1080 2 12agent-browser screenshot retina.png 13 14# Device emulation (sets viewport + user agent in one step) 15agent-browser set device "iPhone 14" 16agent-browser screenshot device.png
The scale parameter (3rd argument) sets window.devicePixelRatio without changing CSS layout. Use it when testing retina rendering or capturing higher-resolution screenshots.
Visual Browser (Debugging)
bash1agent-browser --headed open https://example.com 2agent-browser highlight @e1 # Highlight element 3agent-browser inspect # Open Chrome DevTools for the active page 4agent-browser record start demo.webm # Record session 5agent-browser profiler start # Start Chrome DevTools profiling 6agent-browser profiler stop trace.json # Stop and save profile (path optional)
Use AGENT_BROWSER_HEADED=1 to enable headed mode via environment variable. Browser extensions work in both headed and headless mode.
Local Files (PDFs, HTML)
bash1# Open local files with file:// URLs 2agent-browser --allow-file-access open file:///path/to/document.pdf 3agent-browser --allow-file-access open file:///path/to/page.html 4agent-browser screenshot output.png
iOS Simulator (Mobile Safari)
bash1# List available iOS simulators 2agent-browser device list 3 4# Launch Safari on a specific device 5agent-browser -p ios --device "iPhone 16 Pro" open https://example.com 6 7# Same workflow as desktop - snapshot, interact, re-snapshot 8agent-browser -p ios snapshot -i 9agent-browser -p ios tap @e1 # Tap (alias for click) 10agent-browser -p ios fill @e2 "text" 11agent-browser -p ios swipe up # Mobile-specific gesture 12 13# Take screenshot 14agent-browser -p ios screenshot mobile.png 15 16# Close session (shuts down simulator) 17agent-browser -p ios close
Requirements: macOS with Xcode, Appium (npm install -g appium && appium driver install xcuitest)
Real devices: Works with physical iOS devices if pre-configured. Use --device "<UDID>" where UDID is from xcrun xctrace list devices.
Security
All security features are opt-in. By default, agent-browser imposes no restrictions on navigation, actions, or output.
Content Boundaries (Recommended for AI Agents)
Enable --content-boundaries to wrap page-sourced output in markers that help LLMs distinguish tool output from untrusted page content:
bash1export AGENT_BROWSER_CONTENT_BOUNDARIES=1 2agent-browser snapshot 3# Output: 4# --- AGENT_BROWSER_PAGE_CONTENT nonce=<hex> origin=https://example.com --- 5# [accessibility tree] 6# --- END_AGENT_BROWSER_PAGE_CONTENT nonce=<hex> ---
Domain Allowlist
Restrict navigation to trusted domains. Wildcards like *.example.com also match the bare domain example.com. Sub-resource requests, WebSocket, and EventSource connections to non-allowed domains are also blocked. Include CDN domains your target pages depend on:
bash1export AGENT_BROWSER_ALLOWED_DOMAINS="example.com,*.example.com" 2agent-browser open https://example.com # OK 3agent-browser open https://malicious.com # Blocked
Action Policy
Use a policy file to gate destructive actions:
bash1export AGENT_BROWSER_ACTION_POLICY=./policy.json
Example policy.json:
json1{ "default": "deny", "allow": ["navigate", "snapshot", "click", "scroll", "wait", "get"] }
Auth vault operations (auth login, etc.) bypass action policy but domain allowlist still applies.
Output Limits
Prevent context flooding from large pages:
bash1export AGENT_BROWSER_MAX_OUTPUT=50000
Diffing (Verifying Changes)
Use diff snapshot after performing an action to verify it had the intended effect. This compares the current accessibility tree against the last snapshot taken in the session.
bash1# Typical workflow: snapshot -> action -> diff 2agent-browser snapshot -i # Take baseline snapshot 3agent-browser click @e2 # Perform action 4agent-browser diff snapshot # See what changed (auto-compares to last snapshot)
For visual regression testing or monitoring:
bash1# Save a baseline screenshot, then compare later 2agent-browser screenshot baseline.png 3# ... time passes or changes are made ... 4agent-browser diff screenshot --baseline baseline.png 5 6# Compare staging vs production 7agent-browser diff url https://staging.example.com https://prod.example.com --screenshot
diff snapshot output uses + for additions and - for removals, similar to git diff. diff screenshot produces a diff image with changed pixels highlighted in red, plus a mismatch percentage.
Timeouts and Slow Pages
The default timeout is 25 seconds. This can be overridden with the AGENT_BROWSER_DEFAULT_TIMEOUT environment variable (value in milliseconds). For slow websites or large pages, use explicit waits instead of relying on the default timeout:
bash1# Wait for network activity to settle (best for slow pages) 2agent-browser wait --load networkidle 3 4# Wait for a specific element to appear 5agent-browser wait "#content" 6agent-browser wait @e1 7 8# Wait for a specific URL pattern (useful after redirects) 9agent-browser wait --url "**/dashboard" 10 11# Wait for a JavaScript condition 12agent-browser wait --fn "document.readyState === 'complete'" 13 14# Wait a fixed duration (milliseconds) as a last resort 15agent-browser wait 5000
When dealing with consistently slow websites, use wait --load networkidle after open to ensure the page is fully loaded before taking a snapshot. If a specific element is slow to render, wait for it directly with wait <selector> or wait @ref.
JavaScript Dialogs (alert / confirm / prompt)
When a page opens a JavaScript dialog (alert(), confirm(), or prompt()), it blocks all other browser commands (snapshot, screenshot, click, etc.) until the dialog is dismissed. If commands start timing out unexpectedly, check for a pending dialog:
bash1# Check if a dialog is blocking 2agent-browser dialog status 3 4# Accept the dialog (dismiss the alert / click OK) 5agent-browser dialog accept 6 7# Accept a prompt dialog with input text 8agent-browser dialog accept "my input" 9 10# Dismiss the dialog (click Cancel) 11agent-browser dialog dismiss
When a dialog is pending, all command responses include a warning field indicating the dialog type and message. In --json mode this appears as a "warning" key in the response object.
Session Management and Cleanup
When running multiple agents or automations concurrently, always use named sessions to avoid conflicts:
bash1# Each agent gets its own isolated session 2agent-browser --session agent1 open site-a.com 3agent-browser --session agent2 open site-b.com 4 5# Check active sessions 6agent-browser session list
Always close your browser session when done to avoid leaked processes:
bash1agent-browser close # Close default session 2agent-browser --session agent1 close # Close specific session 3agent-browser close --all # Close all active sessions
If a previous session was not closed properly, the daemon may still be running. Use agent-browser close to clean it up, or agent-browser close --all to shut down every session at once.
To auto-shutdown the daemon after a period of inactivity (useful for ephemeral/CI environments):
bash1AGENT_BROWSER_IDLE_TIMEOUT_MS=60000 agent-browser open example.com
Ref Lifecycle (Important)
Refs (@e1, @e2, etc.) are invalidated when the page changes. Always re-snapshot after:
- Clicking links or buttons that navigate
- Form submissions
- Dynamic content loading (dropdowns, modals)
bash1agent-browser click @e5 # Navigates to new page 2agent-browser snapshot -i # MUST re-snapshot 3agent-browser click @e1 # Use new refs
Annotated Screenshots (Vision Mode)
Use --annotate to take a screenshot with numbered labels overlaid on interactive elements. Each label [N] maps to ref @eN. This also caches refs, so you can interact with elements immediately without a separate snapshot.
bash1agent-browser screenshot --annotate 2# Output includes the image path and a legend: 3# [1] @e1 button "Submit" 4# [2] @e2 link "Home" 5# [3] @e3 textbox "Email" 6agent-browser click @e2 # Click using ref from annotated screenshot
Use annotated screenshots when:
- The page has unlabeled icon buttons or visual-only elements
- You need to verify visual layout or styling
- Canvas or chart elements are present (invisible to text snapshots)
- You need spatial reasoning about element positions
Semantic Locators (Alternative to Refs)
When refs are unavailable or unreliable, use semantic locators:
bash1agent-browser find text "Sign In" click 2agent-browser find label "Email" fill "user@test.com" 3agent-browser find role button click --name "Submit" 4agent-browser find placeholder "Search" type "query" 5agent-browser find testid "submit-btn" click
JavaScript Evaluation (eval)
Use eval to run JavaScript in the browser context. Shell quoting can corrupt complex expressions -- use --stdin or -b to avoid issues.
bash1# Simple expressions work with regular quoting 2agent-browser eval 'document.title' 3agent-browser eval 'document.querySelectorAll("img").length' 4 5# Complex JS: use --stdin with heredoc (RECOMMENDED) 6agent-browser eval --stdin <<'EVALEOF' 7JSON.stringify( 8 Array.from(document.querySelectorAll("img")) 9 .filter(i => !i.alt) 10 .map(i => ({ src: i.src.split("/").pop(), width: i.width })) 11) 12EVALEOF 13 14# Alternative: base64 encoding (avoids all shell escaping issues) 15agent-browser eval -b "$(echo -n 'Array.from(document.querySelectorAll("a")).map(a => a.href)' | base64)"
Why this matters: When the shell processes your command, inner double quotes, ! characters (history expansion), backticks, and $() can all corrupt the JavaScript before it reaches agent-browser. The --stdin and -b flags bypass shell interpretation entirely.
Rules of thumb:
- Single-line, no nested quotes -> regular
eval 'expression'with single quotes is fine - Nested quotes, arrow functions, template literals, or multiline -> use
eval --stdin <<'EVALEOF' - Programmatic/generated scripts -> use
eval -bwith base64
Configuration File
Create agent-browser.json in the project root for persistent settings:
json1{ 2 "headed": true, 3 "proxy": "http://localhost:8080", 4 "profile": "./browser-data" 5}
Priority (lowest to highest): ~/.agent-browser/config.json < ./agent-browser.json < env vars < CLI flags. Use --config <path> or AGENT_BROWSER_CONFIG env var for a custom config file (exits with error if missing/invalid). All CLI options map to camelCase keys (e.g., --executable-path -> "executablePath"). Boolean flags accept true/false values (e.g., --headed false overrides config). Extensions from user and project configs are merged, not replaced.
Deep-Dive Documentation
| Reference | When to Use |
|---|---|
| references/commands.md | Full command reference with all options |
| references/snapshot-refs.md | Ref lifecycle, invalidation rules, troubleshooting |
| references/session-management.md | Parallel sessions, state persistence, concurrent scraping |
| references/authentication.md | Login flows, OAuth, 2FA handling, state reuse |
| references/video-recording.md | Recording workflows for debugging and documentation |
| references/profiling.md | Chrome DevTools profiling for performance analysis |
| references/proxy-support.md | Proxy configuration, geo-testing, rotating proxies |
Browser Engine Selection
Use --engine to choose a local browser engine. The default is chrome.
bash1# Use Lightpanda (fast headless browser, requires separate install) 2agent-browser --engine lightpanda open example.com 3 4# Via environment variable 5export AGENT_BROWSER_ENGINE=lightpanda 6agent-browser open example.com 7 8# With custom binary path 9agent-browser --engine lightpanda --executable-path /path/to/lightpanda open example.com
Supported engines:
chrome(default) -- Chrome/Chromium via CDPlightpanda-- Lightpanda headless browser via CDP (10x faster, 10x less memory than Chrome)
Lightpanda does not support --extension, --profile, --state, or --allow-file-access. Install Lightpanda from https://lightpanda.io/docs/open-source/installation.
Observability Dashboard
The dashboard is a standalone background server that shows live browser viewports, command activity, and console output for all sessions.
bash1# Install the dashboard once 2agent-browser dashboard install 3 4# Start the dashboard server (background, port 4848) 5agent-browser dashboard start 6 7# All sessions are automatically visible in the dashboard 8agent-browser open example.com 9 10# Stop the dashboard 11agent-browser dashboard stop
The dashboard runs independently of browser sessions on port 4848 (configurable with --port). All sessions automatically stream to the dashboard.
Ready-to-Use Templates
| Template | Description |
|---|---|
| templates/form-automation.sh | Form filling with validation |
| templates/authenticated-session.sh | Login once, reuse state |
| templates/capture-workflow.sh | Content extraction with screenshots |
bash1./templates/form-automation.sh https://example.com/form 2./templates/authenticated-session.sh https://app.example.com/login 3./templates/capture-workflow.sh https://example.com ./output