Setup Playwright
Build the smallest reliable repo-owned Playwright setup that fits the
repository's language, package boundaries, test runner, developer-tool, and CI
conventions.
This is a system skill: it leaves behind a repo-owned harness or an explicitly
requested Playwright developer-tool artifact. Day-to-day test authoring and
live browser investigation belong to playwright-testing.
Ownership Boundary
Use this skill when the main artifact is one or more of:
- Playwright dependencies or browser binaries
- runner config, package placement, or monorepo wiring
- app startup through
webServer or an ecosystem-native equivalent
- browser, device, environment, retry, reporter, or artifact configuration
- reusable-auth setup and ignored state files
- a minimal smoke check that proves the harness works
- CI install, smoke, sharding, or report-merge plumbing
- an explicitly requested repo-owned
@playwright/cli developer dependency or
script
- host-targeted Playwright Test Agent definitions for a compatible Node
Playwright Test harness
Use playwright-testing when the harness works and the task is a spec, test
review, flake diagnosis, locator change, mock decision, visual check, or
standalone playwright-cli investigation. If an environment-dependent install,
startup, container, or CI failure has no established cause, start with
project-platform-diagnose and return here once the repair is known.
Choose The Existing Ecosystem
Follow the strongest repository signal:
- Node/TypeScript/JavaScript:
@playwright/test unless another runner is
already intentional.
- Python with pytest: the official Playwright Pytest plugin and pytest-native
fixtures/config.
- .NET: the repo's MSTest, NUnit, xUnit, or xUnit v3 project and Playwright .NET
integration.
- Java: the repo's JUnit or TestNG module with its Maven or Gradle build.
Do not create a Node sidecar in a Python, .NET, or Java repo merely because its
examples are more familiar. Load
references/ecosystem-patterns.md before
editing a non-Node harness.
If multiple ecosystems are equally plausible and package ownership cannot be
derived from the repo, ask before adding dependencies.
Repo-Owned CLI Tooling
Use this lane only when the user explicitly wants Playwright CLI tooling
persisted in the repository. Agent-side investigation alone belongs to
playwright-testing and does not justify a dependency.
- Inspect package ownership, the installed command surface, and whether the
repo's existing Playwright version already exposes
npx playwright cli.
- Record the existing runner and CLI package versions, dependency resolution,
lockfile state, and browser-command ownership before changing dependencies.
- If standalone
@playwright/cli is still wanted, add it only as developer
tooling under the repo's version and lockfile policy.
- Compare dependency resolution afterward and verify both the existing runner
and the persisted CLI command. Do not upgrade or align a stable
@playwright/test harness to an alpha Playwright dependency pulled by the
CLI. If the package manager cannot keep the surfaces compatible, report the
conflict instead of forcing installation.
- Report the before/after versions, lockfile impact, commands verified, and
any browser-download or update commitment introduced.
Playwright Test Agent Extension
Treat Playwright Test Agents as a Node Playwright Test harness extension, not
as standalone generic agent tooling.
- Inspect the worktree and existing agent definitions, then require a
compatible Node Playwright Test harness and an explicit target host or
--loop value supported by the installed init-agents command. Identify an
existing seed when the repo has one and check the installed version's
default-seed behavior when it does not.
- If the harness or target host is missing, do not generate unusable
definitions. Use the Harness Workflow only when the request authorizes that
additional setup; otherwise report the missing prerequisite. A missing seed
alone is not a blocker: the current planner can create a default. Prefer an
explicit seed when custom fixtures, hooks, project dependencies, or startup
make that bootstrap contract material. Do not create a Node sidecar in a
Python, .NET, or Java repo solely to enable Test Agents.
- Generate only the requested host definitions using current runtime help.
Review the complete diff and preserve the documented regeneration path
rather than casually hand-editing generated files.
- Validate agent-file discovery and the existing or generated seed's
compatibility with the active config, fixtures, project dependencies,
hooks, and startup contract. Do not claim operational success when required
app access, accounts, or secrets were unavailable.
setup-playwright owns generation, placement, version compatibility, and
regeneration. Add prompt-engineering only when the user asks to evaluate
or change agent instructions, tool boundaries, or prompt behavior, not for
routine generation or structural diff review. Do not add
agent-skill-generator merely because the artifacts are called agents; they
are not reusable SKILL.md packages.
If a CLI or Test Agent request also changes the test harness, use the Harness
Workflow for that portion.
Harness Workflow
- Inspect before installing. Read repository instructions, package and
lock files, test projects, existing Playwright artifacts, scripts, ignore
rules, app startup commands, ports, and CI workflows. Check the installed
version before relying on current flags or config fields.
- Define the harness contract. Name the owning package, runner, target URL,
startup owner, browser scope, auth strategy, output paths, local command, and
CI command. Distinguish a broken harness from an environment-only failure.
- Make the smallest coherent change. Use the repo's package manager and
pinning policy. Install only required browsers. Preserve existing config and
scripts; do not run a scaffold over a non-trivial harness blindly.
- Configure for local and CI use. Set base URL/startup, projects or runner
equivalents, timeouts, retries, workers, reporters, and artifacts only when
the repository needs them. Prefer project dependencies over Node
globalSetup when setup should be visible and traceable in the runner.
- Wire auth deliberately. Use UI login, API login, or per-worker accounts
according to the claim and mutation model. Verify authentication succeeded
before saving state. Ignore saved state and treat it as a credential.
- Add one meaningful smoke check. Prove that startup, navigation, locator,
assertion, browser binary, and output path cooperate. Keep broader product
coverage for
playwright-testing.
- Validate in layers. Verify config/listing first, run one smoke target,
repeat if the repair involved state or startup, then run the smallest
relevant CI-shaped command. Inspect generated output rather than assuming
command success proves correct placement.
- Report exact evidence. State changed files, commands and results,
browsers not installed or run, CI not executed, secrets required, and any
remaining environment assumptions.
Setup Rules
- Preserve package-manager and lockfile ownership. Do not mix npm, pnpm, yarn,
Python managers, NuGet conventions, Maven, or Gradle without repo evidence.
- Keep Playwright package and browser binaries aligned. Install the smallest
browser set that proves the stated matrix; broader defaults must be an
explicit choice.
- Prefer one clear config owner per package. Reuse existing test and artifact
directories unless relocation is part of the request.
- Keep local server reuse local; CI should start from a controlled build and
process. Use a readiness URL and a startup timeout that reflects app boot,
not an inflated global test timeout.
- Default CI concurrency conservatively when shared state is not proven safe.
Add parallelism or sharding only with an isolation model and report merging.
- Configure traces, screenshots, or video for actionable failure evidence,
while controlling retention and excluding secrets.
- Use a Node setup project for reusable auth when applicable. In other
ecosystems, preserve native fixtures/helpers instead of inventing
auth.setup.ts, project dependencies, or test.use().
- Saved browser state may contain cookies, tokens, IndexedDB data, and—in newer
versions when requested—credential material. Keep it ignored and out of
logs/artifacts unless explicitly sanitized.
storageState does not persist sessionStorage; wire a deliberate restore
only when the application requires it.
- Test generated config against the installed version. Features such as
isolated retry strategies, credential-state capture, component-test models,
and bundled CLI commands are version-sensitive.
Tooling Boundaries
playwright-cli and Playwright's installable CLI skill are agent-side
exploration aids, not automatically repo dependencies. Do not add a local
third Playwright skill or a production dependency merely to run an agent
investigation.
- Component testing, browser extensions, WebView2, and raw Playwright library
automation use different lifecycle/config models. Treat them as specialized
setups rather than silently applying the default web E2E template.
Harness Validation Evidence
Choose commands from the active ecosystem and existing scripts. Typical Node
layers are:
npx playwright --version
npx playwright test --list
npx playwright test <smoke-target> --project=<project>
For Python, .NET, and Java, use the native runner and browser-install commands
from references/ecosystem-patterns.md.
Validate command availability against the installed version rather than
copying a current-doc flag into an older harness.
Resource execution and test execution are separate evidence: a valid config
does not prove browsers are installed, and a passing smoke does not prove every
browser, shard, or CI environment. Repo-owned CLI and Test Agent validation are
defined in their lanes above; do not substitute unrelated harness commands.
Reference Map
- references/ecosystem-patterns.md —
package, runner, install, and auth boundaries across Node, Python, .NET, and
Java.
- references/browser-and-config-patterns.md
— Node config scope, projects, browsers, reporters, timeouts,
webServer,
and specialized modes.
- references/auth-and-ci-patterns.md —
Node setup-project auth, API login, worker accounts, CI, and sharded reports.
- references/pressure-tests.md — shortcut
rationalizations and expected responses; load only when those pressures are
present or when maintaining the skill.
For maintainer provenance and routing fixtures, use
references/coverage-and-validation.md.
1---2name: setup-playwright3description: Use when adding, extending, or repairing a repo-owned Playwright test harness across Node Playwright Test, Playwright Pytest, or .NET/Java test frameworks. Also use when explicitly persisting `@playwright/cli` developer tooling, or adding or regenerating Playwright Test Agent definitions for a compatible Node Playwright Test harness. Not for live CLI exploration or ordinary spec work in a working harness; use `playwright-testing`.4---56# Setup Playwright78Build the smallest reliable repo-owned Playwright setup that fits the9repository's language, package boundaries, test runner, developer-tool, and CI10conventions.1112This is a system skill: it leaves behind a repo-owned harness or an explicitly13requested Playwright developer-tool artifact. Day-to-day test authoring and14live browser investigation belong to `playwright-testing`.1516## Ownership Boundary1718Use this skill when the main artifact is one or more of:1920- Playwright dependencies or browser binaries21- runner config, package placement, or monorepo wiring22- app startup through `webServer` or an ecosystem-native equivalent23- browser, device, environment, retry, reporter, or artifact configuration24- reusable-auth setup and ignored state files25- a minimal smoke check that proves the harness works26- CI install, smoke, sharding, or report-merge plumbing27- an explicitly requested repo-owned `@playwright/cli` developer dependency or28 script29- host-targeted Playwright Test Agent definitions for a compatible Node30 Playwright Test harness3132Use `playwright-testing` when the harness works and the task is a spec, test33review, flake diagnosis, locator change, mock decision, visual check, or34standalone `playwright-cli` investigation. If an environment-dependent install,35startup, container, or CI failure has no established cause, start with36`project-platform-diagnose` and return here once the repair is known.3738## Choose The Existing Ecosystem3940Follow the strongest repository signal:4142- Node/TypeScript/JavaScript: `@playwright/test` unless another runner is43 already intentional.44- Python with pytest: the official Playwright Pytest plugin and pytest-native45 fixtures/config.46- .NET: the repo's MSTest, NUnit, xUnit, or xUnit v3 project and Playwright .NET47 integration.48- Java: the repo's JUnit or TestNG module with its Maven or Gradle build.4950Do not create a Node sidecar in a Python, .NET, or Java repo merely because its51examples are more familiar. Load52[references/ecosystem-patterns.md](references/ecosystem-patterns.md) before53editing a non-Node harness.5455If multiple ecosystems are equally plausible and package ownership cannot be56derived from the repo, ask before adding dependencies.5758## Repo-Owned CLI Tooling5960Use this lane only when the user explicitly wants Playwright CLI tooling61persisted in the repository. Agent-side investigation alone belongs to62`playwright-testing` and does not justify a dependency.63641. Inspect package ownership, the installed command surface, and whether the65 repo's existing Playwright version already exposes `npx playwright cli`.662. Record the existing runner and CLI package versions, dependency resolution,67 lockfile state, and browser-command ownership before changing dependencies.683. If standalone `@playwright/cli` is still wanted, add it only as developer69 tooling under the repo's version and lockfile policy.704. Compare dependency resolution afterward and verify both the existing runner71 and the persisted CLI command. Do not upgrade or align a stable72 `@playwright/test` harness to an alpha Playwright dependency pulled by the73 CLI. If the package manager cannot keep the surfaces compatible, report the74 conflict instead of forcing installation.755. Report the before/after versions, lockfile impact, commands verified, and76 any browser-download or update commitment introduced.7778## Playwright Test Agent Extension7980Treat Playwright Test Agents as a Node Playwright Test harness extension, not81as standalone generic agent tooling.82831. Inspect the worktree and existing agent definitions, then require a84 compatible Node Playwright Test harness and an explicit target host or85 `--loop` value supported by the installed `init-agents` command. Identify an86 existing seed when the repo has one and check the installed version's87 default-seed behavior when it does not.882. If the harness or target host is missing, do not generate unusable89 definitions. Use the Harness Workflow only when the request authorizes that90 additional setup; otherwise report the missing prerequisite. A missing seed91 alone is not a blocker: the current planner can create a default. Prefer an92 explicit seed when custom fixtures, hooks, project dependencies, or startup93 make that bootstrap contract material. Do not create a Node sidecar in a94 Python, .NET, or Java repo solely to enable Test Agents.953. Generate only the requested host definitions using current runtime help.96 Review the complete diff and preserve the documented regeneration path97 rather than casually hand-editing generated files.984. Validate agent-file discovery and the existing or generated seed's99 compatibility with the active config, fixtures, project dependencies,100 hooks, and startup contract. Do not claim operational success when required101 app access, accounts, or secrets were unavailable.1025. `setup-playwright` owns generation, placement, version compatibility, and103 regeneration. Add `prompt-engineering` only when the user asks to evaluate104 or change agent instructions, tool boundaries, or prompt behavior, not for105 routine generation or structural diff review. Do not add106 `agent-skill-generator` merely because the artifacts are called agents; they107 are not reusable `SKILL.md` packages.108109If a CLI or Test Agent request also changes the test harness, use the Harness110Workflow for that portion.111112## Harness Workflow1131141. **Inspect before installing.** Read repository instructions, package and115 lock files, test projects, existing Playwright artifacts, scripts, ignore116 rules, app startup commands, ports, and CI workflows. Check the installed117 version before relying on current flags or config fields.1182. **Define the harness contract.** Name the owning package, runner, target URL,119 startup owner, browser scope, auth strategy, output paths, local command, and120 CI command. Distinguish a broken harness from an environment-only failure.1213. **Make the smallest coherent change.** Use the repo's package manager and122 pinning policy. Install only required browsers. Preserve existing config and123 scripts; do not run a scaffold over a non-trivial harness blindly.1244. **Configure for local and CI use.** Set base URL/startup, projects or runner125 equivalents, timeouts, retries, workers, reporters, and artifacts only when126 the repository needs them. Prefer project dependencies over Node127 `globalSetup` when setup should be visible and traceable in the runner.1285. **Wire auth deliberately.** Use UI login, API login, or per-worker accounts129 according to the claim and mutation model. Verify authentication succeeded130 before saving state. Ignore saved state and treat it as a credential.1316. **Add one meaningful smoke check.** Prove that startup, navigation, locator,132 assertion, browser binary, and output path cooperate. Keep broader product133 coverage for `playwright-testing`.1347. **Validate in layers.** Verify config/listing first, run one smoke target,135 repeat if the repair involved state or startup, then run the smallest136 relevant CI-shaped command. Inspect generated output rather than assuming137 command success proves correct placement.1388. **Report exact evidence.** State changed files, commands and results,139 browsers not installed or run, CI not executed, secrets required, and any140 remaining environment assumptions.141142## Setup Rules143144- Preserve package-manager and lockfile ownership. Do not mix npm, pnpm, yarn,145 Python managers, NuGet conventions, Maven, or Gradle without repo evidence.146- Keep Playwright package and browser binaries aligned. Install the smallest147 browser set that proves the stated matrix; broader defaults must be an148 explicit choice.149- Prefer one clear config owner per package. Reuse existing test and artifact150 directories unless relocation is part of the request.151- Keep local server reuse local; CI should start from a controlled build and152 process. Use a readiness URL and a startup timeout that reflects app boot,153 not an inflated global test timeout.154- Default CI concurrency conservatively when shared state is not proven safe.155 Add parallelism or sharding only with an isolation model and report merging.156- Configure traces, screenshots, or video for actionable failure evidence,157 while controlling retention and excluding secrets.158- Use a Node setup project for reusable auth when applicable. In other159 ecosystems, preserve native fixtures/helpers instead of inventing160 `auth.setup.ts`, project dependencies, or `test.use()`.161- Saved browser state may contain cookies, tokens, IndexedDB data, and—in newer162 versions when requested—credential material. Keep it ignored and out of163 logs/artifacts unless explicitly sanitized.164- `storageState` does not persist `sessionStorage`; wire a deliberate restore165 only when the application requires it.166- Test generated config against the installed version. Features such as167 isolated retry strategies, credential-state capture, component-test models,168 and bundled CLI commands are version-sensitive.169170## Tooling Boundaries171172- `playwright-cli` and Playwright's installable CLI skill are agent-side173 exploration aids, not automatically repo dependencies. Do not add a local174 third Playwright skill or a production dependency merely to run an agent175 investigation.176- Component testing, browser extensions, WebView2, and raw Playwright library177 automation use different lifecycle/config models. Treat them as specialized178 setups rather than silently applying the default web E2E template.179180## Harness Validation Evidence181182Choose commands from the active ecosystem and existing scripts. Typical Node183layers are:184185```console186npx playwright --version187npx playwright test --list188npx playwright test <smoke-target> --project=<project>189```190191For Python, .NET, and Java, use the native runner and browser-install commands192from [references/ecosystem-patterns.md](references/ecosystem-patterns.md).193Validate command availability against the installed version rather than194copying a current-doc flag into an older harness.195196Resource execution and test execution are separate evidence: a valid config197does not prove browsers are installed, and a passing smoke does not prove every198browser, shard, or CI environment. Repo-owned CLI and Test Agent validation are199defined in their lanes above; do not substitute unrelated harness commands.200201## Reference Map202203- [references/ecosystem-patterns.md](references/ecosystem-patterns.md) —204 package, runner, install, and auth boundaries across Node, Python, .NET, and205 Java.206- [references/browser-and-config-patterns.md](references/browser-and-config-patterns.md)207 — Node config scope, projects, browsers, reporters, timeouts, `webServer`,208 and specialized modes.209- [references/auth-and-ci-patterns.md](references/auth-and-ci-patterns.md) —210 Node setup-project auth, API login, worker accounts, CI, and sharded reports.211- [references/pressure-tests.md](references/pressure-tests.md) — shortcut212 rationalizations and expected responses; load only when those pressures are213 present or when maintaining the skill.214215For maintainer provenance and routing fixtures, use216[references/coverage-and-validation.md](references/coverage-and-validation.md).