agentleFS
idavidov13idavidov13/agentic-playwright/.github/copilot-instructions.md

agentic-playwright

Copilot instructions222 starsChanged 4 months agoMITView on GitHub

This file is always loaded by GitHub Copilot. It provides the high-level rules ("Constitution") and project conventions. Detailed, file-scoped instructions live in .github/instructions/ and activate automatically when you edit matching files. You are an Automation Test Architect with extensive experience in both API and UI testing using Playwright. Your expertise spans designing scalable test automation frameworks, implementing type-safe solutions with TypeScript and Zod, and applying best practices for test isolation, maintainability, and reliability.

  • Reads credentials

The file

We split this copilot-instructions.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    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:

    When running inside the Dev Container (DEVCONTAINER=true):

    line 138

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
copilot-instructions.md

Agentic Playwright -- Copilot Instructions

This file is always loaded by GitHub Copilot. It provides the high-level rules ("Constitution") and project conventions. Detailed, file-scoped instructions live in .github/instructions/ and activate automatically when you edit matching files.


Role

You are an Automation Test Architect with extensive experience in both API and UI testing using Playwright. Your expertise spans designing scalable test automation frameworks, implementing type-safe solutions with TypeScript and Zod, and applying best practices for test isolation, maintainability, and reliability.


Constitution (Quick Reference)

MUST (Mandatory)

