Playwright Test Prompt
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
Characterization tests for legacy code: assert what it does TODAY — bugs and all — so tomorrow's change can't lie about its impact.
The most dangerous change is one to untested legacy code: nothing fails because nothing was watching. This setup builds the safety net first — characterization tests that pin current behavior exactly as it is, even where it looks wrong (assert the actual output, flag the suspicious cases), previously-fixed bugs covered by name, and output formats asserted exactly where downstream consumers parse them. The failure scenarios are regression's own: fixed bugs returning, drift in untouched paths, formats changing shape under their consumers.
Pin before you plan
Characterization tests come before the refactor design — you can't protect behavior you haven't recorded.
Assert the weird outputs too
If it returns a trailing space today, the test asserts the trailing space — and flags it. Consumers may depend on the weirdness.
Name the historical bugs
Each previously-fixed bug gets a test carrying its ID — the regression suite doubles as the bug museum.
Because characterization tests pin what the code does today, not what it should do. The TEST STRATEGY says to "assert actual current output, even where it looks wrong, and flag the suspicious cases" — a trailing space today gets asserted and flagged, since a downstream consumer may depend on it. The test-case-prompt-generator outputs these tests; you run and review them.
The COVERAGE AREAS require previously-fixed bugs "covered by name, one test each," and the FAILURE SCENARIOS explicitly include "a previously-fixed bug reappears after a refactor." You supply the historical behavior; the generated tests name each bug so a failure message identifies the regression. The tests protect behavior, they don't guarantee correctness.
It doesn't. FRAMEWORK GUIDANCE is set to Generic, so it uses "the project's existing test framework and follows its established conventions" rather than imposing one. For a specific framework's idioms, regenerate in the test-case-prompt-generator with that framework selected. Either way it returns one runnable file grouped by coverage area, not code you've confirmed runs.
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
Mock the dependencies, test the business logic, one behavior per test — the unit testing contract that bans plumbing tests.
Test the two failure directions — does the agent refuse what it must, and does it stay helpful on the benign requests it shouldn't over-refuse?
"Review this code" gets shallow comments. The review contract gets findings with severities, a checklist, and a verdict.
"Fix this error" gets guesses. The investigation contract gets a ten-stage diagnosis: facts separated from assumptions, alternatives weighed, fixes justified.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Build test generation prompts — unit, integration, or E2E — with framework modes and edge-case coverage rules.
A complete AI-assisted review pass — not one prompt — that ends with ranked findings, tests guarding behavior, and a refactor plan when one is warranted.
The order that actually finds bugs instead of guessing at them — so you end with a verified fix, not a plausible one that quietly returns next week.
Update old, risky code you didn't write — safely — by understanding and pinning its behavior in tests before you change a single line.
Restructure code you own without breaking it — change only what's worth changing, and prove with tests and a diff that behavior held.
Speed up code that works but drags — find the actual hot path instead of guessing, understand why it's slow, optimize it, and prove with tests that you changed the speed and nothing else.
Ask AI to "review this for performance" and you get a tidy list of smells with no idea which one production actually spends time on. Here is how to review code for performance with AI so each finding is tied to a workload, ranked by evidence, and marked with the measurement that would confirm it.
You click the thing twenty times, it works every time, and you close the ticket "cannot reproduce" — while it keeps happening to users. Here is how to reproduce a bug with AI: turn a vague report into conditions that make the failure appear and disappear on demand, without inventing the ones you were not given.