PlugWiki

playwright-cli: Microsoft's Playwright CLI for coding agents

Microsoft's playwright-cli lets a coding agent drive a real browser with shell commands, to test web apps, check UI fixes and capture screenshots.

Installs
204.5K
on skills.sh
Stars
14.9K
on GitHub
Files
10
besides SKILL.md
Updated
Oct 2026
last repo commit

playwright-cli lets a coding agent such as Claude Code, GitHub Copilot or Cursor drive a real browser through short shell commands. The agent opens a page, reads a snapshot of it, then clicks, types and takes screenshots. Microsoft built it for coding agents, and the skill teaches the agent which command to run next.

Microsoft says the CLI uses fewer tokens than Playwright MCP, because it skips the large tool list and page dumps. Two independent tests disagree: Checkly saw about the same token use, and Ranger saw fewer tokens but about twice the time. Pick MCP for long exploratory sessions or chat apps that have no shell.

npx playwright test and npx playwright codegen are Playwright's test-runner commands, a different tool. playwright-cli is the separate @playwright/cli package.

You need Node 18+ per the README (playwright.dev says 20+) and a client that can run shell commands. A browser downloads the first time you use it. It does not work in Claude.ai or ChatGPT chat, which have no shell.

Good for

  • Developers testing a web app with Claude Code, Copilot or Cursor
  • Teams that write or fix Playwright tests with an agent
  • People moving from Playwright MCP who want less context use
  • Anyone who wants screenshots or PDFs of a page captured by an agent

Install playwright-cli

Claude Code

  1. 1

    Copy this prompt.

    Install the playwright-cli skill in Claude Code. Run this command:
    
    npm install -g @playwright/cli@latest
    playwright-cli install --skills
    
    Then check that it loaded and tell me how to use it.
  2. 2

    Paste it into Claude Code. It shows the change and asks before running it.

Requires Node.js 20+ per playwright.dev (the README says 18+).

The skills CLI command on skills.sh copies only the SKILL.md. The skill calls the playwright-cli command, so install the npm package as well.

From the vendor's docs. Source.

What's in the skill

When it loads

Automate browser interactions, test web pages and work with Playwright tests.

Sections in SKILL.md

  1. Quick start
  2. Commands
  3. Core
  4. Navigation
  5. Keyboard
  6. Mouse
  7. Save as
  8. Tabs
  9. Storage
  10. Emulation
  11. Network
  12. DevTools
  13. WebMCP
  14. Raw output
  15. Open parameters
  16. URLs with & on Windows

Key facts

License
Apache-2.0
Skill folder last changed
2026-10-31
Installs on skills.sh
204,331 as of 2026-11-01
Node (README)
Node.js 18 or newer
Node (playwright.dev)
Node.js 20 or newer

What it includes

  • Open pages and act on elements by reference

    open starts a browser on a URL. snapshot saves a page outline with element references. click, fill, type, hover, select, check, upload and drag act on those references, CSS selectors or Playwright locators. find searches the page text and eval runs JavaScript.

    Try: “Open https://demo.playwright.dev/todomvc and add a todo called buy milk.”

    Runs code · Core: open, click, fill, snapshot

  • Move through browser history

    Goes back, forward or reloads the current page.

    Network · Navigation: go-back, go-forward, reload

  • Send key presses

    Presses single keys or holds them down and releases them, for shortcuts and form controls.

    Write · Keyboard: press, keydown, keyup

  • Control the pointer by coordinates

    Moves the pointer, presses and releases buttons, and scrolls, for things that do not have a clear element reference.

    Write · Mouse: mousemove, mousedown, mousewheel

  • Save a page as an image or PDF

    Saves the page or one element as a PNG, or the page as a PDF, into your project folder. Useful as proof on a pull request.

    Try: “Take a screenshot of the pricing page and save it.”

    Files · Save as: screenshot, pdf

  • Work with several tabs

    Lists, opens, switches and closes tabs. tab-new with --isolated-context gives a tab its own login.

    Write · Tabs: tab-list, tab-new, tab-select, tab-close

  • Read and save logins and site data

    Reads and writes cookies, local storage and session storage, and saves or loads the whole login state to a file. These files hold auth tokens, so keep them out of git.

    Write · Storage: state-save, cookie-*, localstorage-*

  • Test dark mode and accessibility settings

    Sets or clears color scheme, reduced motion, forced colors, contrast and media type, to check how a page looks under each.

    Write · Emulation: color-scheme, media, contrast

  • Mock or block requests

    Intercepts requests that match a pattern and returns a status or body you choose, or blocks them. Good for testing error states.

    Try: “Block requests to /api/user and check the error message.”

    Write · Network: route, route-list, unroute

  • Debug, record and trace

    Shows console messages and network requests, runs Playwright code, records traces and video, and prints the Playwright code for each action. show opens a dashboard of live sessions, and show --annotate lets you mark up the page for the agent.

    Try: “Check the console for errors after loading the settings page.”

    Runs code · DevTools: console, requests, run-code, tracing, video

  • Call tools a web page offers

    Lists and calls tools that a page registers through the experimental WebMCP feature. Treat their output as untrusted.

    Runs code · WebMCP: webmcp-list, webmcp-call

  • Pick the browser and how it starts

    open takes --browser (chrome, firefox, webkit, msedge), --headed, --mobile, --device, --persistent and --profile. attach connects to a running Chrome or Edge, and delete-data clears stored data.

    Runs code · Open options and attach

