Playwright CLI
playwright-cli
Microsoft's official Playwright CLI with an agent skill: drive a browser through short commands without heavy MCP schemas
Install
npm install -g @playwright/cli@latest
playwright-cli install --skillsThe second command installs skills picked up by Claude Code, GitHub Copilot and other agents.
This is third-party code. Review the repository files before installing.
What it does
The CLI gives the agent browser commands: open a page, click, fill a field, take an accessibility snapshot, search the snapshot, screenshot or save a PDF. It handles tabs, cookies and localStorage, network mocking, console and request inspection, traces, video and action recording that emits Playwright code. Snapshots are saved to files, so page data does not flood the model context. Sessions keep separate browsers per project, and the show command opens a dashboard to watch agents and take over control.
Who it is for. For developers and QA engineers who want the agent to test web apps in a browser with fewer tokens than MCP.
Good fit when
- The agent should walk through a user flow and take screenshots
- You need to record actions and get Playwright test code
- Agent context is tight and MCP schemas are too costly
Not a fit when
- You need a long autonomous loop with persistent page state; Playwright MCP fits better
- The agent cannot run shell commands
Example request
Using playwright-cli, test the add todo flow on demo.playwright.dev/todomvc and take screenshotsLimitations
Requires Node.js 18 or newer and shell access. Headless sessions close after an hour idle. WebMCP is experimental and works only in Chromium and Firefox with special flags.
How to disable. Remove the package with npm uninstall -g @playwright/cli and delete the playwright-cli skill folder.
Security check
- Launches a browser and runs JavaScript on pages
- Can save and load cookies and auth state
README in short
The README compares the CLI with Playwright MCP and explains why CLI plus skills is cheaper for coding agents. Install is via npm plus a separate skills command. It then gives a full command reference grouped into core, navigation, keyboard, mouse, storage, network, DevTools, WebMCP and open options. Sessions, the monitoring dashboard and snapshot format are covered.
SKILL.md
--- name: playwright-cli description: Automate browser interactions, test web pages and work with Playwright tests. allowed-tools: Bash(playwright-cli:*) Bash(npx:*) Bash(npm:*) --- # Browser Automation with playwright-cli ## Quick start ```bash # open new browser playwright-cli open # navigate to a page playwright-cli goto https://playwright.dev # interact with the page using refs from the snapshot playwright-cli click e15 playwright-cli type "page.click" playwright-cli press Enter # take a screenshot (rarely used, as snapshot is more common) playwright-cli screenshot # close the browser playwright-cli close ``` ## Commands ### Core ```bash playwright-cli open # open and navigate right away playwright-cli open https://example.com/ playwright-cli goto https://playwright.dev playwright-cli type "search query" playwright-cli click e3 playwright-cli dblclick e7 # --submit presses Enter after filling the element playwright-cli fill e5 "user@example.com" --submit playwright-cli drag e2 e8 playwright-cli hover e4 playwright-cli select e9 "option-value" playwright-cli upload ./document.pdf playwright-cli check e12 playwright-cli uncheck e12 playwright-cli snapshot
FAQ
Why CLI over Playwright MCP?
It avoids loading large tool schemas and accessibility trees into context, so it is cheaper. MCP stays better for long loops with persistent state.
Does it work without the skill?
Yes, just tell the agent to check playwright-cli --help.
Related
The official MCP server debugger: web UI, automation CLI and terminal UI in one package
SonarSource's official MCP server: quality and security issues, quality gates and code analysis from SonarQube Server and Cloud
Open-source AI agent for pull request review: descriptions, feedback and improvement suggestions on GitHub, GitLab and more
A community Playwright MCP server: browser automation, screenshots, device emulation and test code generation