Use for committed Playwright regression tests, existing Playwright suites, CI browser gates, traces for reproducible failures, and explicit user requests to write or run Playwright test files. Do not use for ordinary agent browser interaction, scraping, form filling, screenshots, or localhost visual QA; route those to agent-browser unless the repo's existing test suite requires Playwright.
Use Playwright as the regression ratchet: codified tests, CI gates, and reproducible traces. Prefer [[agent-browser]] for interactive agent browser work such as browsing, scraping, filling forms, screenshots, visual checks, and localhost QA.
If this skill triggers because the user said "use Playwright" for generic browsing, first check whether they asked for committed test files. If not, use agent-browser and explain that Playwright is reserved for durable tests.
Before proposing commands, check whether npx is available (the wrapper depends on it):
command -v npx >/dev/null 2>&1If it is not available, pause and ask the user to install Node.js/npm (which provides npx). Provide these steps verbatim:
# Verify Node/npm are installed
node --version
npm --version
# If missing, install Node.js/npm, then:
npm install -g @playwright/cli@latest
playwright-cli --helpOnce npx is present, proceed with the wrapper script. A global install of playwright-cli is optional.
export CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
export PWCLI="$CODEX_HOME/skills/playwright/scripts/playwright_cli.sh"User-scoped skills install under $CODEX_HOME/skills (default: ~/.codex/skills).
Use the wrapper script when you are running an existing suite or collecting a reproducible trace:
"$PWCLI" open https://playwright.dev --headed
"$PWCLI" snapshot
"$PWCLI" click e15
"$PWCLI" type "Playwright"
"$PWCLI" press Enter
"$PWCLI" screenshotIf the user prefers a global install, this is also valid:
npm install -g @playwright/cli@latest
playwright-cli --helpMinimal existing-suite loop:
npx playwright test --list
npx playwright test path/to/spec.ts --trace onSnapshot again after:
Refs can go stale. When a command fails due to a missing ref, snapshot again.
npx playwright codegen http://localhost:3000
npx playwright test path/to/new.spec.ts --trace on"$PWCLI" open https://example.com --headed
"$PWCLI" tracing-start
# ...interactions...
"$PWCLI" tracing-stop"$PWCLI" tab-new https://example.com
"$PWCLI" tab-list
"$PWCLI" tab-select 0
"$PWCLI" snapshotThe wrapper script uses npx --package @playwright/cli playwright-cli so the CLI can run without a global install:
"$PWCLI" --helpPrefer the wrapper unless the repository already standardizes on a global install.
Open only what you need:
references/cli.mdreferences/workflows.mdagent-browser.--headed or --trace on when reproducibility matters.output/playwright/ and avoid introducing new top-level artifact folders.