pw-pom-generator
Skill4 starsChanged 39 days agoMITView on GitHub
Generate a Playwright POM-style test suite (Page Object + typed presets + spec) from flow notes — locators, scenarios, and optional gap analysis. Use when the user wants to scaffold Playwright tests, create a page object for a flow, generate POM files, write a spec from exploration notes, or wire typed test-data presets. Framework- and auth-agnostic — wallet/auth/login steps are emitted as clearly marked placeholders the user fills in. Triggers on phrases like "scaffold Playwright tests", "generate POM", "create page object", "write spec from notes", "Playwright test boilerplate for <flow>".
In this repository8 other files it gives its agents.
- api-contract-reviewerSkill
- api-contract-writerSkill
- e2e-writerSkill
- playwright-sdet-expertSkill
- pw-failure-triageSkill
- pw-project-bootstrapSkill
- pw-test-reviewSkill
- qa-shift-leftSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 9 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Use e2e-writer instead when the app can be opened from this machine: it looks at the real page, prepares data through the API, runs the …
- Distinctive: line 24
Do not trigger for:
- Distinctive: line 39
Only a project with no page objects gets the default layout below.
- Distinctive: line 43
Ask once, then proceed. Don't drag the user through a form.
- Distinctive: line 51
If the user has an exploration report or notes doc, accept it as-is.
- Very specific: line 62
If the project already has a tests/components/ or tests/fixtures/ folder, compose shared components (header, modal, toast) from there …
- Distinctive: line 68
Before writing files, sort the user's notes into buckets:
- Distinctive: line 78
If a constant or component already exists, reuse it.
- Very specific: line 98
If two preset fields are coupled (e.g.
- Very specific: line 104
Default fixture import is @playwright/test unless the project has a custom fixture (tests/fixtures/*.ts) — if so, ask the user which one …
- Very specific: line 106
Use web-first assertions: expect(...).toBeVisible(), .toHaveText(), .toBeEnabled(), .toHaveURL()
- Distinctive: line 109
Don't add browser teardown — fixtures own that
- Very specific: line 113
If the user's notes contain repeated regexes (URL patterns, success-modal headings, button label variants), extract them to …
- Very specific: line 123
If the project uses dotenv or another loader (visible from existing scripts), match that pattern.
- Very specific: line 142
Stop after this. Do not execute the tests — the user runs them.
- Distinctive: line 145
If the project has a CLAUDE.md, propose the lines to add under "Test conventions" (where the page objects live, the locator convention …
- Distinctive: line 150
No raw selectors in spec files: Always go through the Page Object or a shared component.
- Very specific: line 151
No
test.skipto hide unimplemented setup: Use test.fixme() with a comment explaining what's missing.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pw-pom-generator
Scaffold a per-flow Playwright suite that follows the Page Object Model + typed presets pattern. The skill emits three files (Page Object, presets, spec) plus optional constants, all consistent with each other and ready to run after the user fills in placeholders for auth/setup.
When to trigger
Trigger when the user asks to:
- "Scaffold Playwright tests for
<flow>" - "Generate a POM / page object for this page"
- "Create page object + presets + spec"
- "Write a Playwright spec from these exploration notes"
- Any time they hand you a list of locators / scenarios and want runnable scaffold code
Use e2e-writer instead when the app can be opened from this machine: it looks at the real page,
prepares data through the API, runs the tests and proves they can fail. This skill is for the
case where only notes exist (no access to the environment yet, a page still in design).
Do not trigger for:
- Reviewing existing tests (use
pw-test-reviewinstead) - Running tests / debugging failures
- Setting up a new Playwright project from scratch (no
playwright.config.tshere — assume one exists)
Before anything: read the project
CLAUDE.mdin the test folder, if there is one: project profile and test conventions. It wins over every default in this skill.- Existing page objects, wherever they live: read the base classes (if any), two pages, one
component, the fixture that hands them to a test, one spec. A structure that exists wins.
The project may use per-flow folders (the default below) or a registry
(
PageHolder→Component→AppPage, oneApplicationobject handed to tests by a fixture). Generate in the shape you found, including its naming and where locators live. - Only a project with no page objects gets the default layout below.
Inputs to collect
Ask once, then proceed. Don't drag the user through a form.
- Flow slug — kebab-case (
buy-position,checkout,login). Becomes the folder name and file prefix. - Locators — list of things to interact with on the page. Any format the user gives you is fine (bullet list, paste from exploration doc, JSON). Each locator needs at least a human name (
submit button) and a recognizable identifier (role+name, label, placeholder, text, or as a last resort CSS). - Scenarios — minimum one happy path. Negative / gap-coverage / validation cases are optional but recommended.
- Project conventions (if not obvious from a quick scan): fixture path (
tests/fixtures/*.ts), module system (ESM with.jssuffix on TS imports, or plain CJS/no-suffix), TypeScript or JS. - Auth/setup hooks (optional) — if the flow needs login, wallet connect, API seeding, etc. Capture where they happen (before the form, mid-flow) so placeholders land in the right spot.
If the user has an exploration report or notes doc, accept it as-is. Don't require a specific schema.
Output layout
tests/<slug>/
├── <slug>.page.ts # Page Object — locators + high-level actions
├── <slug>.presets.ts # Typed test data presets
└── <slug>.spec.ts # Test cases — no raw selectorsIf the project already has a tests/components/ or tests/fixtures/ folder, compose shared components (header, modal, toast) from there instead of redefining them in the POM. See references/layout-guide.md for the full convention (shared src/, constants split, ESM .js suffix gotcha).
Workflow
Step 1 — Classify each input
Before writing files, sort the user's notes into buckets:
| Belongs in... | What goes there |
tests/<slug>/<slug>.page.ts | Flow-specific locators + high-level actions; composes shared components |
tests/<slug>/<slug>.presets.ts | Strongly-typed test-data fixtures (named consts: minimumPreset, fullPreset) |
tests/<slug>/<slug>.spec.ts | Test cases. No raw selectors. |
src/constants/<slug>.ts (if exists) | URL regexes, copy regexes (button labels, success headings), enum-like maps |
tests/components/ | UI primitives shared with other flows (header, tx modal, toasts, sidebar) |
If a constant or component already exists, reuse it. Do not duplicate.
Step 2 — Write the Page Object
See references/page-object-template.md.
Key rules:
- Constructor takes
Page, assigns fields in the body (avoidconstructor(public readonly page)— fails on Node 24 strip-only TS) - One getter per locator, camelCase names
- Locator priority:
getByRole→getByLabel→getByPlaceholder→getByText({ exact: true })→getByTestId→ CSS (anchored on[name]/[data-*], nevernth(i)) - High-level actions compose multiple locators (
fillFromPreset(preset),expand(section),submit()) goto()method for the entry URL — acceptbaseUrlas a parameter, don't hard-code it
Step 3 — Write the presets
See references/presets-template.md.
- Define a
<Flow>Presettype that mirrors the form/inputs the user described - Export at least one named const (
minimumPreset); add more if the user gave multiple scenarios - If two preset fields are coupled (e.g. "Field B only valid when Field A is X"), encode the constraint with a
// TODO:comment, not a runtime check
Step 4 — Write the spec
See references/spec-template.md.
- Default fixture import is
@playwright/testunless the project has a custom fixture (tests/fixtures/*.ts) — if so, ask the user which one and use it - Auth / wallet / login steps are marked with
// SETUP_REQUIRED: <what>placeholders the user fills in. Never emit fake auth code (mock tokens, hardcoded sessions,localStorage.setItemhacks) — placeholders are honest, fakes break in CI - Use web-first assertions:
expect(...).toBeVisible(),.toHaveText(),.toBeEnabled(),.toHaveURL() - No
page.waitForTimeout(...),networkidle(for non-navigation waits),force: trueclicks, ortoContainTexton numeric values (false-positive risk —"1"contains"") - Pull timeouts from config / constants if the project has them; otherwise rely on Playwright's defaults
- Don't add browser teardown — fixtures own that
Step 5 — Optional: constants file
If the user's notes contain repeated regexes (URL patterns, success-modal headings, button label variants), extract them to src/constants/<slug>.ts (or wherever the project keeps constants). If no such folder exists, inline them at the top of the spec as const declarations.
Step 6 — Suggest the npm script
Tell the user (do not silently edit package.json) to add:
"test:<slug>": "playwright test tests/<slug>"If the project uses dotenv or another loader (visible from existing scripts), match that pattern.
Step 7 — Print a summary
✓ tests/<slug>/<slug>.spec.ts — X tests across Y describe blocks
✓ tests/<slug>/<slug>.page.ts — Z locators, N actions[, composes <ComponentA>, <ComponentB>]
✓ tests/<slug>/<slug>.presets.ts — M presets exported
✓ src/constants/<slug>.ts — K constants (if new; otherwise list reused)
Coverage breakdown:
- Happy path: ...
- Validation: ...
- Gap / negative: ...
SETUP_REQUIRED markers: N (lines: ...)
Suggested npm script: "test:<slug>": "playwright test tests/<slug>"Stop after this. Do not execute the tests — the user runs them. Say plainly that the locators
come from notes and were not checked against the page, and offer e2e-writer for that.
If the project has a CLAUDE.md, propose the lines to add under "Test conventions" (where the
page objects live, the locator convention used), and add them after a yes.
Hard rules
- No raw selectors in spec files. Always go through the Page Object or a shared component.
- No
test.skipto hide unimplemented setup. Usetest.fixme()with a comment explaining what's missing. - No teardown that closes the browser — fixtures own lifecycle.
- No
expect(...).toContainText('1')— substring on numeric strings false-positives ("10"contains"1"). UsetoHaveTextor anchored regex. - No comments explaining the obvious. Names should carry the meaning.
References (load on demand)
references/layout-guide.md— project layout conventions, ESM.jssuffix gotcha, sharedsrc/vstests/components/decision treereferences/page-object-template.md— full POM template with composition examplereferences/presets-template.md— typed presets templatereferences/spec-template.md— spec template withSETUP_REQUIREDplaceholder pattern
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
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.

