Skip to content

feat(browser): add playwright-cli subagent for AI agent automation#196

Merged
marcusquinn merged 2 commits intomainfrom
feature/playwright-cli-subagent
Jan 25, 2026
Merged

feat(browser): add playwright-cli subagent for AI agent automation#196
marcusquinn merged 2 commits intomainfrom
feature/playwright-cli-subagent

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 25, 2026

Summary

  • Add playwright-cli.md subagent with Microsoft official CLI documentation
  • Update browser-automation.md decision tree to include playwright-cli
  • Update README.md with playwright-cli in browser tools section (now 8 tools + anti-detect stack)

What is playwright-cli?

playwright-cli is Microsoft's official CLI for AI agents, part of @playwright/mcp. It provides:

  • Ref-based element targeting - Deterministic selection from accessibility snapshots (e1, e2, e3)
  • Session isolation - --session flag for parallel browser instances with persistent profiles
  • Built-in tracing - tracing-start/stop for debugging
  • Headless by default - No window competition, faster execution

When to use playwright-cli vs other tools

Need Tool
AI agent automation (CLI) playwright-cli - Microsoft official, simple tool restriction
Existing browser sessions Playwriter - Your extensions/passwords already unlocked
Maximum speed Playwright direct - Full API control
CLI with Rust binary agent-browser - Faster cold starts

Installation

bun install -g @playwright/mcp@latest   # Bun (preferred for speed)
npm install -g @playwright/mcp@latest   # npm alternative

Related

Summary by CodeRabbit

  • Documentation
    • Added comprehensive guide for playwright-cli browser automation tool for AI agents
    • Updated browser automation toolset to include playwright-cli with session isolation and built-in tracing capabilities
    • Refreshed decision trees and feature matrices reflecting expanded CLI-first automation workflows
    • Enhanced guidance for selecting appropriate browser automation tools for AI-agent use cases

✏️ Tip: You can customize this high-level summary in your review settings.

- Add playwright-cli.md subagent with Microsoft official CLI documentation
- Update browser-automation.md decision tree to include playwright-cli
- Update README.md with playwright-cli in browser tools section
- Recommend bun install for faster package installation

playwright-cli is Microsoft's official CLI for AI agents, part of @playwright/mcp.
Key features: --session isolation, built-in tracing, ref-based element targeting.
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the repository's capabilities for AI agent browser automation by integrating playwright-cli, Microsoft's official command-line interface tool. The changes involve adding detailed documentation for this new tool, updating existing guides to recommend its use in relevant scenarios, and ensuring all overview sections accurately reflect the expanded toolset. This provides AI agents with a powerful, dedicated CLI option for web interaction, emphasizing deterministic element targeting and session isolation.

Highlights

  • New Subagent Added: Introduced playwright-cli.md as a new subagent, providing comprehensive documentation and usage guidelines for Microsoft's official Playwright CLI for AI agent automation.
  • Browser Automation Decision Tree Update: Modified browser-automation.md to integrate playwright-cli into the decision-making process for selecting browser automation tools, specifically highlighting its use for AI agents, CLI/shell scripting, and persistent sessions.
  • README Update: Updated README.md to reflect the addition of playwright-cli, increasing the count of browser automation tools from 7 to 8 and incorporating it into the performance benchmarks, feature matrix, and tool selection guide.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 42 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The PR introduces playwright-cli as a new browser automation tool for AI agents. It updates documentation to emphasize CLI-first workflows, integrating the tool into feature matrices, decision trees, and quick references with support for session isolation and built-in tracing.

Changes