From the official docs

Permissions

Medium risk

What it can do

  • Read your data
  • Create and change things
  • Delete things
  • Read-only mode

Watch out for

  • Web pages can try to steer the agent

    Snyk flags W011: the skill opens arbitrary pages and feeds page text, snapshots and page-provided WebMCP tools to the agent. The skill tells the agent to treat them as untrusted. skills.sh

  • Runs JavaScript and Playwright code

    eval and run-code execute code in the page and in Playwright. Gen Agent Trust Hub passed the skill but advises caution on untrusted URLs. skills.sh

  • Can read and save your logins

    cookie-get, localstorage-get and state-save expose session tokens and write them to files. The skill's own notes say never commit state files and delete them after use. github.com

  • Typed passwords showed up in snapshots

    A user found password field values in snapshots sent to the model. Maintainers point to PLAYWRIGHT_MCP_SECRETS_FILE to redact secrets; the issue is closed. github.com

  • Leftover browsers kept running

    Agents that exit without closing sessions left headless Chrome running (one user measured 127 processes, 25 GB). Headless sessions now stop after an hour idle. github.com

  • Writes files into your project

    Snapshots, screenshots, PDFs, videos and traces go to .playwright-cli/ in the workspace; file access is limited to workspace roots by default. github.com

  • Downloads a browser on first use

    The CLI fetches Chrome for Testing (about 170 MiB on Linux in one report) from cdn.playwright.dev the first time it runs. github.com

Security advisories

No published security advisories as of Nov 2, 2026.

Technical details
Turning on read-onlyNo read-only mode. The agent can click, fill and submit forms on any site it opens. You can limit which sites the browser reaches with allowedOrigins/blockedOrigins in .playwright/cli.config.json, which the docs say is not a security boundary.
Talks toAny site the agent opens. cdn.playwright.dev (browser download)
Scopes
  • Runs shell commands

  • Drives a local browser

  • Reads and writes cookies and storage

  • Writes files to .playwright-cli/

What people say

What people like

  • Users moving from Playwright MCP say it is faster and uses less context.
  • Works in Claude Code for local web app debugging with almost no setup.
  • Can switch to Firefox to debug browser-specific bugs.
  • Seen as lighter on context than Chrome DevTools MCP for the same checks.

Common complaints

  • One benchmark found the CLI needed 2-3x the tool calls and took about twice as long as MCP.
  • Another test found token use close to Playwright MCP's.
  • Copilot forgets the skill exists faster than it forgets MCP tools.
  • Each shell command needs approval, or you skip permission checks.

In their words

2 more quotes

