seed-skills/playwright-cli-agent-loop/SKILL.md
Teach AI coding agents to use the Playwright CLI and debug loop efficiently with last-failed runs, locator probing, trace evidence, and safe healing.
npx skillsauth add PramodDutta/qaskills Playwright CLI Agent LoopInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an AI coding agent that uses the Playwright CLI as a tight evidence loop: run the smallest useful test, inspect traces, probe locators, fix code, and rerun only what proves the change.
Install Playwright and create predictable scripts.
npm install --save-dev @playwright/test
npx playwright install --with-deps
npm pkg set scripts.test:e2e='playwright test'
npm pkg set scripts.test:e2e:debug='PWDEBUG=1 playwright test --debug'
npm pkg set scripts.test:e2e:last='playwright test --last-failed'
npm pkg set scripts.test:e2e:report='playwright show-report'
Use a config that retains failure evidence.
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests/e2e',
retries: process.env.CI ? 2 : 0,
reporter: [['html'], ['list']],
use: {
baseURL: process.env.BASE_URL || 'http://127.0.0.1:3000',
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
],
});
Follow this loop for every Playwright failure.
--last-failed.Use commands that keep output readable.
npx playwright test tests/e2e/login.spec.ts --project=chromium --reporter=line
npx playwright test -g 'valid user can sign in' --project=chromium --reporter=line
npx playwright test --last-failed --reporter=line
npx playwright show-trace test-results/login-valid-user-chromium/trace.zip
Use Playwright locators to understand what the browser can actually see.
// tests/e2e/probe.spec.ts
import { test } from '@playwright/test';
test('probe accessible names', async ({ page }) => {
await page.goto('/login');
const buttons = await page.getByRole('button').evaluateAll((nodes) =>
nodes.map((node) => ({
text: node.textContent?.trim(),
aria: node.getAttribute('aria-label'),
})),
);
console.log(JSON.stringify(buttons, null, 2));
});
Use debug mode when static logs are not enough.
PWDEBUG=console npx playwright test tests/e2e/checkout.spec.ts -g 'submits order'
npx playwright test tests/e2e/checkout.spec.ts --debug --project=chromium
npx playwright codegen http://127.0.0.1:3000/checkout
When the inspector is open, check these items.
When repairing a locator, improve the contract.
// Before
await page.locator('.btn-primary').click();
// Better
await page.getByRole('button', { name: 'Create project' }).click();
// Also acceptable when the design system owns the accessible name
await page.getByTestId('create-project-button').click();
| Problem | First Command | Follow-Up |
|---|---|---|
| One failing test | playwright test path -g name | Open trace |
| Multiple failures | playwright test --last-failed | Group by root cause |
| Locator timeout | --debug | Probe roles and names |
| Mobile-only failure | --project mobile project | Check viewport assumptions |
| Suspected flake | Repeat exact test | Inspect network and timing |
| Unknown page state | Add temporary probe | Remove probe before final |
waitForTimeout instead of identifying the wait condition.--last-failed after a fix.--last-failed passed after the fix.development
Generate test data from the schemas you already have. Read OpenAPI, JSON Schema, SQL DDL, or TypeScript models and produce deterministic factories, boundary and negative cases, relational datasets with valid foreign keys, cleanup scripts, and PII-safe synthetic data. Production records never leave the machine.
development
Diagnose flaky test failures from Playwright reports, traces, and rerun history. Classify each failure as product, test, environment, data, or unknown with cited evidence and a proposed fix. Never auto-modifies code without opt-in.
tools
Test LLM, RAG, MCP, and agentic systems end to end. Build golden datasets, run deterministic checks and LLM judges, score retrieval, probe prompt injection, verify tool use, and gate CI on thresholds. Orchestrates DeepEval, Ragas, promptfoo, and Langfuse.
development
Analyze a git diff, map affected risks, select the tests that matter, detect coverage gaps on changed lines, run configurable quality gates, and produce a go/no-go release report with cited evidence. Recommends only; never merges or deploys.