Cohort / File(s) Summary
New Playwright CLI Documentation
\.agent/tools/browser/playwright-cli.md
New comprehensive guide documenting installation, core snapshot + ref pattern, commands reference (core actions, navigation, input, file saving, tabs, DevTools, session management), environment variables, workflow examples, debugging/tracing, multi-tab workflows, and comparisons with other tools.
Browser Automation Decision Tree & References
\.agent/tools/browser/browser-automation.md
Recasts decision paths and guidance toward CLI-first AI-agent workflows. Adds new playwright-cli section to Quick Reference. Updates Feature Matrix with playwright-cli column and adjusts multiple feature rows (headless, session persistence, cookies, proxy, form filling, screenshots, tracing, etc.) to reflect CLI-backed approaches.
Project-level Tool Documentation
README.md
Updates Browser Automation section from 7 to 8 tools, adds playwright-cli to tool roster, extends Feature Matrix and Tool Selection rows with playwright-cli column, documents its role for AI agents with session isolation and built-in tracing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🎭 A new CLI joins the stage with flair,
Sessions isolated in the crisp, headless air,
playwright-cli commands paint the browser's way,
Eight tools dance together, leading AI's play! ⚡

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding playwright-cli as a new subagent for AI agent automation, which is the primary focus across all three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces playwright-cli as a new browser automation tool, which is a great addition for AI agent workflows. The documentation is comprehensive, with a new dedicated file for playwright-cli and updates to the existing browser automation decision tree and README. The changes are well-structured and clearly explain the purpose and usage of the new tool. I've found a few minor inconsistencies in the documentation that could be addressed to improve clarity. Overall, this is a solid contribution.

Comment on lines 50 to 323
**vs agent-browser**: playwright-cli uses simpler ref syntax (`e5` vs `@e5`), has built-in tracing, and is Microsoft-maintained. agent-browser has Rust CLI for faster cold starts.

**vs Playwriter MCP**: playwright-cli runs headless with isolated sessions. Playwriter uses your existing browser (headed, with your extensions/passwords).

**When to use**:

- AI agent automation (forms, clicks, navigation)
- CI/CD pipelines and shell scripts
- Parallel browser sessions
- Tasks that don't need your existing browser state

<!-- AI-CONTEXT-END -->

## Installation

```bash
# Install globally (recommended - fastest, no runner overhead)
bun install -g @playwright/mcp@latest # Bun (preferred)
npm install -g @playwright/mcp@latest # npm alternative

# Verify installation
playwright-cli --help

# Or run without global install (slower cold start)
bunx @playwright/mcp playwright-cli --help # ~0.3s
npx @playwright/mcp playwright-cli --help # ~2-3s (registry lookup)
```

**As Claude Code skill** (recommended for Claude Code users):

```bash
/plugin marketplace add microsoft/playwright-cli
/plugin install playwright-cli
```

**Manual skill installation**:

```bash
mkdir -p .claude/skills/playwright-cli
curl -o .claude/skills/playwright-cli/SKILL.md \
https://raw.githubusercontent.com/microsoft/playwright-cli/main/skills/playwright-cli/SKILL.md
```

## Core Workflow

### The Snapshot + Ref Pattern

This is the **recommended workflow for AI agents**:

```bash
# 1. Navigate and get snapshot
playwright-cli open https://example.com
playwright-cli snapshot

# 2. AI identifies target refs from snapshot
# Output includes refs like:
# - heading "Example Domain" [ref=e1] [level=1]
# - button "Submit" [ref=e2]
# - textbox "Email" [ref=e3]

# 3. Execute actions using refs
playwright-cli click e2
playwright-cli fill e3 "input text"

# 4. Get new snapshot if page changed
playwright-cli snapshot
```

**Why use refs?**

- **Deterministic**: Ref points to exact element from snapshot
- **Fast**: No DOM re-query needed
- **AI-friendly**: Snapshot + ref workflow is optimal for LLMs

## Commands Reference

### Core

```bash
playwright-cli open <url> # Navigate to URL
playwright-cli close # Close the page
playwright-cli type <text> # Type text into focused/editable element
playwright-cli click <ref> [button] # Click element (left/right/middle)
playwright-cli dblclick <ref> [button] # Double-click element
playwright-cli fill <ref> <text> # Clear and fill input
playwright-cli drag <startRef> <endRef> # Drag and drop between elements
playwright-cli hover <ref> # Hover over element
playwright-cli select <ref> <value> # Select dropdown option
playwright-cli upload <file> # Upload file(s)
playwright-cli check <ref> # Check checkbox/radio
playwright-cli uncheck <ref> # Uncheck checkbox
playwright-cli snapshot # Get accessibility tree with refs
playwright-cli eval <func> [ref] # Evaluate JavaScript
playwright-cli dialog-accept [prompt] # Accept dialog (with optional prompt text)
playwright-cli dialog-dismiss # Dismiss dialog
playwright-cli resize <width> <height> # Resize browser window
```

### Navigation

```bash
playwright-cli go-back # Navigate back
playwright-cli go-forward # Navigate forward
playwright-cli reload # Reload page
```

### Keyboard

