Jorge Turbica / blog · Blog ← All articles ES · Leer en español
AI

Skill of the day: playwright-cli, your agent tests the web and writes the test

Microsoft's official skill gives your agent a browser from the terminal and turns every click into Playwright code. How to use it and what to watch.

Every click your agent makes in the browser comes back as a line of Playwright TypeScript, ready to paste into a test. That's the idea behind playwright-cli, Microsoft's official skill for Claude Code, GitHub Copilot and other agents: it has around 224,000 installs on skills.sh, its repo is past 15,300 stars, and the latest package release, 0.1.25, shipped on November 18, 2026.

What it does

The skill teaches the agent to drive a real browser with short terminal commands (open, goto, click, fill, snapshot) instead of calling tools on an MCP server. It kicks in when you ask for something like "test the sign-up flow on this URL" or "debug this failing Playwright test".

The loop is always the same. The agent opens a session, takes a snapshot (the page's accessibility tree, with a short reference for each element, such as e15) and acts on those references. What matters is where that snapshot goes: it's written to a YAML file under .playwright-cli/, and the agent reads only what it needs, with find "Sign in" or snapshot --depth=4. The whole page doesn't land in the context on every step, which is what makes LLM-driven browser automation expensive.

Beyond clicking, the SKILL.md covers cookies and localStorage, request mocking with route, console and network inspection, tracing, video, emulating dark mode or reduced motion, and any tools a page exposes through the experimental WebMCP API.

The part I find most useful for a team is testing. Every action prints the equivalent Playwright code with semantic locators (getByRole('button', { name: 'Sign In' })), and the skill ships a three-step plan → generate → heal workflow: explore the app and write a spec, turn it into test files, and fix the ones that fail. To debug, the agent runs npx playwright test --debug=cli in the background, the test pauses, and playwright-cli attach hands it that page.

How to install it

It needs Node.js 20 or later. With the global CLI, the CLI itself installs the skill into your project:

bash
npm install -g @playwright/cli@latest
playwright-cli install --skills

Or use the generic Agent Skills installer:

bash
npx skills add https://github.com/microsoft/playwright-cli --skill playwright-cli

If the project already has Playwright 1.59 or later, the skill uses npx playwright cli and the global package isn't needed. From there you just ask: "test the add-todo flow on https://demo.playwright.dev/todomvc with playwright-cli and screenshot the failing cases". To watch it work, playwright-cli show opens a dashboard with a live view of every session and lets you take over with the mouse.

Risks and limits

The skill has no scripts of its own: it's a SKILL.md plus ten reference documents, all Apache 2.0. The risk lies in what it allows. Its allowed-tools header grants Bash(playwright-cli:*), Bash(npx playwright:*) and Bash(npx --no-install playwright:*), so the agent can run your test suite, which is project code, and run-code executes arbitrary JavaScript in the page.

The caveat that really matters is credentials. attach --extension=chrome and attach --cdp=chrome hook the agent into your own browser, logged-in sessions included; cookie-get prints session tokens in plain text, and state-save auth.json dumps cookies and localStorage to a file. Use test profiles, not yours, and add .playwright-cli/ and any auth.json to .gitignore: snapshots store the content of every page visited.

It's not a stable release either: the package is still at 0.x, so pin the version in CI rather than installing @latest.

playwright-cli vs Playwright MCP

The obvious alternative is the same team's MCP server, which works with any MCP client and is added to Claude Code with claude mcp add playwright npx @playwright/mcp@latest. The CLI's README spells out the trade-off: the CLI keeps tool schemas and accessibility trees out of the context, while MCP pays off in long loops that need persistent state and continuous inspection of the page.

playwright-cli (skill)Playwright MCP
InterfaceTerminal commands described in a SKILL.mdTools on an MCP server
Page snapshotWritten to a file; the agent searches itReturned with each tool call (configurable)
Best fitCoding agents that also edit, test and reasonLong exploration, self-healing tests
LicenseApache 2.0Apache 2.0
ClientsAgents with Agent Skills: Claude Code, Copilot…Any MCP client: VS Code, Cursor, Claude Desktop…

If your agent already lives in the terminal and you want it to write and fix E2E tests, the skill is the lighter option. If you need an agent that browses for a long time with the page always in view, MCP still makes sense.

Sources

Jorge Turbica

Software Engineer and SRE. I write about the real challenges I run into in production.

See portfolio ↗