mk:playwright-cli
Scripted browser control through the Playwright CLI using accessibility snapshots and element refs.
| Source | .claude/skills/playwright-cli/SKILL.md |
| Owner | testing |
| Runtime | claude-code |
| Risk | medium |
What it does
Drives a browser from the shell with the Playwright CLI. It reads the page as an accessibility snapshot with element refs (e1, e2, ...) and acts on those refs. Use it for a known click-and-type sequence: DOM interaction, navigation, form filling, data extraction, screenshots, or generating reusable .spec.ts E2E test code.
When not to use
Use mk:agent-browser when you need session persistence across auth flows, MFA or cookie import.
Usage
playwright-cli open https://example.com/form
playwright-cli snapshot
playwright-cli fill e1 "user@example.com"
playwright-cli click e3
playwright-cli snapshot
playwright-cli closeIf the global binary is missing, run npx --yes @playwright/cli@0.1.24 <command> (the bare playwright-cli package name is deprecated).
| Group | Commands |
|---|---|
| Navigate | open <url>, goto <url>, go-back, go-forward, reload |
| Interact | click, fill e5 "text" (clears first), type "text", press Enter, select e9 "value", check, uncheck |
| Capture | snapshot [--filename=x.yaml], screenshot [--filename=x.png], pdf --filename=x.pdf |
| Sessions | -s=NAME open <url> --persistent, list, close, close-all, kill-all |
| Auth state | state-save auth.json, state-load auth.json |
| Storage | cookie-list, cookie-set, cookie-delete, cookie-clear, localstorage-get, localstorage-set |
| Network | route "<pattern>" --status=404, route "<pattern>" --body='{...}', unroute, network |
| Debug | console, tracing-start, tracing-stop, video-start, video-stop x.webm, run-code "async page => ..." |
The full list is references/command-reference.md. Topic references are session-management.md, request-mocking.md, storage-state.md, test-generation.md, tracing.md, video-recording.md and running-code.md.
Steps
open <url>, thensnapshotto get refs.- Interact using refs.
- Take a new snapshot after navigation or a DOM change, because refs can change.
closewhen done.
Outputs
After each command a snapshot is written as YAML under .playwright-cli/, with a timestamped name. Pass --filename= when the file is a workflow result. Named sessions run isolated contexts with separate cookies, storage and history.
Setup
The skill states that it needs the Playwright MCP server (npx @playwright/mcp@latest) configured in .mcp.json.
Gotchas
On single-page apps data-testid values can change between renders, so prefer role-based selectors such as getByRole. Each run starts with a fresh context, so use state-save and state-load to keep auth cookies between runs.
mk:chrome-profile
Connects agent-browser to a real Chrome profile over CDP so automation keeps that profile cookies, extensions and logins.
mk:frontend-design
Designs and reviews UI components for typography, color, spacing, motion, responsiveness and WCAG 2.1 AA accessibility, with an anti-generic-design checklist.