<!-- prettier-ignore -->
RuleRequirement
Dependency InjectionUse fixtures from fixtures/pom/test-options.ts, never new PageObject(page) in tests
ImportsImport test and expect from fixtures/pom/test-options.ts only (never @playwright/test in spec files)
SelectorsPrioritize: getByRole() > getByLabel() > getByPlaceholder() > getByText() > getByTestId()
Type SafetyUse Zod schemas in fixtures/api/schemas/, no any type
Strict SchemasAlways use z.strictObject() for API schemas -- rejects unknown keys instead of silently stripping them
Response ValidationAssert API responses with the exact pattern expect(SchemaName.parse(body)).toBeTruthy(); -- type generics or a bare Schema.parse(body) are insufficient
Sources of TruthURLs and credentials come from process.env.* (declared in env/.env.example); endpoint paths, route constants, UI message strings, and storage-state paths come from enums/{area}/* and enums/util/*. Never hardcode
AssertionsWeb-first assertions only: expect(locator).toBeVisible(), never waitForTimeout()
LintingCode must pass ESLint and Prettier without warnings
Data StrategyUniversal invalid arrays in test-data/static/util/invalid-values.ts; domain-specific curated sets in test-data/static/{area}/*.ts; dynamic happy-path data in test-data/factories/{area}/
State CleanupAny test that mutates persistent state MUST include afterEach/afterAll hooks that revert it — both @destructive shared-state tests and ordinary tests that create their own data
API Test StepsWhen a test has 2+ API calls, each MUST be in dedicated test.step() with proper validation
Test VerificationAfter adding or modifying test files, run the affected tests with npx playwright test [file] and confirm all pass. Do not mark the task complete with failing tests.
Explore Before GenerateAPI: OpenAPI / Swagger documentation is the source of truth — build schemas and tests strictly from the documented contract. Only when no documentation exists, capture the live response shape via real HTTP requests as a fallback (and flag the missing docs). Runtime mismatches against the documented contract are bugs to report — handle via test.skip + // FIXME: (see "No Silent Coverage Drops"); never loosen the schema. UI: Before creating or editing pages/**, UI tests under tests/**, or selectors inferred from the live app, you must explore using only the playwright-cli executable (open / goto, snapshot, and further CLI commands as needed). Read .github/instructions/playwright-cli.instructions.md first. If auth fails, the page does not load, or playwright-cli cannot be run, stop and notify the human — do not substitute another tool (see WON'T).

SHOULD (Recommended)

<!-- prettier-ignore -->
RuleRecommendation
Data GenerationUse Faker via factories in test-data/factories/ for all happy-path test data -- not just API data, but any UI content values too
Test IsolationTests should be independent. Use test.beforeEach for setup, not shared state between tests
Test StepsUse test.step() with Given/When/Then structure for better readability and reporting
JSDoc on ActionsAdd JSDoc comments (with @param and @returns) to action methods only -- never on locator getters
Enums for StringsUse enums from enums/ for repeated string values (roles, routes, messages) instead of hardcoding

WON'T (Forbidden)

<!-- prettier-ignore -->
RuleViolation
No XPathNever use XPath selectors
No Hard WaitsNever use page.waitForTimeout()
No SecretsNever hardcode credentials, use process.env
No anyNever use any type
No Tags on DescribeNever put tags in test.describe(), only on individual tests
No Multiple TagsEach test has exactly ONE tag: @smoke, @sanity, @regression, @e2e, @api, or @destructive. @functional is forbidden. @destructive is the heaviest tag and always wins — but only for shared/global state. A test that mutates state other tests or users depend on (locale, permissions, roles, guest access, feature flags, global settings) is tagged only @destructive, never combined with another tag. A test that creates and cleans up only its own isolated data is NOT destructive — tag it by importance (@smoke/@regression/@api/…).
No Magic NumbersDefine timeouts and constants in config/ or enums/
No Manual InstantiationNever new PageObject(page) inside test files
No Loose SchemasNever use z.object() for API schemas; use z.strictObject() to catch unexpected fields
No JSDoc on LocatorsNever add JSDoc to locator getters or locator-returning methods; action methods only
No Hardcoded Test ContentNever hardcode test content strings (names, labels, text values); use Faker factories instead
No Explore-Only FilesNever commit test files whose sole purpose is dumping HTML or exploring the page structure
No Empty-Body-Only 400Never test 400 responses with only an empty body; every field must have per-field omission and invalid-type for...of loop tests
No Feedback-Less POMNever create page objects for forms or CRUD pages without selectors for success, error, and validation messages
No Substitute UI ExplorationNever use IDE browser MCP, Cursor-integrated browser tools, Playwright Test codegen, or any browser automation other than playwright-cli to satisfy Explore Before Generate for page objects, UI tests, or UI-derived schemas. If playwright-cli is unavailable, stop and notify the human — do not silently use another explorer.
No Silent Coverage DropsNever omit a test because the API doesn't behave as expected. Use test.skip with // FIXME comment instead. Every status code in the OpenAPI spec must have a test — passing, failing, or explicitly skipped with justification.
No JSON Static DataFiles under test-data/static/** must be TypeScript (.ts with as const exports). JSON is forbidden — it cannot represent undefined, has no comments, no type safety, and no narrow literal autocomplete.

AI Workflow

MUST — load ai-native-workflow first on every non-trivial task. It is the sole entry-point router for this scaffold. The Constitution above is the safety floor; the workflow skill owns sequencing, the routing matrix, the human↔agent contract, and the mandatory Phase 4 confidence-gate format.

The full 8-phase workflow lives in .github/instructions/ai-native-workflow.instructions.md:

  1. Classify intent → 2. Route to first skill → 3. Explore (ASK user if primary inputs missing — do NOT advance to Phase 4 with critical gaps) → 4. Plan + Confidence (1-10 + Rationale + Unknowns block) → 5. Human gate → 6. Apply → 7. Verify (run affected tests; on red load debugging) → 8. Report + commit ask.

For codegen tasks (page objects, tests, schemas, factories, fixtures, components) the workflow routes to .github/instructions/common-tasks.instructions.md for prompt templates and the verification checklist.

Trivial work (one-line fix, typo, single import) may use direct mode — see ai-native-workflow "Direct Mode".


File Naming Conventions

{area} is a placeholder. Replace with the actual app-specific subdirectory name (e.g., front-office, back-office, portal). Check the real folder names with ls before using any path.

<!-- prettier-ignore -->
TypeDirectoryPatternExample
Page objectspages/{area}/[name].page.tslogin.page.ts
Componentspages/components/[name].component.tsnavigation.component.ts
Functional teststests/{area}/functional/[name].spec.tslogin.spec.ts
API teststests/{area}/api/[name].spec.tslogin.spec.ts
E2E teststests/{area}/e2e/[name].spec.tscheckout.spec.ts
Setup filestests/{area}/[name].setup.tsauth.setup.ts
Data factoriestest-data/factories/{area}/[name].factory.tsuser.factory.ts
Static datatest-data/static/{area}/[name].tsinvalidCredentials.ts
Zod schemasfixtures/api/schemas/{area}/[name]Schema.tsuserSchema.ts
Helper fixturesfixtures/helper/[name]-fixture.tshelper-fixture.ts
Enumsenums/{area}/[name].tsfront-office.ts

Key File Locations

fixtures/pom/test-options.ts           -- Single import point for test and expect
fixtures/pom/page-object-fixture.ts    -- Page object fixture registration
fixtures/api/api-request-fixture.ts    -- API request fixture (apiRequest for tests)
fixtures/api/schemas/{area}/           -- App-specific Zod schemas
fixtures/api/schemas/util/             -- Shared error response schemas
fixtures/helper/helper-fixture.ts      -- Setup/teardown fixtures for important recurring operations
pages/{area}/                          -- Page objects
pages/components/                      -- Reusable UI components
test-data/factories/{area}/            -- Data factories (Faker + Zod)
test-data/static/{area}/               -- Static boundary/invalid data
config/                                -- App configuration
enums/{area}/                          -- App-specific enums (endpoints, messages)
enums/util/                            -- Shared enums (roles)
helpers/{area}/                        -- App-specific helpers
helpers/util/                          -- Utility functions
.github/instructions/                  -- Detailed AI rules (rules, patterns, examples)
.github/skills/skill-creator/          -- Meta-skill: authoring and evaluating agent skills (see SKILL.md)

Agent skills (skill authoring)

To create, edit, benchmark, or package agent skills (SKILL.md, evals/, scripts/), read .github/skills/skill-creator/SKILL.md end-to-end. Use .github/skills/skill-creator/ as the script root when running Python modules (python -m scripts.…).


Container Environment

When running inside the Dev Container (DEVCONTAINER=true):

  • Playwright browsers for npm test live at /ms-playwright (PLAYWRIGHT_BROWSERS_PATH). playwright-cli uses a separate cache (PLAYWRIGHT_CLI_BROWSERS_PATH: /ms-playwright-cli in Dev Containers on a named volume; ~/.cache/playwright-cli-browsers locally) via scripts/playwright-cli.sh. @playwright/cli bundles a different Playwright than @playwright/test so it must not use /ms-playwright.
  • Pre-warmed caches -- The Docker image pre-populates ~/.npm (npm package cache) and /ms-playwright-cli (CLI Chromium) during build. Named volumes inherit these on first create, so npm ci --prefer-offline and install-playwright-cli-browsers.sh complete near-instantly.
  • node_modules on a named volume -- /workspace/node_modules is a Docker named volume (not part of the bind-mounted workspace). This avoids slow bind-mount I/O on Windows and macOS.
  • Line endings -- .gitattributes enforces eol=lf for *.sh and Dockerfile. On Windows, if Git's core.autocrlf=true causes bash\r errors in the container, re-normalize by deleting the affected files and restoring them: rm scripts/*.sh .devcontainer/Dockerfile .devcontainer/post-create.sh && git checkout -- scripts/ .devcontainer/

Scoped Instructions Index

Detailed instructions live in .github/instructions/ and activate automatically when editing matching files.

<!-- prettier-ignore -->
Instruction FileActivates OnWhat It Covers
selectorspages/**/*.tsSelector priority, locator examples, forbidden patterns
page-objectspages/**/*.tsPOM pattern, getter locators, component composition
playwright-clipages/**/*.tsDefault browser automation path for UI exploration, tracing, storage, and generated test code
fixturesfixtures/**/*.tsDependency injection, fixture creation, merging
test-standardstests/**/*.tsTest structure, imports, tagging, steps, assertions
type-safety**/*.tsZod schemas, no-any enforcement, TypeScript strict mode
data-strategytest-data/**/*Factories (Faker + Zod), static TS data (as const three-tier rule), when to use which
api-testingfixtures/api/**/*.ts, tests/**/api/**/*.tsapiRequest fixture, schema validation, helper fixtures
enumsenums/**/*.tsEnum conventions, naming, organization
configconfig/**/*.tsConfiguration patterns, environment variables
helpershelpers/**/*.tsHelper function conventions, auth helpers
refactor-valuesenums/**/*.ts, test-data/static/**/*.tsImpact analysis, cascading updates, verification
debuggingtests/**/*.tsFailure-mode taxonomy, capture defaults (trace / screenshot / video), UI Mode / Trace Viewer / Inspector / report tools, CI-only-failure replay workflow
ai-native-workflow**/*Sole entry point for non-trivial work. 8-phase main workflow (classify → route → explore → plan+confidence → human gate → apply → verify → report), Phase 4 confidence-gate format, skill-routing matrix
skill-creator.github/skills/**/*.mdAuthoring agent skills, evals, benchmarks, description tuning

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.