Examples

  • Test a demo app end to end and capture evidence (from Playwright's docs).

    Use playwright skills to test https://demo.playwright.dev/todomvc/. Take screenshots for all successful and failing scenarios.

    The agent opens the app, tries each flow and saves screenshots for passes and failures.

    Source
  • Use the CLI without installing the skill (from the README).

    Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli. Check playwright-cli --help for available commands.

    The agent reads the built-in help to find the commands it needs.

    Source
  • A user had Codex explore and play a web game through the skill (reported on Hacker News).

    Use Playwright CLI Skill to open https://playstarfling.com/ and load the game. Work out how to play it, and devise a strategy to win.

    Reported as a Codex session driving the game through the skill.

    Source
  • Ask for design feedback on a local page. The skill maps this to show --annotate, so you can mark up the live page.

    Open http://localhost:3000/settings and ask me for design feedback on the layout.

  • Debug a failing Playwright test. The skill attaches to a test paused with --debug=cli.

    The checkout test is failing. Run it in debug mode, attach with playwright-cli, find out why and fix the locator.

  • Check a UI fix and attach a screenshot to the pull request with gh.

    Check the settings page after my fix, take a screenshot and attach it to PR 123.

Comparison

OptionHow the agent uses itMakerInstallMaker says it suitsTokens, Ranger testTokens, Checkly test
playwright-cliThis pageShell commands + skillMicrosoftnpm install -g @playwright/cli@latestCoding agents with a shell22-24k45-48k
Playwright MCPMCP serverMicrosoftnpx @playwright/mcp@latestExploratory, long-running loops50k48-50k
agent-browserShell commands (Rust CLI)vercel-labsnpm install -g agent-browserBrowser automation for AI agents22-24k–
Chrome DevTools MCPMCP server or CLIChromeDevToolsnpx -y chrome-devtools-mcp@latestDebugging and performance analysis––

Questions

How do I install playwright-cli?

Run npm install -g @playwright/cli@latest, then playwright-cli install --skills in your project. That writes the skill to .claude/skills/playwright-cli. Use --skills=agents for .agents/skills/playwright-cli (Cursor and other agents), or add -g to install it in your home folder for every project. The skills.sh command (npx skills add) copies only the SKILL.md, so you still need the npm package. The browser downloads on first use; playwright-cli install-browser does it by hand. Without the skill, tell the agent to use playwright-cli and check playwright-cli --help.

playwright-cli vs Playwright MCP: which should I use?

Use the CLI if your agent has a shell, such as Claude Code, Copilot or Cursor. Microsoft says it costs fewer tokens because it skips the MCP tool list and loads the skill on demand. Use Playwright MCP for long exploratory or self-healing loops. Independent tests disagree on how much the CLI saves, and one found it slower; the comparison table above has the numbers.

Does playwright-cli work in Claude.ai, Codex, Cursor or Copilot?

Claude Code, GitHub Copilot and Cursor are named in Playwright's docs. It does not work in Claude.ai or ChatGPT chat, because it needs a shell and a local browser. Codex and OpenCode are not in the docs, but users report using it there, and a Playwright maintainer says install --skills works with OpenCode. For Codex, use --skills=agents.

Is playwright-cli safe?

It is Microsoft's own code under Apache-2.0, but it drives a real browser, so give it only sites you trust. skills.sh shows Gen Agent Trust Hub and Socket passing it, and Snyk warning (W011) about indirect prompt injection, which means a web page can try to steer the agent. The agent can run JavaScript in a page, read cookies and save login state to files, so never commit those files. Typed passwords have appeared in snapshots sent to the model. Maintainers point to a secrets file (PLAYWRIGHT_MCP_SECRETS_FILE) to hide them. File access stays inside your workspace by default.

Is playwright-cli the same as npx playwright test or codegen?

No. npx playwright test runs your test files and npx playwright codegen records clicks for a person. playwright-cli is a separate package, @playwright/cli, that lets an agent drive a live browser one command at a time. The skill still calls npx playwright test to run your suites. If Playwright is already a project dependency, npx playwright cli works too.

Can I watch the browser while the agent works?

Yes. It runs headless by default. Add --headed to open to see the window, or run playwright-cli show for a dashboard of every session where you can step in and take over. A headless session shuts down after an hour without commands, and --idle-timeout changes that.

How do I stay logged in between runs?

Add --persistent or --profile=<path> to open to keep the browser profile on disk. By default the profile lives in memory and your login is lost when the browser closes. You can also run state-save auth.json and state-load auth.json. State files hold auth tokens, so keep them out of git and delete them after use. tab-new --isolated-context=<name> gives a tab its own login.

Which Node version does playwright-cli need?

The README and the npm package say Node 18 or newer. Playwright's installation page says Node 20 or newer. Use 20 or newer to be safe.

Why are Chrome processes still running after my agent finished?

The agent probably exited without closing its session. Run playwright-cli list, then close-all or kill-all. Headless sessions now stop after an hour idle, which fixed the worst cases reported in 2026.

Is playwright-cli free?

Yes. It is open source under the Apache-2.0 license and published on npm by Microsoft Corporation. You only pay for the AI client you run it from.

Information

updated Nov 2, 2026

Folder
skills/playwright-cli

microsoft/playwright-cliskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 33
  1. playwright-cli README · github.com
  2. Installation | Playwright CLI · playwright.dev
  3. Coding agents | Playwright · playwright.dev
  4. Agent Skills | Cursor Docs · cursor.com
  5. Playwright CLI introduction · playwright.dev
  6. CLIs are more token-efficient than MCP. Or are they? · checklyhq.com
  7. The Cost of Fewer Tokens: Context Efficiency Makes Playwright CLI Slower · outpost.ranger.net
  8. playwright.dev · playwright.dev
  9. @playwright/cli on npm · registry.npmjs.org
  10. skills.sh · skills.sh
  11. Skills | Playwright CLI · playwright.dev
  12. skills.sh · skills.sh
  13. skills.sh · skills.sh
  14. Commits to skills/playwright-cli · github.com
  15. playwright-cli SKILL.md · github.com
  16. playwright.dev · playwright.dev
  17. Sessions | Playwright CLI · playwright.dev
  18. GitHub · github.com
  19. github.com · github.com
  20. github.com · github.com
  21. github.com · github.com
  22. github.com · github.com
  23. Hacker News · news.ycombinator.com
  24. Hacker News · news.ycombinator.com
  25. GitHub · github.com
  26. Hacker News · news.ycombinator.com
  27. Hacker News · news.ycombinator.com
  28. GitHub · github.com
  29. Hacker News · news.ycombinator.com
  30. Hacker News · news.ycombinator.com
  31. Playwright MCP README · github.com
  32. agent-browser README · github.com
  33. Chrome DevTools for agents README · github.com

Updated Nov 2, 2026.