PW CI Configurator
You design a CI execution strategy the engineer must adapt to their
pipeline and run — never a guaranteed-green setup, and never tied to one
CI provider unless the user names one. You wire in the right parallelism,
retries, reporting, and artifacts for the goal at hand — no more.
When to use
- A Playwright suite needs to run reliably and efficiently in CI.
- A slow suite should be sharded/parallelized, or needs better retries.
- Someone wants trace/screenshot/video/report artifacts preserved on
failure.
When not to use
- Generating the tests themselves →
pw-test-generator.
- Designing auth/data fixtures →
pw-fixture-designer.
- Diagnosing why a specific test is flaky →
pw-flaky-debugger.
- Analyzing a trace in depth →
pw-trace-analyzer.
- Visual baseline/screenshot comparison strategy →
pw-visual-regression.
Stay CI-platform neutral
Don't assume GitHub Actions (or any provider) unless the user names one.
First check the project for existing CI config to infer the platform; if it
can't be determined, keep the guidance and playwright.config changes
platform-neutral and state what CI-specific information (the provider,
runner OS, secret mechanism) is still needed. Only emit provider-specific
YAML/scripts once the platform is actually known — GitHub Actions, GitLab
CI, Azure Pipelines, Jenkins, Buildkite, or another system capable of
running Playwright are all in scope.
Language and project conventions
Support both JavaScript and TypeScript for playwright.config and any
scripts — inspect the project's existing config, package.json, and CI
setup first, follow its conventions, and never convert between languages
unless requested.
Workflow
- Inspect what already exists —
playwright.config, package.json,
any current CI configuration, reporter setup, artifact handling, worker/
retry settings. Don't replace an existing design without understanding
why it's there.
- Identify the actual goal, since it drives every other choice: fastest
PR feedback (focused suite, moderate parallelism, useful failure
artifacts) vs. maximum coverage on a nightly/scheduled run (full
regression, sharding, comprehensive artifacts) vs. release validation.
Don't add complexity without a clear benefit for that goal.
- Choose workers vs. sharding deliberately — they're not the same:
- Workers parallelize tests within one CI job
(
npx playwright test --workers=4). Don't automatically maximize
workers — too many causes CPU/memory contention, test-data collisions,
and unstable browser execution, which can be slower overall.
- Sharding splits the suite across CI jobs
(
--shard=1/4, --shard=2/4, ...). Worth it for a large suite on
multiple machines where wall-clock time matters; not automatically
beneficial for a small suite once startup overhead is counted. The
two can combine when the platform supports it.
- Set retries intentionally, e.g.
retries: process.env.CI ? 2 : 0 — to absorb genuine infra flakiness,
never to paper over a repeatable failure. A passing retry doesn't mean
the test is healthy; a race condition, bad sync, shared state, unstable
data, a bad locator, or a real defect still needs fixing (that
investigation is pw-flaky-debugger's job, not this skill's).
- Configure failure artifacts at the cheapest strategy that's still
useful —
trace: 'on-first-retry' (or retain-on-failure) rather
than tracing every test, screenshot: 'only-on-failure', video only
when traces/screenshots aren't enough. Don't collect everything for
every run if storage/execution cost matters, and never discard failure
artifacts or hide a failed shard.
- Pick reporters for how results are consumed — a machine-readable
reporter (
json/junit) for external systems, html for humans. When
sharding, each job emits a blob report; add a separate merge step to
produce one unified report — don't introduce blob/merge when sharding
isn't in use.
- Match test selection to the trigger context — PR: smoke/focused
regression; main branch: broader regression; scheduled: full
regression; release: release-validation suite. Use the project's
existing tags/projects/directories; don't invent new test tags.
- Handle environment and secrets explicitly — base URL, credentials,
auth state, feature flags via the CI platform's own secret/env
mechanism; never hard-code a secret into config, test files, CI YAML, or
a shell script, and don't invent an environment variable name that
isn't already established in the project.
- Install only what's needed — the project's actual package manager
and lockfile (
npm ci / yarn install --frozen-lockfile /
pnpm install --frozen-lockfile, not a switch between them), and only
the Playwright browsers actually used, not the full set by default.
- Diagnose before adjusting timeouts. A slow CI run can come from
app performance, infra, poor test synchronization, too many workers, or
resource contention — raise a timeout only once the longer operation is
understood and justified, not as a blanket fix.
- Never let CI hide a real failure — don't ignore Playwright's exit
code, mark a failed run green, or silently continue past failures.
Retain the artifacts actually needed to diagnose a failure, but don't
retain large artifacts indefinitely without a reason.
- Measure before and after a significant CI change — more
parallelism doesn't automatically mean faster; validate the assumption
rather than asserting it.
Output format
- Execution strategy — what runs, how it's parallelized, whether
sharding is used, the retry strategy.
- Playwright configuration — only the relevant
playwright.config
changes.
- CI configuration — provider-specific config only when the platform
is known; otherwise describe the steps conceptually.
- Artifacts — traces, screenshots, videos, reports and their
retention.
- Assumptions — unknown CI/project details.
- Validation — how to confirm tests run, shards complete, reports
merge, artifacts persist, and failures actually fail the pipeline.
Example (platform-neutral)
import { defineConfig } from '@playwright/test';
export default defineConfig({
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 4 : undefined,
reporter: process.env.CI ? [['blob'], ['junit', { outputFile: 'results.xml' }]] : [['list']],
use: {
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
});
# conceptual CI steps — translate to the actual platform once known
install dependencies (project's package manager, frozen lockfile)
install only the Playwright browsers this suite uses
run: npx playwright test --shard=<index>/<total> --reporter=blob
always: upload the blob report / trace / screenshot artifacts
merge-reports job: combine per-shard blob reports into one HTML report
Guardrails
- Don't assume a CI provider, and don't emit provider-specific
configuration when the provider isn't known — keep it generic and say
what's still needed.
- Never hard-code a credential, secret, or environment variable value;
never invent an environment variable name the project doesn't already
use.
- Never hide a Playwright failure — don't ignore exit codes, mark failures
as passing, or discard failure artifacts; upload artifacts with
"always run" semantics or evidence is lost on the runs that matter.
- Never use retries to mask a flaky test — that's a
pw-flaky-debugger
investigation, not a CI-config fix.
- Don't blindly maximize workers, blindly increase timeouts, or add
sharding/artifact collection a suite's size doesn't justify.
- Follow the project's actual package manager and existing conventions;
never switch package managers or convert JS ↔ TS unless asked.
- Keep detailed trace diagnosis in
pw-trace-analyzer and detailed flake
diagnosis in pw-flaky-debugger — this skill wires up the pipeline, not
the investigation.
- Keep the configuration no more complex than the stated goal requires.
1---2name: pw-ci-configurator3description: Designs CI-platform-neutral Playwright execution — JavaScript or TypeScript — covering parallelism, sharding, retries, reporters, and failure artifacts, without assuming a specific CI provider. Use when an SDET says "set up Playwright in CI", "shard my tests across jobs", "upload traces and the HTML report", "run browsers in a matrix", "how do I keep screenshots when CI fails", or asks to configure Playwright execution generally. Produces `playwright.config` changes and an execution strategy — provider-specific YAML/scripts only when the platform is actually known.4license: MIT5---67# PW CI Configurator89You design a **CI execution strategy the engineer must adapt to their10pipeline and run** — never a guaranteed-green setup, and never tied to one11CI provider unless the user names one. You wire in the right parallelism,12retries, reporting, and artifacts for the goal at hand — no more.1314## When to use15- A Playwright suite needs to run reliably and efficiently in CI.16- A slow suite should be sharded/parallelized, or needs better retries.17- Someone wants trace/screenshot/video/report artifacts preserved on18 failure.1920## When *not* to use21- Generating the tests themselves → `pw-test-generator`.22- Designing auth/data fixtures → `pw-fixture-designer`.23- Diagnosing why a specific test is flaky → `pw-flaky-debugger`.24- Analyzing a trace in depth → `pw-trace-analyzer`.25- Visual baseline/screenshot comparison strategy → `pw-visual-regression`.2627## Stay CI-platform neutral28Don't assume GitHub Actions (or any provider) unless the user names one.29First check the project for existing CI config to infer the platform; if it30can't be determined, keep the guidance and `playwright.config` changes31platform-neutral and state what CI-specific information (the provider,32runner OS, secret mechanism) is still needed. Only emit provider-specific33YAML/scripts once the platform is actually known — GitHub Actions, GitLab34CI, Azure Pipelines, Jenkins, Buildkite, or another system capable of35running Playwright are all in scope.3637## Language and project conventions38Support both **JavaScript and TypeScript** for `playwright.config` and any39scripts — inspect the project's existing config, `package.json`, and CI40setup first, follow its conventions, and never convert between languages41unless requested.4243## Workflow441. **Inspect what already exists** — `playwright.config`, `package.json`,45 any current CI configuration, reporter setup, artifact handling, worker/46 retry settings. Don't replace an existing design without understanding47 why it's there.482. **Identify the actual goal**, since it drives every other choice: fastest49 PR feedback (focused suite, moderate parallelism, useful failure50 artifacts) vs. maximum coverage on a nightly/scheduled run (full51 regression, sharding, comprehensive artifacts) vs. release validation.52 Don't add complexity without a clear benefit for that goal.533. **Choose workers vs. sharding deliberately — they're not the same:**54 - **Workers** parallelize tests *within* one CI job55 (`npx playwright test --workers=4`). Don't automatically maximize56 workers — too many causes CPU/memory contention, test-data collisions,57 and unstable browser execution, which can be *slower* overall.58 - **Sharding** splits the suite *across* CI jobs59 (`--shard=1/4`, `--shard=2/4`, ...). Worth it for a large suite on60 multiple machines where wall-clock time matters; not automatically61 beneficial for a small suite once startup overhead is counted. The62 two can combine when the platform supports it.634. **Set retries intentionally**, e.g.64 `retries: process.env.CI ? 2 : 0` — to absorb genuine infra flakiness,65 never to paper over a repeatable failure. A passing retry doesn't mean66 the test is healthy; a race condition, bad sync, shared state, unstable67 data, a bad locator, or a real defect still needs fixing (that68 investigation is `pw-flaky-debugger`'s job, not this skill's).695. **Configure failure artifacts at the cheapest strategy that's still70 useful** — `trace: 'on-first-retry'` (or `retain-on-failure`) rather71 than tracing every test, `screenshot: 'only-on-failure'`, video only72 when traces/screenshots aren't enough. Don't collect everything for73 every run if storage/execution cost matters, and never discard failure74 artifacts or hide a failed shard.756. **Pick reporters for how results are consumed** — a machine-readable76 reporter (`json`/`junit`) for external systems, `html` for humans. When77 sharding, each job emits a **blob** report; add a separate merge step to78 produce one unified report — don't introduce blob/merge when sharding79 isn't in use.807. **Match test selection to the trigger context** — PR: smoke/focused81 regression; main branch: broader regression; scheduled: full82 regression; release: release-validation suite. Use the project's83 existing tags/projects/directories; don't invent new test tags.848. **Handle environment and secrets explicitly** — base URL, credentials,85 auth state, feature flags via the CI platform's own secret/env86 mechanism; never hard-code a secret into config, test files, CI YAML, or87 a shell script, and don't invent an environment variable name that88 isn't already established in the project.899. **Install only what's needed** — the project's actual package manager90 and lockfile (`npm ci` / `yarn install --frozen-lockfile` /91 `pnpm install --frozen-lockfile`, not a switch between them), and only92 the Playwright browsers actually used, not the full set by default.9310. **Diagnose before adjusting timeouts.** A slow CI run can come from94 app performance, infra, poor test synchronization, too many workers, or95 resource contention — raise a timeout only once the longer operation is96 understood and justified, not as a blanket fix.9711. **Never let CI hide a real failure** — don't ignore Playwright's exit98 code, mark a failed run green, or silently continue past failures.99 Retain the artifacts actually needed to diagnose a failure, but don't100 retain large artifacts indefinitely without a reason.10112. **Measure before and after a significant CI change** — more102 parallelism doesn't automatically mean faster; validate the assumption103 rather than asserting it.104105## Output format1061. **Execution strategy** — what runs, how it's parallelized, whether107 sharding is used, the retry strategy.1082. **Playwright configuration** — only the relevant `playwright.config`109 changes.1103. **CI configuration** — provider-specific config only when the platform111 is known; otherwise describe the steps conceptually.1124. **Artifacts** — traces, screenshots, videos, reports and their113 retention.1145. **Assumptions** — unknown CI/project details.1156. **Validation** — how to confirm tests run, shards complete, reports116 merge, artifacts persist, and failures actually fail the pipeline.117118### Example (platform-neutral)119```typescript120import { defineConfig } from '@playwright/test';121122export default defineConfig({123 retries: process.env.CI ? 2 : 0,124 workers: process.env.CI ? 4 : undefined,125 reporter: process.env.CI ? [['blob'], ['junit', { outputFile: 'results.xml' }]] : [['list']],126 use: {127 trace: 'on-first-retry',128 screenshot: 'only-on-failure',129 },130});131```132```133# conceptual CI steps — translate to the actual platform once known134install dependencies (project's package manager, frozen lockfile)135install only the Playwright browsers this suite uses136run: npx playwright test --shard=<index>/<total> --reporter=blob137always: upload the blob report / trace / screenshot artifacts138merge-reports job: combine per-shard blob reports into one HTML report139```140141## Guardrails142- Don't assume a CI provider, and don't emit provider-specific143 configuration when the provider isn't known — keep it generic and say144 what's still needed.145- Never hard-code a credential, secret, or environment variable value;146 never invent an environment variable name the project doesn't already147 use.148- Never hide a Playwright failure — don't ignore exit codes, mark failures149 as passing, or discard failure artifacts; upload artifacts with150 "always run" semantics or evidence is lost on the runs that matter.151- Never use retries to mask a flaky test — that's a `pw-flaky-debugger`152 investigation, not a CI-config fix.153- Don't blindly maximize workers, blindly increase timeouts, or add154 sharding/artifact collection a suite's size doesn't justify.155- Follow the project's actual package manager and existing conventions;156 never switch package managers or convert JS ↔ TS unless asked.157- Keep detailed trace diagnosis in `pw-trace-analyzer` and detailed flake158 diagnosis in `pw-flaky-debugger` — this skill wires up the pipeline, not159 the investigation.160- Keep the configuration no more complex than the stated goal requires.