```bash
playwright-cli press <key> # Press key (Enter, ArrowDown, Tab, etc.)
playwright-cli keydown <key> # Press key down
playwright-cli keyup <key> # Release key
```

### Mouse

```bash
playwright-cli mousemove <x> <y> # Move mouse to position
playwright-cli mousedown [button] # Press mouse button
playwright-cli mouseup [button] # Release mouse button
playwright-cli mousewheel <dx> <dy> # Scroll mouse wheel
```

### Save As

```bash
playwright-cli screenshot # Screenshot current page
playwright-cli screenshot <ref> # Screenshot specific element
playwright-cli pdf # Save page as PDF
```

### Tabs

```bash
playwright-cli tab-list # List all tabs
playwright-cli tab-new [url] # Create new tab
playwright-cli tab-close [index] # Close tab
playwright-cli tab-select <index> # Switch to tab
```

### DevTools

```bash
playwright-cli console [min-level] # List console messages
playwright-cli network # List network requests
playwright-cli run-code <code> # Run Playwright code snippet
playwright-cli tracing-start # Start trace recording
playwright-cli tracing-stop # Stop trace recording
```

### Sessions

```bash
playwright-cli --session=name open <url> # Use named session
playwright-cli session-list # List all sessions
playwright-cli session-stop [name] # Stop session
playwright-cli session-stop-all # Stop all sessions
playwright-cli session-delete [name] # Delete session data and profile
```

## Sessions

Playwright CLI uses persistent profiles by default. Cookies and storage are preserved between calls.

### Named Sessions

Run multiple isolated browser instances:

```bash
# Different sessions for different tasks
playwright-cli open https://playwright.dev
playwright-cli --session=example open https://example.com
playwright-cli session-list

# Work in specific session
playwright-cli --session=example click e4
playwright-cli --session=example snapshot
```

### Environment Variable

Set session via environment for all commands:

```bash
PLAYWRIGHT_CLI_SESSION=todo-app claude .
```

### Session Management

```bash
playwright-cli session-list # List all sessions
playwright-cli session-stop [name] # Stop session (keeps profile)
playwright-cli session-stop-all # Stop all sessions
playwright-cli session-delete [name] # Delete session + profile data
```

## Headed Mode

Show the browser window for debugging:

```bash
playwright-cli open https://playwright.dev --headed
```

## Examples

### Form Submission

```bash
playwright-cli open https://example.com/form
playwright-cli snapshot

playwright-cli fill e1 "user@example.com"
playwright-cli fill e2 "password123"
playwright-cli click e3
playwright-cli snapshot
```

### Multi-Tab Workflow

```bash
playwright-cli open https://example.com
playwright-cli tab-new https://example.com/other
playwright-cli tab-list
playwright-cli tab-select 0
playwright-cli snapshot
```

### Debugging with DevTools

```bash
playwright-cli open https://example.com
playwright-cli click e4
playwright-cli fill e7 "test"
playwright-cli console
playwright-cli network
```

### Tracing for Debug

```bash
playwright-cli open https://example.com
playwright-cli tracing-start
playwright-cli click e4
playwright-cli fill e7 "test"
playwright-cli tracing-stop
# Opens trace viewer with recorded actions
```

### Todo App Demo

```bash
playwright-cli open https://demo.playwright.dev/todomvc/ --headed
playwright-cli type "Buy groceries"
playwright-cli press Enter
playwright-cli type "Water flowers"
playwright-cli press Enter
playwright-cli check e21
playwright-cli check e35
playwright-cli screenshot
```

## Comparison with Other Tools

| Feature | playwright-cli | agent-browser | Playwriter | Stagehand |
|---------|---------------|---------------|------------|-----------|
| **Maintainer** | Microsoft | Vercel | Community | Browserbase |
| **Interface** | CLI | CLI | MCP | SDK |
| **Ref syntax** | `e5` | `@e5` | aria-ref | Natural language |
| **Sessions** | `--session` | `--session` | Your browser | Per-instance |
| **Tracing** | Built-in | Via Playwright | Via CDP | Via Playwright |
| **Headless** | Default | Default | No (your browser) | Default |
| **Extensions** | No | No | Yes (yours) | Possible |
| **Cold start** | ~2s | ~3-5s (Rust) | ~1s (extension) | ~2s |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There appears to be a contradiction regarding the cold start performance comparison between playwright-cli and agent-browser.

  • On line 50, the text says: agent-browser has Rust CLI for faster cold starts.
  • However, the comparison table on line 323 shows playwright-cli as being faster (~2s) than agent-browser (~3-5s (Rust)).

