agentleFS
EnjoyoerEnjoyoer/loadout/skills/web-browser/playwright/SKILL.md

playwright

Skill0 starsChanged 25 days agoMITView on GitHub

Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, UI-flow debugging) via `playwright-cli` or the bundled wrapper script.

  • Installs packages

94 other projects use a version of this, 36 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use develop-web-game, msw and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • hebertzhuSkill

    develop-web-game

    Use when building or iterating on a web game and you need a tight implement-test-observe loop; prefer the bundled Playwright client, inspect screenshots and text state, and validate every meaningful change before moving on.

    Also in 4 projects that use this

  • thongdn-itSkill

    msw

    MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.

    Also in 3 projects that use this

  • SupabaseSkill

    react-hook-form

    Correct React Hook Form usage anywhere in the monorepo — data flow, subscriptions,

    Also in 3 projects that use this

  • thongdn-itSkill

    tailwind

    Tailwind CSS v4 performance optimization and best practices guidelines (formerly tailwindcss-v4-style). This skill should be used when writing, reviewing, or refactoring Tailwind CSS v4 code to ensure optimal build performance, minimal CSS output, and correct usage of v4 features. Triggers on tasks involving Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.

    Also in 5 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 6 projects that use this

  • OpenAISkill

    web-perf

    Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (FCP, LCP, TBT, CLS, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge.

    Also in 5 projects that use this

  • +1 more from thongdn-it

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 4 are distinctive, and 11 are very specific to this project.

  • 0

    Common

    Most of the 81 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Treat this skill as CLI-first automation.

    line 10
  2. Very specific:

    Before proposing commands, check whether npx is available (the wrapper depends on it):

    line 14
  3. Very specific:

    If it is not available, pause and ask the user to install Node.js/npm (which provides npx).

    line 20
  4. Very specific:

    Always run the wrapper as bash "$PWCLI".

    line 43
  5. Very specific:

    Keep Chromium's sandbox on.

    line 47
  6. Distinctive:

    Not needed on macOS or Linux.

    line 74
  7. Distinctive:

    Use the wrapper script:

    line 78
  8. Very specific:

    If the user prefers a global install, this is also valid (the command is then playwright-core cli):

    line 89
  9. Distinctive:

    Prefer the wrapper unless the repository already standardizes on a global install.

    line 163
  10. Very specific:

    Always snapshot before referencing element ids like e12.

    line 174
  11. Very specific:

    Prefer explicit commands over eval and run-code unless needed.

    line 176
  12. Very specific:

    When you do not have a fresh snapshot, use placeholder refs like eX and say why.

    line 177
  13. Very specific:

    Use --headed when a visual check will help.

    line 178
  14. Very specific:

    When capturing artifacts in this repo, use output/playwright/ and avoid introducing new top-level artifact folders.

    line 179
  15. Distinctive:

    Default to CLI commands and workflows, not Playwright test specs.

    line 180

“Common” is measured: kept by at least 6 in 10 of the 81 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
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-core@1.64.1
playwright-core cli --help

Once npx is present, proceed with the wrapper script. A global install 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).

Always run the wrapper as bash "$PWCLI". A skill install or sync may not keep the script's execute bit, and then "$PWCLI" on its own fails with Permission denied.

Browser sandbox (required)

Keep Chromium's sandbox on. Set it once per host in the CLI's global config, ~/.playwright/cli.config.json (%USERPROFILE%\.playwright\cli.config.json on Windows):

