Notes
Give it a map
Start with a rules file at the root of the repo, named AGENTS dot md or the name your tool reads. It tells the agent how to start the app, reset data and run the tests, which locators the team prefers, and the rules that protect test quality: never change an expected value without the requirement behind it, never add retries, sleeps or skips to make a test pass, and use test accounts only. The agent reads it before every task.
- start: cd shoprung && npm start
- reset: POST /api/test/reset
- run: npx playwright test, pytest -q
- locators: roles and labels
- never change an expected value without the requirement id
- never add retries, sleeps or .skip to make a test pass
- test accounts only
Tools for agents
Playwright now ships tools for agents. Init skills installs three skills, playwright CLI, component testing and trace, each a short instruction file that tells an agent when to use the tool and the exact commands. They are plain files in your repo: read them and keep them in version control. The trace skill even declares which commands it needs, npx only, which helps you set permissions.
installs 3 skills into .claude/skills/: playwright-cli playwright-component-testing playwright-trace each SKILL.md: when to use it and the exact commands trace skill: allowed-tools: Bash(npx:*)
playwright-cli
Playwright CLI gives the agent a browser through ordinary shell commands: go to a page, take a snapshot, fill and click by ref, list console messages and network requests. Each action prints the Playwright code it ran. A difference from the MCP server: page snapshots after navigation are saved to files instead of being printed, four of them came to about ten kilobytes, so the agent reads them only when it needs to. That saves tokens.
$ playwright-cli goto .../#/login
Snapshot saved to
.playwright-cli/page-....yml
$ playwright-cli snapshot
textbox "Email" [ref=f1e18]
$ playwright-cli fill f1e18 alice@...
await page.getByRole('textbox',
{ name: 'Email' }).fill(...)
$ playwright-cli requests
[GET] /api/products/4 => 200 Debug from traces
The trace command line lets an agent debug a failed test without opening the trace viewer. We traced the ShopRung coupon test with the coupon boundary bug on. Open showed thirty two actions, sixteen requests and one error. Actions pointed at step twenty three, which waited five seconds. Errors gave the message, and requests showed the coupon call returned four hundred. That is enough for an agent, or you, to see it is a product bug.
open trace.zip: 32 actions, 16 requests, 1 error actions: 23 Expect "toHaveText" 5.0s ✗ errors: "This coupon needs a subtotal of at least $50.00" requests: 16 POST coupon 400 2ms request 16: headers and body
A real finding
Look closer at the same trace. The action list shows the password typed into the login form, in plain text, and the request details include the login token in the authorization header. Traces are often uploaded as CI artifacts, shared in bug reports and now read by agents. So: test accounts only, short-lived tokens, private artifacts, and never a trace from a real customer account.
actions:
13 Fill "Alice123!"
getByRole('textbox',
{ name: 'Password' })
request 16 headers:
Authorization: Bearer
eyJhbGciOiJIUzI1NiIs...
traces are uploaded as CI
artifacts and read by agents Permissions
Give the agent only what the task needs. Allow reading files, running the test commands and editing the tests folder. Make it ask before installing packages, editing CI configuration or deleting files. Deny pushing to the main branch, production systems and real credentials. Most agents support allow and deny lists, and running the agent in a sandbox or container limits the damage of a wrong command.
- allow: read files, run the test commands, edit tests/ ask: install packages, edit CI files, delete files
- deny: git push to main, production URLs and data, real credentials
- run it in a sandbox or a container when you can
Review
Then review the result like any pull request, with a tester's checklist. Did expected values change, and which requirement says so? Any new skips, fix mes, retries, longer timeouts or sleeps? Were assertions deleted or weakened? Ask for the test output, and make every new test fail once on purpose, for example with ShopRung's bug switch, to prove it can fail. And check for secrets in code and artifacts.
- changed expected values? → requirement id, or reject
- new .skip, fixme, retries, longer timeouts, sleeps?
- deleted or weakened asserts?
- tests run: show the output
- new test seen failing once (break it on purpose)
- secrets in code or traces?
Common mistakes
Mistakes. No rules file, so the agent guesses your commands and conventions. A task that says only make the tests pass, which invites the agent to weaken them. Full permissions and no sandbox. Real accounts that end up in traces and logs. Accepting a diff without running it yourself. And new tests that nobody ever saw fail, which may test nothing at all.
- no rules file
- "make the tests pass" as the whole task
- full permissions, no sandbox
- real accounts in traces
- accepting a diff without running it
- new tests never seen failing
Say it like this
In the interview: I give the agent a rules file with our commands and our test quality rules, install Playwright's agent skills, and run it with tight permissions in a sandbox. It debugs failures from traces with the command line. I review every diff for changed expectations, new skips and retries, make each new test fail once on purpose, and keep real secrets out of traces and logs.
- "With a rules file for commands
- and test-quality rules, the Playwright skills, and tight
- permissions in a sandbox. Agents
- debug from traces with the CLI.
- I review every diff for changed
- expectations, skips and retries, see each new test fail once, and keep secrets out of traces."