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
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
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
- Quick start
- Commands
- Core
- Navigation
- Keyboard
- Mouse
- Save as
- Tabs
- Storage
- Emulation
- Network
- DevTools
- WebMCP
- Raw output
- Open parameters
- URLs with & on Windows
Key facts
- License
- Apache-2.0
- First release
- 0.0.60 on npm, 2026-01-26
- 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
- Browser
- Downloads on first use
- skills.sh audits
- Gen Agent Trust Hub pass, Socket pass, Snyk warn
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, snapshotMove through browser history
Goes back, forward or reloads the current page.
Network ·
Navigation: go-back, go-forward, reloadSend key presses
Presses single keys or holds them down and releases them, for shortcuts and form controls.
Write ·
Keyboard: press, keydown, keyupControl 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, mousewheelSave 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, pdfWork 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-closeRead 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, contrastMock 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, unrouteDebug, 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, videoCall 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-callPick 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 attachRun and clean up named sessions
Named sessions (-s=name or PLAYWRIGHT_CLI_SESSION) keep separate browsers. list shows them, and close-all or kill-all stops them. Run these if Chrome is left running.
Runs code ·
Sessions: -s, list, close-all, kill-allMake output easy to pipe
--raw prints only the result and --json prints structured output, so another command or script can read it.
Read ·
Output flags: --raw, --json
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-only | No 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 to | Any site the agent opens. cdn.playwright.dev (browser download) |
| Scopes |
|
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
“Here my first reaction to Playwright CLI compared to the MCP: it works better, faster, and indeed consume less context.”gsemetHacker NewsMay 2026
“Using playwright-cli with Claude code is highly effective for debugging locally deployed web apps with essentially zero setup.”lsaferiteHacker NewsJul 2026
“It works much faster for me than the MCP servers I tried.”egeozcanBlogJul 2026
“There's no big difference in using CLIs or MCPs these days.”Stefan Judis (Checkly)
2 more quotesFewer quotes
“The MCP case consistently took about half the time as the CLI.”Mikayla Thompson (Ranger)GitHub issueApr 2026
“I had similar issues with MCP where there were so many orphaned playwright mcp servers - that was one of the major reasons I switched to cli - now, instead of orphaned mcp servers, I see orphaned chrome processes”tvvignesh
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.
SourceUse 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.
SourceA 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.
SourceAsk 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
| Option | How the agent uses it | Maker | Install | Maker says it suits | Tokens, Ranger test | Tokens, Checkly test |
|---|---|---|---|---|---|---|
| playwright-cliThis page | Shell commands + skill | Microsoft | npm install -g @playwright/cli@latest | Coding agents with a shell | 22-24k | 45-48k |
| Playwright MCP | MCP server | Microsoft | npx @playwright/mcp@latest | Exploratory, long-running loops | 50k | 48-50k |
| agent-browser | Shell commands (Rust CLI) | vercel-labs | npm install -g agent-browser | Browser automation for AI agents | 22-24k | – |
| Chrome DevTools MCP | MCP server or CLI | ChromeDevTools | npx -y chrome-devtools-mcp@latest | Debugging 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
- Repository
- microsoft/playwright-cli
- Folder
skills/playwright-cli
Sources
Docs, issue trackers and discussions this page is built from.
Show all 33Hide
- playwright-cli README · github.com
- Installation | Playwright CLI · playwright.dev
- Coding agents | Playwright · playwright.dev
- Agent Skills | Cursor Docs · cursor.com
- Playwright CLI introduction · playwright.dev
- CLIs are more token-efficient than MCP. Or are they? · checklyhq.com
- The Cost of Fewer Tokens: Context Efficiency Makes Playwright CLI Slower · outpost.ranger.net
- playwright.dev · playwright.dev
- @playwright/cli on npm · registry.npmjs.org
- skills.sh · skills.sh
- Skills | Playwright CLI · playwright.dev
- skills.sh · skills.sh
- skills.sh · skills.sh
- Commits to skills/playwright-cli · github.com
- playwright-cli SKILL.md · github.com
- playwright.dev · playwright.dev
- Sessions | Playwright CLI · playwright.dev
- GitHub · github.com
- github.com · github.com
- github.com · github.com
- github.com · github.com
- github.com · github.com
- Hacker News · news.ycombinator.com
- Hacker News · news.ycombinator.com
- GitHub · github.com
- Hacker News · news.ycombinator.com
- Hacker News · news.ycombinator.com
- GitHub · github.com
- Hacker News · news.ycombinator.com
- Hacker News · news.ycombinator.com
- Playwright MCP README · github.com
- agent-browser README · github.com
- Chrome DevTools for agents README · github.com