Playwright CLI Skill
Drive a real browser using an already available, supported playwright-cli or
host browser capability. Match the commands and documentation to that version.
Treat this skill as CLI-first automation. Do not pivot to @playwright/test unless the user explicitly asks for test files.
Capability Discovery
@playwright/cli and @playwright/mcp are different packages and interfaces.
The reviewed Playwright MCP release is 0.0.86 (Node.js >= 20 required); it does not
establish the CLI's version or command support. When driving @playwright/mcp 0.0.86+:
extension tab-group sessions support --session-name / --session-color, browser_close
closes the entire browser and all tabs (use browser_tabs with action: "close" to close
a single tab), downloads preserve collision-safe filenames, and Linux ARM64 Chrome installs
via npx @playwright/mcp@0.0.86 install-browser chrome. Native Browser/Chrome plugins use
their host's current tools and lifecycle documentation. Keep refs and session handles within
the chosen backend instead of translating them by name.
Check the project's installed CLI and the host's browser tools before choosing
an execution path. Missing npx alone is not a reason to stop all work. If a
dependency must be acquired, reuse existing installation authorization, choose
a compatible fixed version and an isolated local runner; do not install globally
as a loading side effect. Without browser capability, complete independent static
work and state which browser acceptance checks were not run.
Skill path (set once)
PWCLI="/absolute/path/to/verified/installed/playwright-cli"
Resolve PWCLI from the selected installed CLI; keep host environment variables
unchanged. Resolve any bundled helper from the actual loaded skill directory.
Quick start
Use the verified installed CLI selected above:
"$PWCLI" open https://playwright.dev --headed
"$PWCLI" snapshot
"$PWCLI" click e15
"$PWCLI" type "Playwright"
"$PWCLI" press Enter
"$PWCLI" screenshot
Use only commands supported by that CLI version. Installation, if necessary,
is a separate scoped dependency change under existing authorization.
Core workflow
- Open the page.
- Snapshot to get stable element refs.
- Interact using refs from the latest snapshot.
- Re-snapshot after navigation or significant DOM changes.
- Capture artifacts (screenshot, pdf, traces) when useful.
Minimal loop:
"$PWCLI" open https://example.com
"$PWCLI" snapshot
"$PWCLI" click e3
"$PWCLI" snapshot
When to snapshot again
Snapshot again after:
- navigation
- clicking elements that change the UI substantially
- opening/closing modals or menus
- tab switches
Refs can go stale. When a command fails due to a missing ref, snapshot again.
Recommended patterns
Form fill and submit
"$PWCLI" open https://example.com/form
"$PWCLI" snapshot
"$PWCLI" fill e1 "user@example.com"
"$PWCLI" fill e2 "password123"
"$PWCLI" click e3
"$PWCLI" snapshot
Debug a UI flow with traces
"$PWCLI" open https://example.com --headed
"$PWCLI" tracing-start
# ...interactions...
"$PWCLI" tracing-stop
Multi-tab work
"$PWCLI" tab-new https://example.com
"$PWCLI" tab-list
"$PWCLI" tab-select 0
"$PWCLI" snapshot
Wrapper script
The bundled scripts/playwright_cli.sh actually executes
npx --yes --package @playwright/cli playwright-cli: it may download an unpinned
package even for --help. It preserves explicit --session or injects
PLAYWRIGHT_CLI_SESSION, but does not enforce a fixed dependency version.
Use an existing verified CLI directly; use a separately pinned local invocation
only when acquisition is authorized. Do not treat the wrapper as an offline or
version-locked runner. For the selected CLI:
"$PWCLI" --help
Keep the session and fresh-snapshot loop with the selected supported runner.
References
Open only what you need:
- CLI command reference:
references/cli.md - Practical workflows and troubleshooting:
references/workflows.md
Guardrails
- Always snapshot before referencing element ids like
e12. - Re-snapshot when refs seem stale.
- Prefer explicit commands over
evalandrun-codeunless needed. - When you do not have a fresh snapshot, use placeholder refs like
eXand say why; do not bypass refs withrun-code. - Use
--headedwhen a visual check will help. - When capturing artifacts in this repo, use
output/playwright/and avoid introducing new top-level artifact folders. - Default to CLI commands and workflows, not Playwright test specs.