
Playwright Cli
Drive Playwright CLI snapshots, eval probes, and test runs from your coding agent when E2E tests fail or selectors are unclear.
Overview
Playwright-cli is an agent skill for the Ship phase that guides solo builders to inspect elements, run Playwright tests, and debug sessions via Microsoft's playwright-cli.
Install
npx skills add https://github.com/microsoft/playwright-cli --skill playwright-cliWhat is this skill?
- Inspect hidden DOM via `playwright-cli eval` on snapshot element refs (id, class, data-*, aria-label, computed styles)
- Run full suites with `PLAYWRIGHT_HTML_OPEN=never` to avoid blocking interactive HTML reports
- Debug failing tests using `npx playwright test --debug=cli` plus follow-on `playwright-cli` against the printed session
- Background long-running debug commands until debugging instructions appear, then stop cleanly when finished
Adoption & trust: 51.6k installs on skills.sh; 11.1k GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent sees a shallow accessibility snapshot and cannot reliably target elements or reproduce failing Playwright tests from the chat.
Who is it for?
Indie devs shipping web apps with Playwright who want their agent to run tests and debug in the same repo workflow.
Skip if: Teams that only use non-Playwright E2E stacks or want hosted browser farms without a local Playwright project.
When should I use this skill?
When inspecting DOM beyond snapshots, running Playwright tests non-interactively, or debugging failures with `--debug=cli` and playwright-cli.
What do I get? / Deliverables
You get deterministic CLI steps to probe DOM attributes, run suites non-interactively, and attach playwright-cli to an active debug session until the test passes.
- Executed test run output with controlled HTML report behavior
- Element attribute probes via playwright-cli eval
- Active debug session steps tied to a named Playwright CLI session
Recommended Skills
Journey fit
End-to-end browser verification and test debugging belong in Ship, where solo builders validate behavior before release. The skill documents running `npx playwright test`, non-interactive HTML report settings, and `--debug=cli` sessions—core testing workflows.
How it compares
Agent-oriented Playwright CLI recipes—not a replacement for writing specs in `@playwright/test` or a remote browser MCP.
Common Questions / FAQ
Who is playwright-cli for?
Solo and indie builders using Claude Code, Cursor, or Codex who already have Playwright in the repo and want the agent to execute CLI debugging steps safely.
When should I use playwright-cli?
Use it in Ship/testing when E2E tests fail, when snapshots hide selectors, or when you need to run `npx playwright test` with non-interactive reporting during launch prep or post-deploy verification.
Is playwright-cli safe to install?
It implies shell and browser automation against your machine; review the Security Audits panel on this Prism page and restrict agent permissions in CI as you would for any test runner.
SKILL.md
READMESKILL.md - Playwright Cli
# Inspecting Element Attributes When the snapshot doesn't show an element's `id`, `class`, `data-*` attributes, or other DOM properties, use `eval` to inspect them. ## Examples ```bash playwright-cli snapshot # snapshot shows a button as e7 but doesn't reveal its id or data attributes # get the element's id playwright-cli eval "el => el.id" e7 # get all CSS classes playwright-cli eval "el => el.className" e7 # get a specific attribute playwright-cli eval "el => el.getAttribute('data-testid')" e7 playwright-cli eval "el => el.getAttribute('aria-label')" e7 # get a computed style property playwright-cli eval "el => getComputedStyle(el).display" e7 ``` # Running Playwright Tests To run Playwright tests, use the `npx playwright test` command, or a package manager script. To avoid opening the interactive html report, use `PLAYWRIGHT_HTML_OPEN=never` environment variable. ```bash # Run all tests PLAYWRIGHT_HTML_OPEN=never npx playwright test # Run all tests through a custom npm script PLAYWRIGHT_HTML_OPEN=never npm run special-test-command ``` # Debugging Playwright Tests To debug a failing Playwright test, run it with `--debug=cli` option. This command will pause the test at the start and print the debugging instructions. **IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed. Make sure to stop the command after you have finished. Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page. ```bash # Run the test PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli # ... # ... debugging instructions for "tw-abcdef" session ... # ... # Attach to the test playwright-cli attach tw-abcdef ``` Keep the test running in the background while you explore and look for a fix. The test is paused at the start, so you should step over or pause at a particular location where the problem is most likely to be. Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code. This code appears in the output and can be copied directly into the test. Most of the time, a specific locator or an expectation should be updated, but it could also be a bug in the app. Use your judgement. After fixing the test, stop the background test run. Rerun to check that test passes. # Request Mocking Intercept, mock, modify, and block network requests. ## CLI Route Commands ```bash # Mock with custom status playwright-cli route "**/*.jpg" --status=404 # Mock with JSON body playwright-cli route "**/api/users" --body='[{"id":1,"name":"Alice"}]' --content-type=application/json # Mock with custom headers playwright-cli route "**/api/data" --body='{"ok":true}' --header="X-Custom: value" # Remove headers from requests playwright-cli route "**/*" --remove-header=cookie,authorization # List active routes playwright-cli route-list # Remove a route or all routes playwright-cli unroute "**/*.jpg" playwright-cli unroute ``` ## URL Patterns ``` **/api/users - Exact path match **/api/*/details - Wildcard in path **/*.{png,jpg,jpeg} - Match file extensions **/search?q=* - Match query parameters ``` ## Advanced Mocking with run-code For conditional responses, request body inspection, response modification, or delays: ### Conditional Response Based on Request ```bash playwright-cli run-code "async page => { await page.route('**/api/login', route => { const body = route.request().postDataJSON(); if (body.username === 'admin') { route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) }); } else { route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) }); } }); }" ``` ### Modify Real Response ```bash playwright-cli run-code "async page => { await page.route('**/api/user', async route => { const response = await route.fetch(); const json = await response.json(); json.isPremium = true; await route.f