Playwright CLI: a browser your coding agent drives from the shell
Microsoft quietly shipped another way to drive a browser: Playwright CLI. It's not a test runner and not an MCP server — it's browser automation exposed as plain shell commands, built specifically so coding agents can click around the web without incinerating their context window. I spent an evening reading the repo, the docs, and the pushback, so here are my field notes.
What it actually is
Don't confuse this with the npx playwright command that ships with the test runner. microsoft/playwright-cli is a separate package (@playwright/cli, Apache-2.0, already sitting at roughly 12k stars) that wraps Playwright in short, stateful commands. A daemon keeps the browser alive between invocations, so each command is cheap. You get sessions for multiple isolated browser instances, cookies/storage management, network mocking, tracing, video, and a rather nice playwright-cli show dashboard where you can watch — and interrupt — whatever your agent is doing in the background.
The pitch is disarmingly simple: agents already know how to run shell commands. Instead of teaching your assistant a tool schema, you let it read --help and get on with it.
What using it looks like
Every action prints a compact accessibility snapshot of the page with element references (e15 and friends), which the agent then targets deterministically in the next command. From the README and docs, verbatim:
# install once, globally
npm install -g @playwright/cli@latest
playwright-cli install --skills
# drive a page
playwright-cli open https://demo.playwright.dev/todomvc --headed
playwright-cli type "Buy groceries"
playwright-cli press Enter
playwright-cli snapshot
playwright-cli click e15
playwright-cli screenshot
# watch what your agent is up to
playwright-cli show
That install --skills step drops skill files (for Claude Code, Copilot and co.) that teach the agent common workflows — testing, debugging, request mocking, test generation — on demand instead of front-loading everything into the prompt.
Why not just use Playwright MCP?
This is the interesting part, and the team is refreshingly explicit about it:
"Modern coding agents increasingly favor CLI-based workflows exposed as skills over MCP because CLI invocations are more token-efficient." — the Playwright CLI README
Playwright MCP streams tool schemas and full accessibility trees into the model's context after every step; by step twelve of a session you're hauling around a lot of stale page snapshots. The CLI writes artifacts to disk and lets the agent decide what to actually read back. One widely shared write-up measured ~114k tokens for a task via MCP versus ~27k via the CLI, and Microsoft's own framing claims roughly 4x savings. For someone like me who mostly wants an agent to verify a UI change on a Drupal site — not narrate the entire DOM — that's appealing.
The caveats nobody puts in the announcement
The token story has a counterpoint worth knowing before you rip out your MCP config. Engineers at Ranger benchmarked identical scenarios across both and found the efficiency is real but not free:
- MCP finished in ~90–120 seconds per scenario; the CLI took ~240–300. The slowest MCP run beat the fastest CLI run.
- The CLI needed 2–3x more tool calls (40 vs 14 in one scenario), because the agent has to ask for page state it would otherwise get automatically — every call is another round trip.
- Cost per run ended up nearly identical (~$0.39–0.54); the CLI's extra output turns ate the input-token savings.
So "token-efficient" does not automatically mean faster or cheaper. It means your context stays clean for longer sessions and bigger codebases — which is a different, and for my use case arguably better, win. Several teams sensibly use both: MCP for quick interactive poking, CLI for longer production automation and test generation. Also worth noting: this is a v0.1.x project. It moves fast and the surface is still settling.
Where it lands for me
My honest take: for the "agent, please check that my form actually submits" loop I run daily, the CLI model fits how I already work — everything is a command, everything is inspectable, and show means I can watch the robot instead of trusting it. The official Playwright channel has a short video on exactly that workflow — giving UI reviews to coding agents — which is the best five-minute overview I found.
I haven't wired it into a real project pipeline yet, so no benchmark numbers of my own — but it's going in next sprint's experiment column.