agentleFS
willcoliveirawillcoliveira/playwright-ts-template/AGENTS.md

playwright-ts-template

AGENTS.md5 starsChanged 15 days agoMITView on GitHub

Playwright + TypeScript end-to-end test project. Tests run against https://playwright.dev by default; BASE_URL (from .env or the environment) points them at another application. The same skills live under .agents/skills/ for Cursor, Codex and Copilot. They are generated — edit the generator inputs, not the files, and run npm run skills:sync. Import through the tsconfig aliases: @fixtures/*, @pages/*, @tests/*, @helpers/*, @test-data/*. npm run lint (type-aware: @typescript-eslint/no-floating-promises fails on an un-awaited action or assertion), npm run typecheck and npm run format:check must…

  • Reads credentials

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is 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.

  • 1

    Very specific

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

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

    Import through the tsconfig aliases: @fixtures/*, @pages/*, @tests/*, @helpers/*, @test-data/*.

    line 46
  2. Distinctive:

    Every test must pass alone and in parallel with the others.

    line 65

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

playwright-ts-template — Agent Instructions

Project overview

Playwright + TypeScript end-to-end test project. Tests run against https://playwright.dev by default; BASE_URL (from .env or the environment) points them at another application.

Skills to load

  • .claude/skills/playwright-e2e/SKILL.md — how tests are planned, written, debugged and reviewed in this project (references under references/: shared conventions, operating workflow, delegation rules, project conventions, page-object conventions, test generation, debugging, review, fixtures and auth, locators and assertions, CI and flake triage, API testing, pass-rate analysis, agent debugging).
  • .claude/skills/playwright-cli/SKILL.md — driving a browser and debugging a paused test with playwright-cli.
  • .claude/skills/playwright-trace/SKILL.md — reading a trace with npx playwright trace.

The same skills live under .agents/skills/ for Cursor, Codex and Copilot. They are generated — edit the generator inputs, not the files, and run npm run skills:sync.

Setup

nvm use
npm ci               # no browsers are downloaded on install
npm run pw:setup     # playwright install --with-deps

Commands

npm test                     # all projects
npm run test:chromium        # one project
npx playwright test --grep @smoke
npm run test:ui              # UI mode
npx playwright test --debug=cli   # pause + `playwright-cli attach …` for agents
npm run lint && npm run typecheck && npm run format:check
npm run skills:check         # generated skills must be in sync (CI enforces)

Structure

src/
├── fixtures/         # test-fixture.ts — `test` extended with page-object fixtures; re-exports `expect`
├── pages/            # Page Object Model classes (*.page.ts); components/ for shared pieces
├── tests/            # Specs (*.spec.ts)
├── helpers/          # Utilities
└── test-data/        # Static test data

Import through the tsconfig aliases: @fixtures/*, @pages/*, @tests/*, @helpers/*, @test-data/*.

Conventions

Page objects

  • One class per page in src/pages/{name}.page.ts; locators as readonly fields set in the constructor.
  • Actions wrapped in test.step(); assertion helpers prefixed expect….
  • Navigation through page.goto('/relative') — baseURL comes from the config.

Locators (in order of preference)

  1. getByRole() 2. getByLabel() 3. getByPlaceholder() / getByText() 4. getByTestId() (data-testid) 5. CSS only as a last resort — never XPath.

Tests

  • Specs import test and expect from @fixtures/test-fixture, never from @playwright/test; page objects arrive as fixtures (async ({ homePage }) => …), so specs never call new and keep no describe-scoped variables. Page objects themselves import test from @playwright/test for test.step() (importing the fixtures file there would be a cycle).
  • src/tests/{feature}.spec.ts; test.describe('Feature', { tag: ['@smoke'] }, …) — tags are options, not title suffixes.
  • Web-first assertions only (await expect(locator).toBeVisible()); no waitForTimeout(), no { force: true }, no test.only (CI forbids it).
  • Every test must pass alone and in parallel with the others; no shared mutable state between tests.
  • Retries and traces are CI-only (retries: 2, trace: 'on-first-retry'); a test that only passes on retry is a bug.

Quality gates

npm run lint (type-aware: @typescript-eslint/no-floating-promises fails on an un-awaited action or assertion), npm run typecheck and npm run format:check must pass; CI runs them together with skills:check and a check that the Dockerfile's Playwright image tag equals the installed @playwright/test version, plus a docker job that builds the image and runs the suite inside it (make docker-test). Bumping @playwright/test means bumping the Dockerfile tag and digest and re-running npm run skills:sync.

Dependency updates

Dependabot opens weekly PRs (npm, GitHub Actions, Docker). .npmrc sets ignore-scripts=true and engine-strict=true, so lifecycle scripts never run on install and the Node floor in engines is enforced. A Dependabot PR that bumps @playwright/test fails the Dockerfile tag check and skills:check on purpose: in that PR, bump the Dockerfile tag and digest to the same version, run npm run skills:sync, and commit the regenerated skills so the reviewer sees the instruction diff. A bump of wico-playwright-agent-skills needs the same skills:sync + commit step.

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.