Playwright CLI Skill
Metadata
- Trigger when: the user needs browser automation or browser-state inspection from the terminal.
- Do not use when: the task is to author Playwright test files or when a different built-in browser tool already solves the job better.
Skill Purpose
Provide a deterministic CLI-first browser workflow that always starts from a fresh snapshot and uses stable element refs instead of ad hoc DOM poking.
Instructions
- Check prerequisites first:
command -v npx >/dev/null 2>&1. Ifnpxis missing, stop and ask the user to install Node/npm. Otherwise use the exact wrapper script at~/.codex/skills/playwright/scripts/playwright_cli.sh. - Run the core loop through the wrapper: open the page, snapshot, interact using refs from the latest snapshot, and snapshot again after navigation or major DOM change. Use
~/.codex/skills/playwright/references/cli.mdfor command reference and~/.codex/skills/playwright/references/workflows.mdfor troubleshooting only when needed. - Capture artifacts such as screenshots, PDFs, or traces when they help. Keep the workflow explicit and CLI-based; do not pivot into Playwright test code unless the user explicitly asked for test files.
Non-Negotiable Acceptance Criteria
- Always snapshot before using element refs like
e12. - Re-snapshot after navigation, modal changes, tab switches, or any UI change that could stale refs.
- Prefer explicit CLI commands over
eval/custom code when the wrapper can already do the job. - Use
--headedwhen a visual check materially helps.
Output
- A concise command sequence or workflow summary.
- Latest relevant element refs or artifact paths when the task depends on them.
- A short note on whether the flow succeeded, stalled on stale refs, or needs a new snapshot.