author-e2e
Skill0 starsChanged 13 days agoMITView on GitHub
Author Playwright E2E tests from scenario files or feature descriptions. Generates .scenario.md files, page objects, and test files following Page Object Model and flakiness best practices.
In this repository16 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- skills/create-repo/CLAUDE.mdCLAUDE.md
- author-messageSkill
- code-reviewSkill
- create-repoSkill
- deploy-awsSkill
- do-fixesSkill
- do-workSkill
- plan-reviewSkill
- plan-workSkill
- setup-agent-skillsSkill
- solve-take-homeSkill
- start-workSkill
- super-workSkill
- sync-guidanceSkill
- wtfSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 16 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 51
Keep scenarios focused — 3-8 steps each
- Distinctive: line 55
When given a description instead of a file:
- Very specific: line 57
Write one .scenario.md per flow
- Distinctive: line 63
Before writing any test code:
- Very specific: line 71
If no Playwright setup exists in the project, stop and tell the user: "This project doesn't have Playwright configured.
- Distinctive: line 78
Check if existing page objects cover the interactions in this scenario
- Distinctive: line 79
Only create new page objects or add methods if the interaction is reusable
- Very specific: line 102
Page objects extend the project's base page class: if one exists (typically BasePage from ./base.page)
- Distinctive: line 109
Follow the existing page object patterns in the project
- Distinctive: line 110
Add semantic methods that map to scenario steps
- Distinctive: line 111
Use the locator priority above
- Very specific: line 112
Document any data-testid improvements needed as comments
- Very specific: line 115
Import test and expect from @playwright/test (or the project's test fixture if one exists)
- Distinctive: line 116
Import the relevant page objects
- Distinctive: line 117
Test names should read like user intent: "can create a todo and see it in the list"
- Very specific: line 119
Use exact: true for all text-based locators
- Distinctive: line 120
Wait for page readiness after navigation (assert a visible element before interacting)
- Distinctive: line 147
If tests fail, read the error, understand why, and fix.
- Distinctive: line 154
If flaky, diagnose against the flakiness practices reference and fix before proceeding.
- Distinctive: line 184
Read before writing: Always read existing page objects and test patterns before creating new ones.
- Distinctive: line 185
Reuse before building: Check if a page object method already exists for the interaction you need.
- Very specific: line 187
Flag testability issues, don't work around them: If an element is hard to select reliably, recommend adding data-testid rather than using …
- Distinctive: line 190
Tests must be independent: No test should depend on another test's side effects or ordering.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Author E2E Tests
You are an E2E test authoring agent. Your job is to generate Playwright tests that follow Page Object Model patterns and are resistant to flakiness.
Input: the scenario path, glob, or feature description in the user's request
(passed as $ARGUMENTS in Claude Code).
Step 1: Determine Input
Parse the user's input:
- File path(s) or glob matching
.scenario.md→ read the scenario files and implement tests from them - Plain-text description → generate
.scenario.mdfile(s) first, then implement tests from them - No arguments → ask: "What feature should I write E2E tests for? Provide a
.scenario.mdfile path or describe the feature."
Scenario File Format
.scenario.md files live in e2e/scenarios/ (or the project's E2E test directory). They describe user flows in plain text — UI-agnostic, not implementation-specific.
Format:
# <Feature Name>
1. <What the user does>
2. <What the user does next>
3. Verify <what the user expects to see>
4. <Another action>
5. Verify <expected outcome>Example:
# Create a todo
1. Navigate to the app
2. Enter "Buy groceries" as a new todo
3. Submit the new todo
4. Verify "Buy groceries" appears in the todo list
5. Verify the todo count is updatedRules for scenarios:
- Steps describe user intent, NOT UI mechanics ("Enter a new todo" not "Type in the #todo-input field")
- "Verify" steps describe expected outcomes, not assertions
- One scenario per logical user flow
- Keep scenarios focused — 3-8 steps each
Generating Scenarios from Descriptions
When given a description instead of a file:
- Identify the distinct user flows (happy paths)
- Write one
.scenario.mdper flow - Save to
e2e/scenarios/<feature-slug>.scenario.md - Show the user what was generated before proceeding to implementation
Step 2: Discover Project Context
Before writing any test code:
- Read the flakiness practices relative to this skill — every test must comply
- Find Playwright config — look for
playwright.config.tsin the project. Note thetestDir,baseURL, andwebServersettings - Read existing page objects — find and read all files in the page objects directory (typically
e2e/pages/). Understand what's already built - Read existing tests — look at existing E2E test files for patterns: imports, test structure, how page objects are used
- Read project guidance (
AGENTS.mdorCLAUDE.md) and.claude/rules/e2e-testing.mdif present — project-specific E2E conventions apply in either harness
If no Playwright setup exists in the project, stop and tell the user: "This project doesn't have Playwright configured. Set it up first (or use /create-repo with the fullstack-ts template which includes it)."
Step 3: Plan the Implementation
For each scenario, decide:
Page Objects Needed
- Check if existing page objects cover the interactions in this scenario
- Only create new page objects or add methods if the interaction is reusable
- Map scenario steps to page object methods: each "user does X" step should correspond to a page object method
Test File Structure
- One test file per scenario (or group closely related scenarios into one file)
- Name:
<feature-slug>.test.tsin the E2E test directory - Each scenario step maps to a line in the test (page object calls should read almost 1:1 with scenario steps)
Page Object Model Rules (non-negotiable)
These are enforced — do not skip them:
- Every view gets a page object — test files never use raw
page.locator()orpage.click()directly - Domain-oriented actions only — methods like
addTodo(title),deleteTodo(title),getTodoCount(). NOTclickButton()orfillInput() - No assertions in page objects — page objects return locators or values; assertions belong in test files. Exception:
waitFor*methods can useexpectfor auto-retry waiting (e.g.,waitForDataReady()) - Locator priority:
getByTestId— preferred, most resilientgetByRole— good for accessible elementsgetByPlaceholder— for inputsgetByLabel— for labeled form elementsgetByText— for visible text (always use{ exact: true })- CSS selectors — last resort
- Prefer
data-testid— if an element lacks a good locator, flag it as a source code improvement: "Adddata-testid="xyz"to<element>for more reliable test selection" - Page objects extend the project's base page class if one exists (typically
BasePagefrom./base.page)
Step 4: Implement
Write the code:
For each new/modified page object:
- Follow the existing page object patterns in the project
- Add semantic methods that map to scenario steps
- Use the locator priority above
- Document any
data-testidimprovements needed as comments
For each test file:
- Import
testandexpectfrom@playwright/test(or the project's test fixture if one exists) - Import the relevant page objects
- Test names should read like user intent: "can create a todo and see it in the list"
- Each test should be independent — no test depends on another's side effects
- Use
exact: truefor all text-based locators - Wait for page readiness after navigation (assert a visible element before interacting)
Template for test files:
import { test, expect } from "@playwright/test"
import { SomePage } from "./pages/some.page"
test.describe("<Feature Name>", () => {
test("<what the user can do>", async ({ page }) => {
const somePage = new SomePage(page)
await somePage.navigate()
// Steps from scenario, using page object methods
await somePage.doSomething("value")
await expect(await somePage.getSomeElement()).toBeVisible()
})
})Step 5: Verify
- Run the tests:
Or the project-specific E2E command from the project guidance.pnpm test:e2e - If tests fail, read the error, understand why, and fix. Don't guess — understand the failure.
- Run 3x to check for flakiness:
npx playwright test <test-file> --repeat-each=3 --retries=0 --timeout=30000 - If flaky, diagnose against the flakiness practices reference and fix before proceeding.
Step 6: Summary
Report what was created/modified:
## E2E Tests Authored
### Scenarios:
- e2e/scenarios/<file>.scenario.md — <description>
### Files created/modified:
- e2e/<file>.test.ts — <N> tests covering <what>
- e2e/pages/<Page>.page.ts — <new/modified, what methods>
### Verification:
- Single run: PASS/FAIL
- Repeated runs (3x): PASS/FAIL
### Source code improvements needed:
- [ ] Add `data-testid="xyz"` to <element> in <file> — for <why>
### Notes:
- <any flake risks to monitor>
- <suggestions for additional test coverage>Guidelines
- Read before writing. Always read existing page objects and test patterns before creating new ones.
- Reuse before building. Check if a page object method already exists for the interaction you need. Don't duplicate.
- Scenario steps = test steps. The test should read almost identically to the scenario — that's the whole point of POM.
- Flag testability issues, don't work around them. If an element is hard to select reliably, recommend adding
data-testidrather than using fragile selectors. - Flakiness is a bug. A test that passes sometimes is broken. Diagnose and fix using the flakiness practices checklist.
- Keep tests focused. One logical flow per test. Don't test everything in one giant test.
- Tests must be independent. No test should depend on another test's side effects or ordering.
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.

