Generate and maintain Playwright E2E tests for the target repository.
Do not assume a specific framework, folder structure, package manager, fixture layout, data setup method, or test command.
Repository discovery
Before writing or editing tests, discover the repository's conventions:
- Read testing documentation if present, such as
docs/testing/e2e-context.md, docs/testing.md, CONTRIBUTING.md, README.md, or files near the E2E tests.
- Inspect
package.json scripts for E2E commands such as test:e2e, e2e, playwright, or project-specific wrappers.
- Inspect Playwright config files such as
playwright.config.ts, playwright.config.js, or playwright.config.mjs.
- Identify E2E folders such as
e2e/, tests/e2e/, __e2e__/, playwright/, or folders referenced by Playwright config.
- Inspect nearby specs in the same feature area.
- Inspect existing fixtures, helpers, page objects, factories, API clients, seed utilities, and authentication/storage setup.
Repository conventions are mandatory and take precedence over generic Playwright patterns or generated recorder-style code.
Before writing or editing tests:
- Read the repository's testing documentation, if present.
- Treat mandatory rules from that documentation as required implementation constraints.
- Inspect the closest existing spec for the same feature area.
- Inspect the relevant fixture, helper, page object, and setup files.
- Reuse existing fixtures, helpers, setup utilities, and page object methods before introducing new patterns.
Core rules:
- Use repository fixtures instead of
@playwright/test directly when applicable.
- Use the repository's existing setup utilities for entities, users, permissions, authentication, storage state, and feature flags.
- Create setup data through fixtures, API helpers, factories, seed utilities, GraphQL helpers, or shared utilities already used by the repository.
- Do not create data through the UI unless that creation flow is the behavior under test.
- Route UI interactions through page objects or helper abstractions when the repository uses them.
- Do not put reusable locators or reusable interaction logic directly in specs when the repository has an abstraction pattern for them.
- Extend existing page objects or helpers when possible.
- Create a new focused page object or helper only when the functionality represents a distinct reusable UI area or flow.
- Keep assertions visible in the spec body unless they are repeated low-level checks.
- Match naming, imports, structure, and style from nearby tests.
Playwright CLI Skill Usage
When browser interaction, debugging, tracing, selector inspection, session management, or lightweight validation is needed, use the installed Playwright CLI skills and their reference guides.
Prefer Playwright CLI capabilities for:
- test generation drafts
- selector validation
- browser interaction
- tracing
- storage state inspection
- request mocking
- video recording
- session management
- lightweight flow validation
- debugging failing interactions
Prefer repository fixtures, page objects, helpers, and testing documentation for:
- final test architecture
- test organization
- setup strategy
- reusable interactions
- assertion placement
- long-term maintainability
Use playwright-cli only for exploration and debugging:
- discovering current UI behavior
- validating selectors
- checking screenshots or snapshots
- debugging failing flows
playwright-cli output is exploration material only.
Do not paste raw generated recorder-style code into specs. Refactor generated interactions into fixtures, helpers, and page object methods that follow repository conventions.
Validation Rules
Use the lightest validation strategy possible.
Preferred validation order:
- Typecheck or lint changed files if available.
- Use Playwright CLI for fast interaction and selector validation.
- Run the smallest relevant Playwright test scope in headless mode using the repository's E2E command.
- Use headed mode only for explicit debugging.
Always avoid:
- unnecessary
--headed
- full-suite execution
- validating unrelated specs
Before finishing, verify:
- repository testing documentation was followed, if present
- the closest existing spec was inspected
- the appropriate fixture, helper, or setup utility was used
- setup data uses repository-standard fixtures, APIs, factories, seed utilities, or helpers
- page object methods or equivalent repository abstractions are used or added where appropriate
- raw locators are kept out of specs where possible
- new interactions are reusable by future tests
- assertions remain visible in the spec body
- the generated code matches nearby repository examples
- the smallest relevant E2E command was run or clearly stated if not run
If generated code conflicts with repository testing documentation or nearby examples, revise the implementation before returning the result.
Use Playwright MCP only if playwright-cli is insufficient.
Use output-template.md for response formatting.
1---2name: playwright-generate3description: Generate, debug, and maintain Playwright end-to-end tests using the target repository's fixtures, helpers, page objects, setup conventions, and E2E command4---56Generate and maintain Playwright E2E tests for the target repository.78Do not assume a specific framework, folder structure, package manager, fixture layout, data setup method, or test command.910## Repository discovery1112Before writing or editing tests, discover the repository's conventions:1314- Read testing documentation if present, such as `docs/testing/e2e-context.md`, `docs/testing.md`, `CONTRIBUTING.md`, `README.md`, or files near the E2E tests.15- Inspect `package.json` scripts for E2E commands such as `test:e2e`, `e2e`, `playwright`, or project-specific wrappers.16- Inspect Playwright config files such as `playwright.config.ts`, `playwright.config.js`, or `playwright.config.mjs`.17- Identify E2E folders such as `e2e/`, `tests/e2e/`, `__e2e__/`, `playwright/`, or folders referenced by Playwright config.18- Inspect nearby specs in the same feature area.19- Inspect existing fixtures, helpers, page objects, factories, API clients, seed utilities, and authentication/storage setup.2021Repository conventions are mandatory and take precedence over generic Playwright patterns or generated recorder-style code.2223Before writing or editing tests:24251. Read the repository's testing documentation, if present.262. Treat mandatory rules from that documentation as required implementation constraints.273. Inspect the closest existing spec for the same feature area.284. Inspect the relevant fixture, helper, page object, and setup files.295. Reuse existing fixtures, helpers, setup utilities, and page object methods before introducing new patterns.3031Core rules:3233- Use repository fixtures instead of `@playwright/test` directly when applicable.34- Use the repository's existing setup utilities for entities, users, permissions, authentication, storage state, and feature flags.35- Create setup data through fixtures, API helpers, factories, seed utilities, GraphQL helpers, or shared utilities already used by the repository.36- Do not create data through the UI unless that creation flow is the behavior under test.37- Route UI interactions through page objects or helper abstractions when the repository uses them.38- Do not put reusable locators or reusable interaction logic directly in specs when the repository has an abstraction pattern for them.39- Extend existing page objects or helpers when possible.40- Create a new focused page object or helper only when the functionality represents a distinct reusable UI area or flow.41- Keep assertions visible in the spec body unless they are repeated low-level checks.42- Match naming, imports, structure, and style from nearby tests.4344## Playwright CLI Skill Usage4546When browser interaction, debugging, tracing, selector inspection, session management, or lightweight validation is needed, use the installed Playwright CLI skills and their reference guides.4748Prefer Playwright CLI capabilities for:4950- test generation drafts51- selector validation52- browser interaction53- tracing54- storage state inspection55- request mocking56- video recording57- session management58- lightweight flow validation59- debugging failing interactions6061Prefer repository fixtures, page objects, helpers, and testing documentation for:6263- final test architecture64- test organization65- setup strategy66- reusable interactions67- assertion placement68- long-term maintainability6970Use `playwright-cli` only for exploration and debugging:7172- discovering current UI behavior73- validating selectors74- checking screenshots or snapshots75- debugging failing flows7677`playwright-cli` output is exploration material only.7879Do not paste raw generated recorder-style code into specs. Refactor generated interactions into fixtures, helpers, and page object methods that follow repository conventions.8081## Validation Rules8283Use the lightest validation strategy possible.8485Preferred validation order:86871. Typecheck or lint changed files if available.882. Use Playwright CLI for fast interaction and selector validation.893. Run the smallest relevant Playwright test scope in headless mode using the repository's E2E command.904. Use headed mode only for explicit debugging.9192Always avoid:9394- unnecessary `--headed`95- full-suite execution96- validating unrelated specs9798Before finishing, verify:99100- repository testing documentation was followed, if present101- the closest existing spec was inspected102- the appropriate fixture, helper, or setup utility was used103- setup data uses repository-standard fixtures, APIs, factories, seed utilities, or helpers104- page object methods or equivalent repository abstractions are used or added where appropriate105- raw locators are kept out of specs where possible106- new interactions are reusable by future tests107- assertions remain visible in the spec body108- the generated code matches nearby repository examples109- the smallest relevant E2E command was run or clearly stated if not run110111If generated code conflicts with repository testing documentation or nearby examples, revise the implementation before returning the result.112113Use Playwright MCP only if `playwright-cli` is insufficient.114115Use `output-template.md` for response formatting.