trace command, and --debug=cli.
Failing tests ship their own context
Start with the feature you get for free. When a test fails, Playwright attaches anerror-context.md file to the test results and points to it right in the terminal output.
Coupon code field, but the snapshot shows the page renders a Discount code textbox. The root cause is sitting right there in plain text. An agent (or you) can spot the mismatch without opening a browser.
The file even starts with LLM instructions (“Following Playwright test failed. Explain why, be concise…”), so it doubles as a ready-made prompt. That’s also what powers the “Copy prompt” button you’ll find next to errors in the HTML report, the trace viewer and UI mode. One click, paste it into your AI chat of choice, and you’re debugging.
If your agent has access to your project, it will usually read error-context.md on its own after a failed test run. This file is a big part of why a plain “please fix this failing test” prompt works as well as it does these days.
npx playwright trace: the trace viewer for terminals
Playwright traces are the most complete record of an end-to-end test failure. The trace viewer makes them easy to inspect, but it’s useless to an agent because it’s a GUI.
Since Playwright 1.59 there’s npx playwright trace, a command that makes recorded traces accessible from the terminal. Point it at a trace file first:
trace actions lists every step of the test with timing and its failure state.
trace action 9 prints the details of the failing step (parameters, error, call log), and trace snapshot 9 renders the page snapshot exactly as it looked at that moment. trace requests lists the network traffic, trace console the console messages, and trace errors the collected errors with stack traces. You get the idea.
It’s all plain text. You can pipe it through grep or any other shell tool, and so can your agent. When a test fails, a simple prompt like this sends your agent through the entire trace, no browser needed:
--debug=cli: a debugger your agent can drive
Sometimes a recorded trace isn’t enough and you want to poke at the live page. For humans, that’s what npx playwright test --debug is for. It opens the Playwright inspector and lets you step through your test action by action. Your agent can’t click through an inspector window, though.

--debug flag accepts a cli mode:
step-over reports where the test is paused and what action comes next. snapshot shows the live page state, requests reveals what’s happening on the network, and you can interact with the paused page using all the other CLI commands (click, fill, eval, and friends). It’s the same Playwright debugger, just in plain text.
For humans, this isn’t a great way to work. But hand it to an agent with the Playwright CLI skill installed:
requests, and discovers, say, that the coupon HTTP call came back with a 500. Watching an agent debug via text is amazingly nerdy, and it works.
Add --headed to the test command if you want to watch the browser while the agent drives.
Debugging doesn’t stop at your test suite
If you’re not on a recent Playwright version, updating is probably the easiest upgrade your agent can get. And this workflow extends past pre-production testing. If you run your Playwright tests as production monitors on Checkly, the same traces get recorded on every failed check run, and Rocky AI analyzes them for you. When a check fails, the root cause analysis is usually done before you even start digging.Further reading
- Debugging scripts
- Common debugging errors
- Control your monitoring infrastructure with AI agents
- Playwright’s trace viewer docs
Bugs don’t stop at CI/CD. Why would Playwright? 
Sign up and start using Playwright for end-to-end monitoring with Checkly.