Please review and correct this for consistency.

Comment on lines 307 to 308
playwright-cli check e21
playwright-cli check e35

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Todo App Demo uses element references (e21, e35) without showing how they are obtained. To make the example clearer and self-contained, a playwright-cli snapshot command should be added before the check commands to demonstrate the standard workflow of getting references before using them. For example:

...
playwright-cli type "Water flowers"
playwright-cli press Enter
playwright-cli snapshot # Get refs for the todo items
playwright-cli check e21
playwright-cli check e35
...

README.md Outdated
| **Self-healing** | No | No | No | No | No | Yes |
| Feature | Playwright | playwright-cli | dev-browser | agent-browser | Crawl4AI | Playwriter | Stagehand |
|---------|-----------|----------------|-------------|---------------|----------|------------|-----------|
| **Headless** | Yes | Yes (default) | Yes | Yes | Yes | No (your browser) | Yes |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a small inconsistency in the Feature Matrix. For agent-browser, the Headless feature is listed as Yes. However, in .agent/tools/browser/browser-automation.md, it's specified as Yes (default). To maintain consistency across documentation files, this should be updated.

Suggested change
| **Headless** | Yes | Yes (default) | Yes | Yes | Yes | No (your browser) | Yes |
| **Headless** | Yes | Yes (default) | Yes | Yes (default) | Yes | No (your browser) | Yes |

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 481 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Jan 25 03:01:08 UTC 2026: Code review monitoring started
Sun Jan 25 03:01:08 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 481
Sun Jan 25 03:01:08 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sun Jan 25 03:01:10 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 481
  • VULNERABILITIES: 0

Generated on: Sun Jan 25 03:02:35 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@augmentcode
Copy link

augmentcode bot commented Jan 25, 2026

🤖 Augment PR Summary

Summary: This PR adds first-class documentation for Microsoft’s playwright-cli as a browser automation option tailored to AI/CLI workflows.

Changes:

  • Added a new playwright-cli subagent doc with installation, core snapshot+ref workflow, and command reference
  • Extended the browser tool decision tree to recommend playwright-cli for CLI-first agent automation and session isolation
  • Updated feature matrices/quick references to include playwright-cli across browser automation docs
  • Updated README browser tooling section to include playwright-cli (tool count now 8)

Technical Notes: Highlights --session-based profile isolation, headless-by-default operation, snapshot refs (e1, e2…), and built-in tracing commands for debugging.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

| **Tracing** | Built-in | Via Playwright | Via CDP | Via Playwright |
| **Headless** | Default | Default | No (your browser) | Default |
| **Extensions** | No | No | Yes (yours) | Possible |
| **Cold start** | ~2s | ~3-5s (Rust) | ~1s (extension) | ~2s |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison section is internally inconsistent about agent-browser startup time: it says agent-browser has "faster cold starts", but the table lists agent-browser cold start as ~3-5s (slower than ~2s for playwright-cli). Consider reconciling these so readers don’t get conflicting guidance.

Other Locations
  • .agent/tools/browser/playwright-cli.md:50
  • .agent/tools/browser/playwright-cli.md:334

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.agent/tools/browser/playwright-cli.md:
- Around line 258-266: Replace the hardcoded password in the example Playwright
CLI snippet by using a credential placeholder (e.g., "$PASSWORD") and update the
surrounding Markdown to include a brief note instructing users to store
credentials securely (environment variable or secret vault); locate the snippet
containing the commands (playwright-cli fill e2 "password123") and change that
invocation to use the placeholder, and add one-line guidance about secure
credential storage adjacent to the snippet.

- Fix cold start comparison (playwright-cli ~2s is faster than agent-browser ~3-5s)
- Add snapshot command to Todo App Demo for clarity
- Use credential placeholder instead of hardcoded password
- Fix README headless column consistency for agent-browser
@sonarqubecloud
Copy link

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 481 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Jan 25 03:06:00 UTC 2026: Code review monitoring started
Sun Jan 25 03:06:00 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 481
Sun Jan 25 03:06:00 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sun Jan 25 03:06:02 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 481
  • VULNERABILITIES: 0

Generated on: Sun Jan 25 03:07:24 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit 07eaea6 into main Jan 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant