agentleFS
idavidov13idavidov13/agentic-playwright/.cursor/skills/common-tasks/SKILL.md

common-tasks

Skill222 starsChanged 4 months agoMITView on GitHub

Copy-paste AI prompt templates for common Playwright scaffold development tasks — adding page objects, functional/E2E/API tests, Zod schemas, factories, fixtures, and components. Use when the user asks "how do I add a ...", "give me a prompt for ...", "create a new [page object | test | schema | factory | fixture | component]", or when bootstrapping a new scaffold artifact and wanting a standardized starting prompt. This skill is a routing layer; for the deep rules of each task category load the matching skill directly — page-objects / selectors / playwright-cli for UI locators, api-testing for API tests and schemas, fixtures / helpers for fixtures, data-strategy for factories and static data, test-standards for test structure and tags, type-safety for TypeScript + Zod, enums for endpoint enums.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Resolve {area} first: Every template contains {area} as a placeholder.

    line 17
  2. Distinctive:

    After generating code, confirm each box:

    line 52
  3. Very specific:

    Failure protocol: Read the error → load debugging (failure-mode taxonomy + right Playwright tool per failure: UI Mode, Trace Viewer, …

    line 84

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AI Prompt Templates for Agentic Playwright

Codegen sub-router. Owns prompt templates per artifact type and the post-generation verification checklist. Plugs into ai-native-workflow Phase 2 (Route) for codegen intents.

For the 8-phase workflow see ai-native-workflow/SKILL.md. For worked examples and troubleshooting see this skill's references/.

Critical

These rules are unique to template usage. All other rules (selectors, waits, types, Zod strictness, response validation, tags, fixtures, JSDoc, no-XPath, no-hardcoded-strings, etc.) live in the .cursor/rules/rules.mdc Constitution and the leaf skills (api-testing, page-objects, selectors, test-standards, data-strategy, type-safety, fixtures, enums). Re-read the Constitution + the matching leaf skill's Critical block before generating from any template here.

  • Resolve {area} first. Every template contains {area} as a placeholder. Run the matching ls (ls pages/, ls tests/, ls fixtures/api/schemas/, ls test-data/factories/, ls test-data/static/, ls enums/) and substitute the real folder name before filling the template. Do not guess.
  • Templates are starters, not substitutes. Each template is a 10-15 line scaffold. The leaf skill listed for the category owns the deep rules — load it and follow it end-to-end. Never reimplement a leaf skill's rules inline in your prompt.
  • Walk the verification checklist (below) after generating. It is the canonical post-codegen audit; the leaf skills point here for it.

Instructions

Phase 1: Identify the task category and resolve paths

Match the user's request to one row, then run the ls commands the row's templates need.

CategoryTemplate sectionSpecialized skill(s)ls to run before filling
Page object / componentPage Object Taskspage-objects, selectors, playwright-clils pages/
Functional / E2E testTest Taskstest-standards, data-strategyls tests/, ls test-data/factories/
API testTest Tasks → Add API Testapi-testing, test-standardsls tests/, ls fixtures/api/schemas/, ls enums/
Zod response schemaAPI Schema Tasksapi-testing, type-safetyls fixtures/api/schemas/
Data factoryData Factory Tasksdata-strategy, type-safetyls test-data/factories/
Static test dataData Factory Tasks → Static Test Datadata-strategy, api-testingls test-data/static/
Fixture (POM / helper)Fixture Tasksfixtures, helpers(no path placeholder)
UI componentComponent Taskspage-objects, selectors(no path placeholder)

Phase 2: Select and customize the matching prompt template

Open the theme file for your category from the Prompt Templates index below, copy the block, and replace every [PLACEHOLDER] and every {area} with concrete values. Leave no unreplaced placeholders in the final prompt.

Phase 3: Load the specialized skill for the deep rules

The templates intentionally stay shallow. When the task needs more than the template's bullets — full status-code coverage, selector exploration rules, fixture composition patterns — load the specialized skill listed in Phase 1 and follow it end-to-end. Do not reimplement that skill's rules inline. Re-read the .cursor/rules/rules.mdc Constitution + the leaf skill's Critical block before writing code.

Phase 4: Verify with the checklist, then run the affected tests

Walk every box. Then run the affected tests; on red, load debugging.

Verification Checklist

After generating code, confirm each box:

  • Imports are from fixtures/pom/test-options.ts (never @playwright/test in specs)
  • Paths, credentials, and endpoints come from process.env.* and enums/{area}/* — nothing hardcoded
  • Locators use getByRole / getByLabel / getByTestId — no XPath
  • No any types
  • No hard waits (waitForTimeout)
  • No JSDoc on locator getters/methods (JSDoc only on action methods)
  • Tests use test.step with Given/When/Then structure
  • Each test has exactly ONE tag from @smoke, @sanity, @regression, @e2e, @api, @destructive (never @functional, never multiple)
  • Tags live on individual tests, not on test.describe() blocks
  • Tests that mutate shared/global state (locale, permissions, roles, guest access, feature flags, global settings) are tagged only @destructive; tests that create + clean up only their own data keep their importance tag
  • Any state-mutating test (destructive or isolated) has an afterEach/afterAll hook that reverts what it wrote
  • Happy-path test data uses factories; curated invalid values come from test-data/static/util/ or test-data/static/{area}/
  • Zod schemas use z.strictObject() — never z.object()
  • API response validation uses expect(SchemaName.parse(body)).toBeTruthy();
  • API tests with request bodies include empty-body + per-field omission + per-field invalid-type for...of loops (universal arrays imported from test-data/static/util/invalid-values.ts)
  • Coverage audit: Every status code in the OpenAPI spec has a matching test (or test.skip + // FIXME)
  • Path parameter tests: Endpoints with path params have the invalid-format data-driven loop
  • 405 tests: At least one unsupported HTTP method test per endpoint
  • Auth matrix: Endpoints with security have both 401 (no token) and 403 (wrong role) tests
  • Behavior mismatches: Any divergence from spec uses test.skip + // FIXME: <ticket-url>, never silent omission
  • No explore-only or throwaway test files committed

Run the affected tests (mandatory)

npx playwright test tests/{area}/[type]/[name].spec.ts   # specific file
npx playwright test --grep @smoke                        # by tag
npm test                                                 # all non-destructive

Failure protocol: Read the error → load debugging (failure-mode taxonomy + right Playwright tool per failure: UI Mode, Trace Viewer, Inspector, HTML report) → fix the root cause (no try/catch on expect, no timeout bumps, no silent .skip) → re-run; for flake fixes, 5x consecutively.

Prompt Templates

Split by theme under templates/ so the agent loads only the slice it needs — open the file matching your Phase 1 category, copy the block, and replace every [PLACEHOLDER] and {area} with concrete values.

  • Page object templates — new page object (with / without exploration), add locators, add action method
  • Test templates — functional, E2E, data-driven, and API tests
  • API schema templates — Zod schema from docs, fallback capture, add fields
  • Data templates — Faker factory and static test data
  • Fixture templates — page-object fixture, helper fixture, fixture category
  • Component templates — reusable UI component

See Also

  • .cursor/rules/rules.mdc — Constitution (MUST/SHOULD/WON'T tables) is the safety floor for every artifact generated from a template here.
  • ai-native-workflow — owns the 8-phase workflow; Phase 2 routes codegen intents to this skill.
  • api-testing — deep rules for API tests + schemas; load before using Add API Test or Create a New Zod Schema templates.
  • page-objects, selectors, playwright-cli — the UI authoring chain; load before using Page Object Tasks templates.
  • test-standards — spec structure, tagging, web-first assertions, data-driven loops; load before using any Test Tasks template.
  • data-strategy — factory + static-data three-tier rule; load before using Data Factory Tasks.
  • fixtures, helpers — DI patterns and helper-fixture promotion; load before using Fixture Tasks.
  • type-safety — Zod 4 validators + the expect(Schema.parse(body)).toBeTruthy() rule; load before any schema work.
  • debugging — load on Phase 4 verification red.
  • refactor-values — load when a template would change an existing enum value or static-data row.
  • references/examples.md — three end-to-end multi-skill chains using the templates.
  • references/troubleshooting.md — common pitfalls when filling templates and how to fix.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.