agent-browser
$
npx mdskill add emdash-cms/emdash/agent-browserFast browser automation CLI for AI agents. Use this to verify web UI changes, test interactions, and capture screenshots.
SKILL.md
.github/skills/agent-browserView on GitHub ↗
--- name: agent-browser description: Browser automation for testing and verification. Use when you need to interact with web UIs, verify visual changes, fill forms, or capture screenshots. --- # Agent Browser Skill Fast browser automation CLI for AI agents. Use this to verify web UI changes, test interactions, and capture screenshots. ## When to Use - Verify visual changes after modifying frontend code - Test form interactions and user flows - Capture screenshots for documentation or debugging - Inspect rendered HTML/accessibility tree - Debug why something isn't working in the browser ## Core Workflow ### 1. Open a URL ```bash agent-browser open http://localhost:4321/ ``` ### 2. Take a Snapshot The snapshot command returns an accessibility tree with refs (`@e1`, `@e2`, etc.) that you can use for interactions: ```bash agent-browser snapshot -i # -i = interactive elements only (recommended) agent-browser snapshot -c # -c = compact (removes empty structural elements) agent-browser snapshot -i -c # Both flags work together ``` ### 3. Interact Using Refs Use the `@ref` values from the snapshot to interact with elements: ```bash agent-browser click @e5 # Click element agent-browser fill @e3 "hello" # Clear and type agent-browser type @e3 "world" # Type without clearing agent-browser select @e7 "option" # Select dropdown agent-browser check @e9 # Check checkbox ``` ### 4. Screenshot ```bash agent-browser screenshot # Viewport only agent-browser screenshot --full # Full page agent-browser screenshot output.png # Save to file ``` ALWAYS check the image size before attempting to load. If it is larger than 2MB, process it using a tool such as sips or ImageMagick to reduce the size. Large files cannot be loaded by your tools. ## Common Patterns ### Form Verification ```bash agent-browser open http://localhost:4321/_emdash/api/setup/dev-bypass?redirect=/_emdash/admin/content/posts/new agent-browser snapshot -i # Check what fields are visible agent-browser fill @e3 "Test Title" agent-browser fill @e5 "Test content here" agent-browser click @e7 # Save button ``` ### Get Element Info ```bash agent-browser get text @e1 # Get text content agent-browser get html @e1 # Get inner HTML agent-browser get value @e2 # Get input value agent-browser get url # Current URL agent-browser get title # Page title agent-browser get count "button" # Count matching elements ``` ### Check Element State ```bash agent-browser is visible @e1 agent-browser is enabled @e2 agent-browser is checked @e3 ``` ### Find by Role/Label ```bash agent-browser find role button click --name "Submit" agent-browser find label "Email" fill "test@example.com" agent-browser find placeholder "Search..." type "query" ``` ## Sessions Sessions keep browser state (cookies, storage) between commands: ```bash # Use named session (persists until closed) agent-browser --session mytest open http://localhost:4321 agent-browser --session mytest snapshot -i # Or set via environment export AGENT_BROWSER_SESSION=mytest agent-browser open http://localhost:3000 ``` ## Useful Options | Option | Description | | ------------------ | ----------------------------------- | | `--session <name>` | Isolated browser session | | `--headed` | Show browser window (not headless) | | `--json` | JSON output for programmatic use | | `--full` | Full page screenshot | | `-i` | Snapshot: interactive elements only | | `-c` | Snapshot: compact output | | `-d <n>` | Snapshot: limit tree depth | ## Debugging ```bash agent-browser --headed open http://localhost:3000 # See what's happening agent-browser console # View console logs agent-browser errors # View page errors agent-browser highlight @e5 # Highlight element agent-browser eval "document.title" # Run JS ``` ## Tips 1. **Always snapshot first** - Get refs before interacting 2. **Use `-i` flag** - Interactive-only snapshots are much cleaner 3. **Wait when needed** - Use `wait <ms>` or `wait <selector>` after actions that trigger loading 4. **Sessions for auth** - Use named sessions to persist login state 5. **Headed for debugging** - Use `--headed` when things aren't working as expected
More from emdash-cms/emdash
- building-emdash-siteBuild and customize EmDash CMS sites on Astro. Use when creating pages, defining collections, writing seed files, querying content, rendering Portable Text, setting up menus/taxonomies/widgets, configuring deployment, or any task involving an EmDash-powered Astro site. Assumes basic Astro knowledge but provides all EmDash-specific patterns.
- creating-pluginsCreate EmDash CMS plugins with hooks, storage, settings, admin UI, API routes, and Portable Text block types. Use this skill when asked to build, scaffold, or implement an EmDash plugin, or when creating plugin features like custom block types, admin pages, or content hooks.
- diagnoseTrace from a reproduced symptom to the source code that causes it. Identify the specific file and approximate line, then rate confidence honestly.
- emdash-cliUse the EmDash CLI to manage content, schema, media, and more. Use this skill when you need to interact with a running EmDash instance from the command line — creating content, managing collections, uploading media, generating types, or scripting CMS operations.
- repro-adminReproduce an EmDash admin UI bug. Boots a demo with bgproc, drives the admin with agent-browser using the dev-bypass session, and captures the reproduction as screenshots plus a written transcript.
- repro-apiReproduce an EmDash bug that lives below the browser layer -- REST handlers, CLI, MCP, migrations, schema registry, or build tooling. No agent-browser. Prefer a failing vitest test in the affected package.
- repro-publicReproduce a bug in the public-facing rendered site (not the admin). Boots a demo with bgproc, drives the public routes with agent-browser, and captures the reproduction as screenshots plus a written transcript.
- verifyDecide whether the diagnosed behaviour is actually a bug or whether the code is doing what it was designed to do. Gate the fix stage.
- wordpress-plugin-to-emdashPort a WordPress plugin to EmDash CMS. Use this skill when asked to migrate, convert, or port a WordPress plugin, theme functionality, or custom post type to EmDash. Provides concept mapping and implementation patterns.
- wordpress-theme-to-emdashPort WordPress themes to EmDash CMS. Use when asked to convert, migrate, or port a WordPress theme to EmDash, or when creating an EmDash site that should match an existing WordPress site's design. Handles design extraction, template conversion, and EmDash-specific features like menus, taxonomies, and widgets.