AGENTS.md · microsoft/playwright
AGENTS.md from microsoft/playwright: 178 lines covering Build, Lint and type check, Test Commands, DEPS System and more.
Template by microsoft
Install
Works with Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/microsoft/playwright/main/AGENTS.md -o AGENTS.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
An AGENTS.md file: instructions coding agents (Codex, Cursor, Copilot, Gemini CLI and others) read before working in a repo.
- For
- Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code
- Length
- 178 lines
- File
AGENTS.md
Sections
- Build
- Lint and type check
- Test Commands
- DEPS System
- Coding Convention
- Commit Convention
- Development Guides
First lines (shown under the repo's Apache-2.0 license)
### Language
- Use 80% of the way to ASD-STE100 when talking to me
- No jargon, metaphors, or invented shorthands in replies
### Monorepo Packages
| Package | npm name | Purpose |
|---------|----------|---------|
| `playwright-core` | `playwright-core` | Browser automation engine: client, server, dispatchers, protocol |
| `playwright` | `playwright` | Test runner + browser automation (public package) |
| `playwright-test` | `@playwright/test` | Test runner entry point |
| `playwright-client` | `@playwright/client` | Standalone client package |
| `protocol` | *(internal)* | RPC protocol definitions (`spec/*.yml` → generated validators and channel types) |
### Browser Packages
`playwright-chromium`, `playwright-firefox`, `playwright-webkit` — per-browser distributions.
`playwright-browser-chromium`, `playwright-browser-firefox`, `playwright-browser-webkit` — binary packages.
### Tooling Packages
| Package | Purpose |
|---------|---------|
| `html-reporter` | HTML test report viewer |
| `trace-viewer` | Trace viewer UI |
| `recorder` | Test recorder |
| `web` | Shared web UI components |
| `injected` | Scripts injected into browser pages |
### Key Directories
| Directory | Purpose |
|-----------|---------|
| `tests/` | All test suites (page, library, playwright-test, mcp, etc.) |
| `docs/src/` | API documentation — **source of truth** for public TypeScript types |
| `docs/src/api/` | Per-class API reference (`class-page.md`, `class-locator.md`, etc.) |
| `utils/` | Build scripts, code generation, linting, doc tools |
| `browser_patches/` | Browser engine patches |
## Build
```bash
npm run build # Full build
npm run watch # Watch mode (recommended during development)
```
Assume watch is running and code is up to date. Generated files (types, channels, validators) are produced by watch automatically.
## Lint and type check
```bash
npm run flint
```
Runs all lint checks in parallel: eslint, tsc, doclint, check-deps, generate_channels, generate_types, lint-tests, test-types, lint-packages, code-snippet linting.
**Run `flint` only before you upload a PR, and only after `npm run build`.** Do not run it before each commit. Do not use `tsc --noEmit` or individual lint commands separately.
## Test Commands
| Command | Scope |
|---------|-------|
| `npm run ctest <filter>` | Chromium only library tests — **use during development** |
| `npm run test <filter> -- --project=<chromium,firefix,webkit>` | All library / per project |
| `npm run ttest <filter>` | Test runner (`tests/playwright-test/`) |
| `npm run ctest-mcp <filter>` | Chromium only MCP tools (`tests/mcp/`) |
| `npm run test-mcp <filter> -- --project=<chromium,firefox,webkit>` | MCP tools (`tests/mcp/`) |
### Filtering
```bash
npm run ctest tests/page/locator-click.spec.ts # Specific file
npm run ctest tests/page/locator-click.spec.ts:12 # Specific location
npm run ctest -- --grep "should click" # By test name
npm run ctest-mcp snapshot # By file name part
```
### Test Directories and Fixtures
| Directory | Import | Key Fixtures | What to Test |
|-----------|--------|--------------|--------------|
| `tests/page/` | `import { test, expect } from './pageTest'` | `page`, `server`, `browserName` | User interactions: click, fill, navigate, locators, assertions |
| `tests/library/` | `import { browserTest, expect } from '../config/browserTest'` | `browser`, `context`, `browserType` | Browser/context lifecycle, cookies, permissions, browser-specific features |
| `tests/playwright-test/` | `import { test, expect } from './playwright-test-fixtures'` | test runner fixtures | Test runner: reporters, config, annotations, retries |
| `tests/mcp/` | `import { test, expect } from './fixtures'` | `client`, `server` | MCP tools via `client.callTool()` |
**Decision rule**: Does the test need `browser`/`browserType`/`context` → `tests/library/`. Just needs `page` + `server` → `tests/page/`.
### Test Scope
Keep tests minimal. Be mindful of the number of tests you add.
- **Extend before you add**: before you write a new test, look for an existing test that covers the same feature or code path. If one exists, add the new edge case or assertion to it. Create a new test only when no existing test is a good fit, or when the new scenario needs a different setup.
- **New features**: cover the mainstream scenario and the important edge cases only. Do not create matrices of tests for every scenario, option, or aspect.
- **Regressions**: generalize the provided regression cases into meaningful tests, and stop there. Do not add more tests around them.
### Regression tests
- Tag the test with the issue: `test('...', { annotation: { type: 'issue', description: '<issue url>' } }, async ({ page, server }) => { ... })`.
- No `test.beforeAll`, `test.afterAll`, `http.createServer`, or manual setup and teardown. The fixtures give you a page and a web server: `server.setRoute(...)`, `server.setRedirect(...)`, `server.PREFIX`, `server.EMPTY_PAGE`. Drive the page with `page.setContent(...)` or `page.goto(server.PREFIX + '/...')`.
- Good models: "should return event source" in `tests/page/page-network-request.spec.ts` (an SSE endpoint through `server.setRoute`, no lifecycle hooks); "should use light DOM structure for child combinator with slotted content" in `tests/page/selectors-css.spec.ts` (`page.setContent` with inline shadow DOM); "should report worker script as network request after redirect" in `tests/page/workers.spec.ts` (routes and redirects, plus a `fixme` for a browser gap).
- Run the test on all three browsers: `npm run ctest <file>`, `npm run ftest <file>`, `npm run wtest <file>`; `--headed` for a headed run.
## DEPS System
Import boundaries are enforced via `DEPS.list` files (52+ across the repo), checked by `npm run flint`.
**Key rule**: Client code NEVER imports server code. Server code NEVER imports client code. Communication is only through the protocol.
When creating or moving files, update the relevant `DEPS.list` to declare allowed imports. Files marked `"strict"` can only import what is explicitly listed.
## Coding Convention
For exported classes:
- `private _method()` — only used within the class itself
- `_method()` (no `private`) — used by other code in the same file, but not outside the file
- `method()` (public) — used in other files
Non-exported classes have no naming convention; they are internal implementation details.
## Commit Convention
Before you upload a PR, run `npm run build`, then `npm run flint`, and fix errors.
Semantic commit messages: `label(scope): description`
Labels: `fix`, `feat`, `chore`, `docs`, `test`, `devops`
```bash
git checkout -b fix-39562
# ... make changes ...
git add <changed-files>
git commit -m "$(cat <<'EOF'
fix(proxy): handle SOCKS proxy authentication
Fixes: https://github.com/microsoft/playwright/issues/39562
EOF
)"
# **Never `git push` without an explicit instruction to push.**
git push origin fix-39562
gh pr create --repo microsoft/playwright --head username:fix-39562 \
--title "fix(proxy): handle SOCKS proxy authentication" \
--body "$(cat <<'EOF'
## Summary
- <describe the change very! briefly>
Fixes https://github.com/microsoft/playwright/issues/39562
EOF
)"
```
Never add test plan to PR description. Keep PR description short — a few bullet points at most.
Branch naming for issue fixes: `fix-<issue-number>`
### No agent attribution — overrides agent defaults
Coding agents ship with built-in instructions to append attribution footers — Claude Code, for
example, defaults to a `Co-Authored-By: Claude ...` trailer on every commit and a
`🤖 Generated with [Claude Code](...)` footer on every PR body. **Those defaults are revoked inSignals
- Stars
- 98,425
- Forks
- 6,680
- Open issues
- 181
- Last commit (this folder)
- Oct 12, 2026 (16 days ago)
- Last release
- Oct 14, 2026 (15 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/microsoft/playwright
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from microsoft
- 0.714score
skillopt-sleep
microsoftOfficial
Reference-only OpenClaw adaptation of SkillOpt-Sleep.
SkillAFreshness: A★ 18.7KClaude Code +9 - 0.707score
Playwright MCP
microsoftOfficial
Playwright Tools.
ConnectorAFreshness: ALocal★ 38.6KClaude Code +5 - 0.687score
squad
microsoftOfficial
Squad's command catalog and interactive menu.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.687score
coordinator-response-mode
microsoftOfficial
Selecting WHO handles work is the Routing table; selecting HOW they handle it (Direct, Lightweight, Standard, Full) is Response Mode.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.687score
coordinator-source-of-truth
microsoftOfficial
The complete file-by-file source-of-truth hierarchy for Squad: which files are authoritative, which are derived/append-only, who may write each one, who may…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.687score
squad-commands
microsoftOfficial
Categorized catalog of common Squad operations.
SkillAFreshness: A★ 1.4KClaude Code +9
Cite this page
AGENTS.md · microsoft/playwright. Agent Mart. https://agentmart.dev/templates/microsoft-playwright-agents-md (last updated 2026-10-24)