Browser automation with Playwright CLI
Drives a real browser from the terminal with playwright-cli: snapshots give element refs for clicks and typing, plus screenshots, console, network and traces, with no test files written. Use when a task needs a browser clicked through step by step.
playwright- Author
- OpenAI
- Source
- openai/skills/skills/.curated/playwright @ 49f948f
- License
- Apache-2.0
About this skill
What it does
The skill lets the agent drive a real browser from the terminal with playwright-cli, one command at a time: open a page, take a snapshot, act on an element, look again. The snapshot gives every element a short ref such as e3, and click, fill, select or check take those refs. After navigation, a modal or a tab switch the agent snapshots again because refs go stale, and it does not bypass refs with eval or run-code without a reason. It saves screenshots and PDFs, reads the console and network log, records traces, works across tabs and keeps named sessions apart (--session or PLAYWRIGHT_CLI_SESSION). Artifacts go to output/playwright/. It writes @playwright/test specs only if you ask.
scripts/playwright_cli.sh runs npx --yes --package @playwright/cli playwright-cli, so no global install is needed, and passes the session variable on. references/cli.md lists the main commands; references/workflows.md shows common flows and a playwright-cli.json config. NOTICE.txt says the skill is adapted from Microsoft's playwright-cli skill.
When to use it, and when not
Use it to click through a flow, fill a form, pull data from a page, take screenshots, or reproduce a UI bug with the console at hand.
For tests that live in the repository and run in CI it is the wrong tool: the skill defaults to CLI commands, not test specs.
How to run it
The install command below puts the whole folder in place. It needs Node.js with npx; without it the agent stops and asks you to install Node. SKILL.md looks for the wrapper under $CODEX_HOME/skills/playwright/; in Claude Code or Cursor, point the agent at the folder where the skill was installed, or install the CLI with npm install -g @playwright/cli@latest. The agent picks the skill up by its description; to call it yourself:
- Claude Code:
/playwright, or ask for the skill by name. - Codex:
$playwright. - Cursor: type
/in the Agent chat and pickplaywright.
Example: /playwright Open localhost:3000, sign up with a test email and take a screenshot after each step.
OpenAI has marked openai/skills deprecated; our copy is pinned to a commit there, and as of November 2026 openai/plugins has no newer version of this skill.
How it differs from similar skills
Web app testing with Playwright scripts has the agent write Python Playwright scripts, with with_server.py starting the app's servers; this skill sends CLI commands one by one and leaves no script behind. E2E tests with Playwright writes @playwright/test specs that stay in the repository. Browser testing with Chrome DevTools MCP works through an MCP server instead of a CLI and adds performance traces with LCP, CLS and INP.
Install
Run one command — it saves SKILL.md and the files it uses into your agent's skills folder. Claude Code and Codex pick up a new skill without a restart; if it does not show up, restart the agent.
curl -fsSL --create-dirs -o ~/.claude/skills/playwright/SKILL.md https://anymodel.org/en/skills/openai/playwright/SKILL.md -o ~/.claude/skills/playwright/LICENSE.txt https://anymodel.org/en/skills/openai/playwright/LICENSE.txt -o ~/.claude/skills/playwright/NOTICE.txt https://anymodel.org/en/skills/openai/playwright/NOTICE.txt -o ~/.claude/skills/playwright/agents/openai.yaml https://anymodel.org/en/skills/openai/playwright/agents/openai.yaml -o ~/.claude/skills/playwright/assets/playwright-small.svg https://anymodel.org/en/skills/openai/playwright/assets/playwright-small.svg -o ~/.claude/skills/playwright/assets/playwright.png https://anymodel.org/en/skills/openai/playwright/assets/playwright.png -o ~/.claude/skills/playwright/references/cli.md https://anymodel.org/en/skills/openai/playwright/references/cli.md -o ~/.claude/skills/playwright/references/workflows.md https://anymodel.org/en/skills/openai/playwright/references/workflows.md -o ~/.claude/skills/playwright/scripts/playwright_cli.sh https://anymodel.org/en/skills/openai/playwright/scripts/playwright_cli.sh && chmod +x ~/.claude/skills/playwright/scripts/playwright_cli.sh
curl -fsSL --create-dirs -o ~/.agents/skills/playwright/SKILL.md https://anymodel.org/en/skills/openai/playwright/SKILL.md -o ~/.agents/skills/playwright/LICENSE.txt https://anymodel.org/en/skills/openai/playwright/LICENSE.txt -o ~/.agents/skills/playwright/NOTICE.txt https://anymodel.org/en/skills/openai/playwright/NOTICE.txt -o ~/.agents/skills/playwright/agents/openai.yaml https://anymodel.org/en/skills/openai/playwright/agents/openai.yaml -o ~/.agents/skills/playwright/assets/playwright-small.svg https://anymodel.org/en/skills/openai/playwright/assets/playwright-small.svg -o ~/.agents/skills/playwright/assets/playwright.png https://anymodel.org/en/skills/openai/playwright/assets/playwright.png -o ~/.agents/skills/playwright/references/cli.md https://anymodel.org/en/skills/openai/playwright/references/cli.md -o ~/.agents/skills/playwright/references/workflows.md https://anymodel.org/en/skills/openai/playwright/references/workflows.md -o ~/.agents/skills/playwright/scripts/playwright_cli.sh https://anymodel.org/en/skills/openai/playwright/scripts/playwright_cli.sh && chmod +x ~/.agents/skills/playwright/scripts/playwright_cli.sh
foreach ($f in 'SKILL.md','LICENSE.txt','NOTICE.txt','agents/openai.yaml','assets/playwright-small.svg','assets/playwright.png','references/cli.md','references/workflows.md','scripts/playwright_cli.sh') { $p = Join-Path "$HOME\.claude\skills\playwright" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/openai/playwright/$f" -UseBasicParsing -OutFile $p }foreach ($f in 'SKILL.md','LICENSE.txt','NOTICE.txt','agents/openai.yaml','assets/playwright-small.svg','assets/playwright.png','references/cli.md','references/workflows.md','scripts/playwright_cli.sh') { $p = Join-Path "$HOME\.agents\skills\playwright" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/openai/playwright/$f" -UseBasicParsing -OutFile $p }Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/openai/playwright/SKILL.md
SKILL.md
Playwright CLI Skill
Drive a real browser from the terminal using playwright-cli. Prefer the bundled wrapper script so the CLI works even when it is not globally installed.
Treat this skill as CLI-first automation. Do not pivot to @playwright/test unless the user explicitly asks for test files.
Prerequisite check (required)
Before proposing commands, check whether npx is available (the wrapper depends on it):
command -v npx >/dev/null 2>&1
If 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 --help
Once npx is present, proceed with the wrapper script. A global install of playwright-cli is optional.
Skill path (set once)
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).
Quick start
Use the wrapper script:
"$PWCLI" open https://playwright.dev --headed
"$PWCLI" snapshot
"$PWCLI" click e15
"$PWCLI" type "Playwright"
"$PWCLI" press Enter
"$PWCLI" screenshot
If the user prefers a global install, this is also valid:
npm install -g @playwright/cli@latest
playwright-cli --help
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 "[email protected]"
"$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 wrapper script uses npx --package @playwright/cli playwright-cli so the CLI can run without a global install:
"$PWCLI" --help
Prefer the wrapper unless the repository already standardizes on a global install.
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.
Connect through AnyModel API
This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.
AnyModel