{"browser":{"browserName":"chromium","launchOptions":{"channel":"chrome","chromiumSandbox":true}}}
  • channel: "chrome" runs the installed Google Chrome, which keeps itself up to date. Keep browserName: without it the CLI ignores channel and always uses Chrome.
  • Without chromiumSandbox: true, the CLI starts Playwright's bundled Chromium on Linux with --no-sandbox.
  • The CLI applies a session's own config (--config, or .playwright/cli.config.json in the working folder) on top of this file. Never set chromiumSandbox to false there or pass --no-sandbox.
  • On a Linux host without Google Chrome, set "channel": "chromium" (Playwright's bundled Chromium, installed with bash "$PWCLI" install-browser chromium) and keep chromiumSandbox: true. It sandboxes through unprivileged user namespaces. If the browser will not start with the sandbox, stop and report it; do not turn the sandbox off.

Windows: seeded profiles (required)

On a fresh Chrome or Edge profile, Chrome checks whether the Windows account has a blank password by trying to log on with an empty one. Each try logs a failed logon (Security event 4625), and enough of them in a few minutes lock the account, SSH included. A profile whose Local State already holds the cached answer (password_manager.os_password_blank false, os_password_last_changed "9223372036854775807") skips the check. scripts/seed_local_state.ps1 writes it: it merges those two keys into an existing Local State and keeps every other key, creates the file only when it is missing, and writes nothing when the profile is already seeded, so it is safe before every launch.

On Windows (Git Bash) the wrapper checks open, attach and show first, about a second each. It lets one through only when it starts no Chrome or Edge, or starts one on a profile it has just seeded. Anything it cannot prove stops with exit 2 before a browser starts. Fix the cause it names; never start the browser another way.

  • open finds the profile the CLI will start, as the CLI does: --profile, else browser.userDataDir from the config files or PLAYWRIGHT_MCP_USER_DATA_DIR, else the CLI's own folder for --persistent. It seeds that folder and passes it to the CLI as --profile. --profile needs one non-empty value: an empty, repeated or negated one is refused.
  • A session with none of those would start on a temporary profile that the browser launch creates, too late to seed. The wrapper gives it a fresh seeded profile instead, a new one at each open, so it still starts empty. delete-data removes these. An open removes earlier ones only when they are older than 30 minutes, hold no browser lock, and no session file or running process names them.
  • Refused on Windows:
    • a config with browser.isolated: true or PLAYWRIGHT_MCP_ISOLATED;
    • extension mode (attach --extension, PLAYWRIGHT_MCP_EXTENSION, or extension in a config), whose relay starts Chrome on a profile the wrapper does not seed;
    • show and show --annotate, whose dashboard runs Chrome on a temporary profile (show --port <n> and show --kill start none);
    • PWDEBUG other than 0 or false, since the Playwright Inspector runs Chrome on a temporary profile.
  • The wrapper also sets PW_CODEGEN_NO_INSPECTOR=1, so a paused headed session does not open the Inspector; resume still works.
  • attach to a running browser (attach <name>, --endpoint, --cdp) starts no browser and goes through. So do Firefox and WebKit, which have no such check.
  • To start Chrome or Edge on Windows outside the wrapper (a Playwright script, code run through run-code, or a browser you launch yourself), use a profile folder and seed it first: powershell -NoProfile -ExecutionPolicy Bypass -File "$(dirname "$PWCLI")/seed_local_state.ps1" -Profile <dir>. Then launch with chromium.launchPersistentContext('<dir>', ...) or --user-data-dir=<dir>. If the helper fails, do not launch. Never use chromium.launch() there: it starts on a temporary profile.
  • Not needed on macOS or Linux; the wrapper skips it there.

Quick start

Use the wrapper script:

bash "$PWCLI" open https://playwright.dev --headed
bash "$PWCLI" snapshot
bash "$PWCLI" click e15
bash "$PWCLI" type "Playwright"
bash "$PWCLI" press Enter
bash "$PWCLI" screenshot

If the user prefers a global install, this is also valid (the command is then playwright-core cli):

npm install -g playwright-core@1.64.1
playwright-core cli --help

Core workflow

  1. Open the page.
  2. Snapshot to get stable element refs.
  3. Interact using refs from the latest snapshot.
  4. Re-snapshot after navigation or significant DOM changes.
  5. Capture artifacts (screenshot, pdf, traces) when useful.

Minimal loop:

bash "$PWCLI" open https://example.com
bash "$PWCLI" snapshot
bash "$PWCLI" click e3
bash "$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

bash "$PWCLI" open https://example.com/form
bash "$PWCLI" snapshot
bash "$PWCLI" fill e1 "user@example.com"
bash "$PWCLI" fill e2 "password123"
bash "$PWCLI" click e3
bash "$PWCLI" snapshot

Debug a UI flow with traces

bash "$PWCLI" open https://example.com --headed
bash "$PWCLI" tracing-start
# ...interactions...
bash "$PWCLI" tracing-stop

Multi-tab work

bash "$PWCLI" tab-new https://example.com
bash "$PWCLI" tab-list
bash "$PWCLI" tab-select 0
bash "$PWCLI" snapshot

Wrapper script

The wrapper script uses the pinned npx --package playwright-core@1.64.1 playwright-core cli so the CLI can run without a global install. That is the CLI shipped in the stable Playwright release. The separate @playwright/cli package pins pre-release Playwright builds, so the skill does not use it; move the pin only to a newer stable playwright-core.

bash "$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 eval and run-code unless needed.
  • When you do not have a fresh snapshot, use placeholder refs like eX and say why; do not bypass refs with run-code.
  • Use --headed when 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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.