What is playwright-cli?
playwright-cli is how AI coding agents interact with a live browser. Click, navigate, capture locators, and document what you find for real test implementation.
All from the terminal.
Playwright vs playwright-cli vs MCP
Three related tools, three different jobs. Keep them distinct so your agent uses the right one.
| Tool | Purpose | Best fit |
|---|---|---|
| npx playwright ... | Project lifecycle: install, test, reports, traces | Building and running tests |
| playwright-cli ... | Live browser control from the terminal | Demos, AI agents, locator discovery, debugging |
| Playwright MCP | Browser control through MCP tools | Same as playwright-cli, but older approach (not recommended) |
npx playwright ...
Purpose: Project lifecycle: install, test, reports, traces
Best fit: Building and running tests
playwright-cli ...
Purpose: Live browser control from the terminal
Best fit: Demos, AI agents, locator discovery, debugging
Playwright MCP
Purpose: Browser control through MCP tools
Best fit: Same as playwright-cli, but older approach (not recommended)
playwright-cli and Playwright MCP complement Playwright. They do not replace it.
How It Works
open → snapshot → act → snapshot → inspect → document
Open
Start a browser session. Headless by default; add --headed if you want to watch.
Snapshot
Capture the accessibility tree. Every element gets a stable ref like e12. The agent reads this as plain text.
Act
Click, fill, and navigate using refs from the latest snapshot. Each command can output the equivalent Playwright locator.
Verify
Snapshot again after each meaningful action so the agent sees the new page state instead of guessing.
Inspect
Check cookies, storage, and network requests when the flow depends on session state or APIs.
Document
Capture stable locators and flow notes in a handoff file (for example locators.md) so another engineer or agent can write reliable tests.
Core Capabilities
Agent-Native Browser Control
Point your AI coding agent at any URL, and it converts the page into structured, machine-readable data. Every button, input, and link gets a stable ref so your agent can click, fill, navigate, and extract data while you supervise.
Inspect Browser State, Not Just the UI
Real automation needs more than visible elements. Check network requests, cookies, and storage when login or cart flows depend on session state. Convert snapshot refs into Playwright locators for your handoff notes.
Language & Framework Agnostic
Your agent explores the live app through playwright-cli, captures locators and page behavior, then writes tests in your preferred language and framework. Playwright, Selenium, Cypress, or anything else—your stack stays the same.
Up and Running in 3 Steps
No config files, no server to run, no MCP setup. Install globally, add skills, and tell your agent where to find them.
- 1
Install the CLI
Install playwright-cli globally. One command, works with Node.js 18+.
- 2
Install Skills
Skills are markdown files your coding agent reads at the start of every task. They describe every playwright-cli command so your agent knows how to use it without you explaining each time.
- 3
Update your
AGENTS.mdKeep these three names distinct in
AGENTS.md:- Playwright— the test framework you write tests in
- Playwright MCP— MCP-based browser tools for agent loops
- playwright-cli— terminal control for live browser work with coding agents
Try it on a real demo store
Works with every AI agent & LLM
Bring your own agent. playwright-cli is the browser layer.
AI Coding Agents
All Major LLMs
Built for QA automation
QA engineers, automation engineers, and SDETs use playwright-cli when they work with AI coding agents on real browser tasks.
QA Engineers
QA Automation Engineers
SDETs
Want a guided live walkthrough of the full AI workflow? See the workshop.