<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ben Weese</title>
    <description>The latest articles on DEV Community by Ben Weese (@ben_weese).</description>
    <link>https://dev.to/ben_weese</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3919040%2Fc0bc43a0-eaf1-4a46-9997-77f6ff914f63.jpeg</url>
      <title>DEV Community: Ben Weese</title>
      <link>https://dev.to/ben_weese</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ben_weese"/>
    <language>en</language>
    <item>
      <title>Playwright Agents Six Months Later: The Brutal Lessons That Made Them Better</title>
      <dc:creator>Ben Weese</dc:creator>
      <pubDate>Sun, 15 Nov 2026 20:08:55 +0000</pubDate>
      <link>https://dev.to/ben_weese/playwright-agents-six-months-later-the-brutal-lessons-that-made-them-better-3f13</link>
      <guid>https://dev.to/ben_weese/playwright-agents-six-months-later-the-brutal-lessons-that-made-them-better-3f13</guid>
      <description>&lt;p&gt;&lt;a href="https://benweese.com/building-playwright-agents-lessons-from-the-deep-trenches/" rel="noopener noreferrer"&gt;Last time&lt;/a&gt;, my planner burned 156k tokens, 78% of my window, planning one feature. If I asked it to plan the next feature on the same page, it scanned the whole page again from scratch, as if the page might have changed overnight. Six months later my agents work like an actual D&amp;amp;D party, with a rulebook, a scout, a cleric on a budget, and me as the DM signing off on every big move. This is what changed in my Playwright agents, the skills and commands around them, and the flow that turns a Jira ticket into tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Party Needed a Rulebook
&lt;/h2&gt;

&lt;p&gt;The first fix wasn't an agent at all. CLAUDE.md started as one giant file with the whole framework in it, and every session loaded all of it, like reading the entire Player's Handbook aloud before anyone rolls initiative. The generator needed more than a summary of the framework, though. It needed to know how I actually write code, folder by folder.&lt;/p&gt;

&lt;p&gt;So I split it. The root CLAUDE.md is a short pointer table now, and each folder gets its own guide that only loads when Claude is working there. The &lt;code&gt;api/&lt;/code&gt; guide explains that I treat endpoints like page objects, so the generator builds an API client the same way it would build a page. The &lt;code&gt;tests/ui/&lt;/code&gt; guide covers my three-file pattern for UI tests, and &lt;code&gt;tests/api/&lt;/code&gt; covers the singleton clients and helper rules.&lt;/p&gt;

&lt;p&gt;It paid off in tokens too, which was the best tip in an article on cutting Claude Code's token burn (linked below). The root went from 12,306 characters to 5,177, which is 58% and roughly 1,790 tokens off every single session. That won't make anyone rich, but it comes off every session whether I send 2 messages or 200.&lt;/p&gt;

&lt;p&gt;It's a tax cut, not a coupon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiv7ekah9fuktw5d8ip8w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiv7ekah9fuktw5d8ip8w.gif" alt="Animated GIF: a student slumped at a classroom desk, falling asleep while the teacher talks." width="300" height="300"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Every session, back when CLAUDE.md read the whole framework aloud before doing anything.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet the Party
&lt;/h2&gt;

&lt;p&gt;I started with three agents, all of them driving the browser and all of them doing a little of everything. Now each one has a class, and the party's bigger:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Agent&lt;/th&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Page-mapper&lt;/td&gt;
&lt;td&gt;Ranger&lt;/td&gt;
&lt;td&gt;Scans a page once and writes down every control, URL param, validation message, and empty state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI planner&lt;/td&gt;
&lt;td&gt;Wizard&lt;/td&gt;
&lt;td&gt;Reads the map and writes the best plan it can. Never touches the browser.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Manual test writer&lt;/td&gt;
&lt;td&gt;Bard&lt;/td&gt;
&lt;td&gt;Writes the Manual test steps into Xray from the approved plan. A new coworker built it, and I plugged it into the flow.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI generator&lt;/td&gt;
&lt;td&gt;Fighter&lt;/td&gt;
&lt;td&gt;Turns the approved plan into locators, page objects, and specs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Healer&lt;/td&gt;
&lt;td&gt;Cleric&lt;/td&gt;
&lt;td&gt;Fixes broken locators, with three spell slots per test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API planner&lt;/td&gt;
&lt;td&gt;Artificer&lt;/td&gt;
&lt;td&gt;Plans API coverage from the ticket&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API generator&lt;/td&gt;
&lt;td&gt;Rogue&lt;/td&gt;
&lt;td&gt;Writes the API specs from that plan&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;The party: each agent, its D&amp;amp;D class, and its job&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The ranger is the big change. Before the page-mapper, the planner scouted every room itself on every plan, which is how one feature ate 78% of my window. Now the map gets written once to &lt;code&gt;.claude/pages/&lt;/code&gt;, and every plan after that just reads it. That gave the planner one job: make the best plan it can, with all of its attention on what's worth testing instead of on clicking around.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkfe2ub0524yon2wtmyqi.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkfe2ub0524yon2wtmyqi.gif" alt="Animated GIF: a flip clock rolling over to 6:00, the Groundhog Day alarm that starts the same morning again." width="197" height="136"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The planner before the page-mapper, scouting the same page every single time.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I tried it first on a real ticket, an export drawer. Pages I hadn't mapped yet got &lt;code&gt;test.fixme()&lt;/code&gt; instead of guesses, which is the ranger saying "haven't been there yet" instead of the wizard inventing a floor plan. I'll take an honest gap over a confident fake every time.&lt;/p&gt;

&lt;p&gt;On the API side, my boss built the first generator, a paladin who had to call on a higher power for every move. It sent one Jira ticket to the Claude API along with a markdown file on how to plan it. When we moved to a Claude Code instance per QA person, I split it in two. An artificer plans, since API planning is the most technical job in the party, and a rogue writes the specs. The Anthropic SDK left the project for good, and Claude Code does all the thinking now.&lt;/p&gt;

&lt;h2&gt;
  
  
  I'm the DM Now
&lt;/h2&gt;

&lt;p&gt;Hand it a Jira ticket key and the first thing it does is pull the ticket through the API and write a brief. The brief is the quest briefing: the ticket's requirements, its acceptance criteria, and the API clients the repo already has. That way the wizard knows what's in the party's inventory before planning anything. Point it at an epic and it pulls every child ticket too. It cuts the duplicates and writes one brief for the whole campaign, split into API and UI.&lt;/p&gt;

&lt;p&gt;From there it runs one flow, and nothing gets past a checkpoint until I say so. The agents can roll all the dice they want. I approve the plan and the Manual tests before a single line of automation gets written. Sometimes the requirement itself is wrong. It can sail through development untouched, and if nobody reads the plan, the agents will write a test that proves the mistake works perfectly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpuwoqdfzvqyj0xtd8rsn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpuwoqdfzvqyj0xtd8rsn.png" alt="Flowchart of my Playwright agents: Jira key, brief, plan, DM plan review, Manual tests in Xray, DM review, automation, run and review, Cleric for UI locators." width="282" height="1024"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Manual tests come first on purpose. Writing the steps into the Xray case gives us real steps in our reporting. The Manual test and the automation both come from the same plan, so they line up when we tie them together. They also put a person in front of the feature. Human eyes still catch things the AI never thinks to look for.&lt;/p&gt;

&lt;p&gt;The generate-tests skill runs all of this, and after the brief it stops and waits for my OK. I also wrote a rule into both the planner and the generator to check whether a test already exists before writing one. So when the fighter shows up to clear a room, the wizard can tell him it's already been cleared. I'd rather hear that than review a duplicate test I'm just going to delete.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmvjygaq3y6w4f6be5ogq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmvjygaq3y6w4f6be5ogq.gif" alt="Animated GIF: Jim Halpert from The Office turning from his computer to give a deadpan stare." width="478" height="269"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The fighter, finding out the wizard already cleared this room.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The plans got stricter too. Every scenario reads like a manual test and names its Xray folder, which follows naming rules instead of whatever someone felt like typing that day. The generator writes the real Xray key into each automated test, so when one fails, it points straight back to the Manual test it came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  House Rules
&lt;/h2&gt;

&lt;p&gt;Last time I wrote about a filter test that checked the URL and never checked the table. That one was on me, bad prompting rather than a bad agent. Since then Nima Parvathy and I kept hitting failures in real use, and each one turned into a new rule in the agents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't wrap assertions in guards that let missing data pass quietly.&lt;/li&gt;
&lt;li&gt;Don't hide &lt;code&gt;test.skip()&lt;/code&gt; behind a conditional where nobody will see it.&lt;/li&gt;
&lt;li&gt;Poll for eventually consistent data instead of waiting a fixed amount of time.&lt;/li&gt;
&lt;li&gt;Use the real pagination response shape, never guessed field names.&lt;/li&gt;
&lt;li&gt;When the plan and the Jira ticket disagree, assert what the ticket requires.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one is the big one, and Nima and I each added it at different times. It's rules as written versus the player who swears he rolled a 20. The point of a test is to prove the requirements are met, not to prove the code does what the code does. If the plan says something different from the ticket's requirements, the agent doesn't get to go with the plan. It asserts the acceptance criteria, lets the test fail, and reports the difference as a possible bug.&lt;/p&gt;

&lt;p&gt;When I rebuilt this setup in public, plan review caught exactly that. One test expected the "Order Placed!" text the page showed instead of the message the site's own docs describe. Another accepted empty search results, so it would have passed with search completely broken. Both would have been green.&lt;/p&gt;

&lt;p&gt;Both now fail when they should.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fymld07782xrcp690napt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fymld07782xrcp690napt.gif" alt="Animated GIF: Moss from The IT Crowd sitting calmly at his desk while a fire burns right next to him." width="500" height="272"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The search test, reporting green while search was completely broken.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here's where it gets interesting. A rule in a prompt is a house rule, and house rules only hold while everyone at the table remembers them. In the public rebuild I moved every rule I could into lint, so serial mode, skipped tests, XPath, fixed waits, and &lt;code&gt;.nth()&lt;/code&gt; never make it past &lt;code&gt;npm run lint&lt;/code&gt;. The ticket-wins rule can't go there, because lint can't tell where an expected value came from, so that one still needs the DM reading the plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Cleric Gets Three Spell Slots
&lt;/h2&gt;

&lt;p&gt;In October I went after locators. The generator and healer share one set of rules now: anchor on a stable container, act on the element with a &lt;code&gt;getBy*&lt;/code&gt; method, and never use XPath, class names, or &lt;code&gt;.nth()&lt;/code&gt;. Class names don't change every build, but they can, and when one does, every locator built on it breaks at once. The generator also scopes to the right row or card on pages that repeat the same structure, instead of grabbing the first match it finds.&lt;/p&gt;

&lt;p&gt;The healer gets three attempts per test, and then it stops. Without that limit it would run nonstop, chasing a locator that isn't flaky and never quite finding one. If it can't land a solid locator in three tries, the test gets &lt;code&gt;test.fixme()&lt;/code&gt; with a comment saying what it tried, and I take it from there.&lt;/p&gt;

&lt;p&gt;Three spell slots, then a long rest.&lt;/p&gt;

&lt;p&gt;Sometimes nobody in the party is actually hurt. The public rebuild runs against a shared demo site, and at the default worker count 19 tests failed. Eight were real findings, the site disagreeing with its own docs, and most of the rest were the site answering "503 heavy load." Capping workers at 2 cut the overload failures from 11 to 2. Once I stopped smoke tests from running twice, the only failures left were the 7 findings.&lt;/p&gt;

&lt;p&gt;The healer would have burned spell slots on every one of those 503s while the dungeon ceiling was the real problem. Nobody's filing a performance bug over a demo site with demo tests hitting it, so the config stays pinned at two workers and the agents check for 503s before blaming a locator.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F38lqdk4sx3i0rsl6zxl3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F38lqdk4sx3i0rsl6zxl3.gif" alt="Animated GIF: a cartoon moose chef proudly lifting a serving cloche, with the caption &amp;quot;nailed it.&amp;quot;" width="480" height="480"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The healer after fixing a locator that was never broken, while the site was throwing 503s&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Packing the Party for Travel
&lt;/h2&gt;

&lt;p&gt;Then our UI started splitting into plugins, and every plugin got its own Playwright repo. The party couldn't live in one repo anymore, so I packed it into a Claude Code plugin that any test repo can install. It carries the party, the skills that drive them, and the slash commands I reach for every day:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;In the kit&lt;/th&gt;
&lt;th&gt;What it's for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;generate-tests&lt;/code&gt; skill&lt;/td&gt;
&lt;td&gt;The Jira ticket to tests flow above&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;create-readme&lt;/code&gt; skill&lt;/td&gt;
&lt;td&gt;Figures out what kind of repo it's in and writes an on-boarding README from the repo's own files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;playwright-cli&lt;/code&gt; skill&lt;/td&gt;
&lt;td&gt;Playwright's own skill for driving a browser, used by the ranger, the fighter, and the cleric&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;update-docs&lt;/code&gt; skill&lt;/td&gt;
&lt;td&gt;Runs on every commit through Husky and updates the docs to match what changed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/brief&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs the Jira intake for a ticket key and writes the brief&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/run-spec&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs one spec through the debug script&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/check&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs lint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;/bug-ticket&lt;/code&gt;, &lt;code&gt;/qa-task&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Draft a ticket, then create it in Jira after I confirm&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;What the Claude Code plugin carries&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1xqv5sgywqb4cly5lpyh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1xqv5sgywqb4cly5lpyh.gif" alt="Animated GIF: an overstuffed blue suitcase sitting on a forest path." width="320" height="320"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Getting the whole party, their skills, and every command into one plugin.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The ticket commands got the best upgrade. They used to draft a ticket for me to paste in by hand. Now they create it once I confirm, and &lt;code&gt;/bug-ticket&lt;/code&gt; with a ticket key files a Story-Bug under that ticket instead of a loose Bug. If Jira rejects the issue type, the error lists the valid ones and the command retries once on its own.&lt;/p&gt;

&lt;p&gt;The bottleneck never went away. It moved from writing tests, to babysitting a planner that clicked through every page, to me sitting behind the DM screen reading plans. I'll take that trade, because the plan is the last place a wrong requirement gets caught before it turns green.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://benweese.com/building-playwright-agents-lessons-from-the-deep-trenches/" rel="noopener noreferrer"&gt;Adding Playwright Agents: Lessons from the Deep Trenches&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/benweese/playwright-ai-qa-agents" rel="noopener noreferrer"&gt;playwright-ai-qa-agents&lt;/a&gt; (the public version of the plugin)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/benweese/playwright-test-commons" rel="noopener noreferrer"&gt;playwright-test-commons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/benweese/playwright-e2e-demo" rel="noopener noreferrer"&gt;playwright-e2e-demo&lt;/a&gt; (a real suite written with the agents)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://playwright.dev/docs/test-agents" rel="noopener noreferrer"&gt;Playwright Test Agents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.anthropic.com/en/docs/claude-code/plugins" rel="noopener noreferrer"&gt;Claude Code Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@habib23me/10-tip-to-stop-burning-your-tokens-in-claude-code-4776d4ac8956" rel="noopener noreferrer"&gt;10 Tips to Stop Burning Your Tokens in Claude Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ai</category>
      <category>claudecode</category>
    </item>
    <item>
      <title>Adding Playwright Agents: Lessons from the Deep Trenches</title>
      <dc:creator>Ben Weese</dc:creator>
      <pubDate>Mon, 11 May 2026 16:26:35 +0000</pubDate>
      <link>https://dev.to/ben_weese/building-playwright-agents-lessons-from-the-deep-trenches-3mk7</link>
      <guid>https://dev.to/ben_weese/building-playwright-agents-lessons-from-the-deep-trenches-3mk7</guid>
      <description>&lt;p&gt;I have spent the last few weeks adding AI agents to my Playwright framework. Specifically Playwright's planner, generator, and healer, running locally through Claude Code. The Playwright agents explore the UI of our payment platform and write tests that match the framework I've been building for three years. This post is a brain dump on what worked, what didn't, the token costs, and what I'm changing next. I am writing it mostly so I don't forget. If anyone else is heading down this road, hopefully it saves you a step.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;p&gt;The three agents are Playwright's own. See &lt;a href="https://playwright.dev/docs/test-agents" rel="noopener noreferrer"&gt;playwright.dev/docs/test-agents&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Planner.&lt;/strong&gt; Explores the UI, documents components and locators, produces a test plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Generator.&lt;/strong&gt; Takes the plan and writes the actual Playwright tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Healer.&lt;/strong&gt; Runs the generated tests, identifies failures, fixes them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6uic8qzu9ssvb5ejclp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6uic8qzu9ssvb5ejclp7.png" alt="Playwright Agents outputs" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting With MCP, And Abandoning It Fast
&lt;/h2&gt;

&lt;p&gt;My first approach was MCP. Claude Code told me Playwright agents only worked through MCP and that &lt;code&gt;playwright-cli&lt;/code&gt; did not support agents. But I watched &lt;a href="https://youtu.be/Be0ceKN81S8" rel="noopener noreferrer"&gt;Playwright's own YouTube video on MCP vs CLI&lt;/a&gt; and the Lie Detector Determined That Was a Lie.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh14me5rhbfcg1wnzx808.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh14me5rhbfcg1wnzx808.jpg" alt="Maury that was a lie" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Playwright agents support &lt;code&gt;playwright-cli&lt;/code&gt; directly. The video specifically called out that the CLI is built for agents and is dramatically less token hungry than MCP. The benchmark Playwright showed on screen was 114k tokens versus 27k tokens for the same task. That works out to roughly 57% versus 13.5% of Claude's 5 hour window, which lines up with what I saw in my own runs.&lt;/p&gt;

&lt;p&gt;If you are running agents against a Playwright framework and you have not looked at &lt;code&gt;playwright-cli&lt;/code&gt; yet, go read &lt;a href="https://dev.to/anirseven/playwrightcli-is-not-npx-playwright-test-and-that-difference-is-costing-your-ai-agent-277f"&gt;this article by Anirban&lt;/a&gt; first. The short version. &lt;code&gt;playwright-cli snapshot&lt;/code&gt; gives the agent a compact structured view of the live page for around 150 tokens, instead of the agent reading source files and guessing what the DOM looks like.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Set the Project Up
&lt;/h2&gt;

&lt;p&gt;Before running anything, I had Claude learn the codebase. After it had context, I had it generate a &lt;code&gt;CLAUDE.md&lt;/code&gt; file documenting the framework. It did a good job. Then I had it rewrite the Playwright-provided agent definitions to use &lt;code&gt;CLAUDE.md&lt;/code&gt; as context. That single change improved both the planner and generator output a lot.&lt;/p&gt;

&lt;p&gt;I also generated an &lt;code&gt;AI.md&lt;/code&gt; to document the toolchain itself. How the agents are invoked, the slash commands, the file layout, the auth flow. About 5 corrections needed but otherwise solid as a reference doc for the team.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;playwright-cli --skills&lt;/code&gt; command was run after install as part of Playwright's documented setup. The agents had local command docs from the start because of that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the Pipeline, And What It Cost
&lt;/h2&gt;

&lt;p&gt;Here is what running all three agents actually cost on basic Claude Code, not enterprise:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Agent&lt;/th&gt;
&lt;th&gt;Token Usage&lt;/th&gt;
&lt;th&gt;Tokens&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Planner&lt;/td&gt;
&lt;td&gt;78%&lt;/td&gt;
&lt;td&gt;156k&lt;/td&gt;
&lt;td&gt;Burned most of the 5-hour window solo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Generator&lt;/td&gt;
&lt;td&gt;39%&lt;/td&gt;
&lt;td&gt;78k&lt;/td&gt;
&lt;td&gt;Run in the next window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Healer&lt;/td&gt;
&lt;td&gt;46%&lt;/td&gt;
&lt;td&gt;93k&lt;/td&gt;
&lt;td&gt;Longest wall-clock time, less tokens than expected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Generator + Healer combined&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;85%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;170k&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Near the window limit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frle30ppzpl6htc8et4f0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frle30ppzpl6htc8et4f0.png" alt="Token Cost Anaysis" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using basic Claude Code, not the enterprise tier, I ran through 78% of my 5-hour usage on the planner alone. That meant waiting for the window to reset before running the generator and healer. What should have been one run turned into a full day.&lt;/p&gt;

&lt;p&gt;The healer surprised me. It ran for over an hour but used less tokens than the planner. Makes sense in hindsight. The planner is doing complex analysis. Exploring the UI, documenting components, generating scenarios. The healer is doing tedious repetitive work. Run test, read failure, fix locator, repeat. Repetitive is cheaper than complex.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Results
&lt;/h2&gt;

&lt;p&gt;The generator produced 47 tests. 18 of them failed when I ran them. 29 passed.&lt;/p&gt;

&lt;p&gt;Then I ran the healer.&lt;/p&gt;

&lt;p&gt;After the healer finished, 45 tests were green. 2 of the 47 had been flagged as bugs along the way.&lt;/p&gt;

&lt;p&gt;The 2 flagged bugs were not real. The agents flagged validation that only triggers after clicking the Apply button, not before. That is a design decision in our framework, not a defect. The agents did not have context on that. Something to address in the planner prompt going forward.&lt;/p&gt;

&lt;p&gt;So 47 passing tests, 0 real bugs missed. Looks great on paper.&lt;/p&gt;

&lt;p&gt;Then I reviewed the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes on the Planner
&lt;/h2&gt;

&lt;p&gt;The planner is based on Playwright's official planner. Modified to understand my codebase through &lt;code&gt;CLAUDE.md&lt;/code&gt;. It does two things in one pass.&lt;/p&gt;

&lt;p&gt;First, it analyzes the page. What is on the page, how the elements work, what options each element has, file references, and locators. On this run it produced a 936-line markdown file. Thorough.&lt;/p&gt;

&lt;p&gt;Second, it generates test scenarios from that analysis.&lt;/p&gt;

&lt;p&gt;A few problems came up.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some of the locators it captured were too generic and needed the healer to clean up later&lt;/li&gt;
&lt;li&gt;The agents needed to run through the project's &lt;code&gt;uiSetup&lt;/code&gt; to ensure they were logged in. Once I told the agent about &lt;code&gt;uiSetup&lt;/code&gt;, it added the handling automatically, including login refresh logic for long runs&lt;/li&gt;
&lt;li&gt;A handful of the generator's assumptions were understandable but wrong, which I will get to below&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bigger architectural thought. The two things the planner does do not need to happen in the same agent run. The page analysis and the test scenarios are different artifacts with different lifespans. The page analysis is reusable, since the page does not change every day, and a cached version could feed future scenario generation at a fraction of the tokens. The test scenarios are throwaway after the tests exist. However this is just a theory of mine and has yet to be verified.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes on the Generator
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;CLAUDE.md&lt;/code&gt; context carried over to the generator and it understood the framework. &lt;code&gt;playwright-cli --skills&lt;/code&gt; ships with a built-in test generation skill that helped here.&lt;/p&gt;

&lt;p&gt;The generator wrote tests, page objects, locator files, and data fixtures following the framework's conventions. The first impression was strong.&lt;/p&gt;

&lt;p&gt;One real problem. The generator always creates a new spec file. It knew which files to reference when building tests, but it never checked whether a similar test already existed or whether it should insert into an existing spec. Every run produces a new file. That is going to create duplicates fast. This needs to be fixed before the agents run in any kind of automated way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes on the Healer
&lt;/h2&gt;

&lt;p&gt;Watching the healer work was satisfying. It runs the test, sees the failure, opens a &lt;code&gt;playwright-cli&lt;/code&gt; session, inspects the UI, and repairs the broken locator. Then runs again. Most of what it fixed was locators from the generator that probably did match the DOM but were flaky or not unique enough.&lt;/p&gt;

&lt;p&gt;Two things I am changing about how the healer runs.&lt;/p&gt;

&lt;p&gt;First, scope. Right now the healer can end up running the full suite to triage one failing test. The article by Anirban covers exactly this. Use &lt;code&gt;--grep&lt;/code&gt; to scope test runs to the specific failure, and use &lt;code&gt;--reporter=json&lt;/code&gt; so the agent parses structured output instead of pattern-matching terminal text. Same fix, way cheaper.&lt;/p&gt;

&lt;p&gt;Second, guardrails. I read a story recently, and I cannot find the source, where someone's AI healer "fixed" a failing test by injecting JavaScript into the UI to make the bug disappear. Not by fixing the test. Not by flagging the bug. By hiding it. The test passed. The bug was still there.&lt;/p&gt;

&lt;p&gt;I have not seen my healer do this. But "the AI healed the test" can mean a lot of different things and I want to be very clear about what mine is and is not allowed to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes on the Generated Code
&lt;/h2&gt;

&lt;p&gt;The page I was testing auto-applies last-month date filters through the URL. The generator wrongly assumed it had to calculate the date range and append the parameters to the URL itself, instead of just navigating to the page and letting it do its thing. It did extra work to arrive at the same place, which is a very AI mistake to make.&lt;/p&gt;

&lt;p&gt;The locators are great after the heal. That part works.&lt;/p&gt;

&lt;p&gt;The data fixture has some useless code that needs refactoring. I am chalking that up to a product knowledge gap. As we build out more skills and markdown context, that should improve.&lt;/p&gt;

&lt;p&gt;Some of the future-date logic in the fixtures is static when it should be dynamic. In 4 years the code would not work. Then again, why would you be running this code 4 years from now? &lt;em&gt;coughs in COBOL&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then the big one.&lt;/p&gt;

&lt;p&gt;The tests are supposed to validate filters. The generated pattern is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set the filter in the UI&lt;/li&gt;
&lt;li&gt;The UI updates the URL to match the filter&lt;/li&gt;
&lt;li&gt;The test verifies the URL contains the filter&lt;/li&gt;
&lt;li&gt;The test verifies the table is present&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That is it.&lt;/p&gt;

&lt;p&gt;The test does not verify that the contents of the table actually match the filter. Some of the tests do not even validate what filter was set. There are no locators for the table the filter is supposed to be filtering.&lt;/p&gt;

&lt;p&gt;Concrete example. If I set the filter to &lt;code&gt;September 9, 1947&lt;/code&gt;*, the test only checks that the URL includes the date. It never checks that the table on the page is showing entries from that date. The test passes. The filter could be returning every record from the Cretaceous period and the test would still go green. We would have a wall of passing tests guarding nothing. That is worse than no tests at all, because at least with no tests you know what you do not have.&lt;/p&gt;

&lt;p&gt;*&lt;a href="https://www.computerhistory.org/tdih/september/9/" rel="noopener noreferrer"&gt;September 9, 1947&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So Whose Fault Is This?
&lt;/h2&gt;

&lt;p&gt;When I went back to the planner output, the planner never planned for the tests to check anything beyond the URL. The generator did exactly what the plan said.&lt;/p&gt;

&lt;p&gt;So is this a planning failure or a prompt failure on my end?&lt;/p&gt;

&lt;p&gt;It is on me. I expected the planner to be capable of more than what it was based on what I had heard from the community. The tests are lacking, and we will need to be more thorough with our prompts.&lt;/p&gt;

&lt;p&gt;That is the lesson for anyone else heading down this road. AI agents will do exactly what you ask. They will not infer what "good test coverage" means. "Test the filters" is not a complete prompt. "Test that the filter changes the URL AND that the table updates to match the filter criteria" is closer to the bar.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Am Changing Next
&lt;/h2&gt;

&lt;p&gt;Going forward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Split the planner workflow.&lt;/strong&gt; The planner creates two things, a page analysis and a set of test scenarios. Those can be split. The generator runs after the planner, against both files, and produces the &lt;code&gt;locators.js&lt;/code&gt; file. Once the generator is done, I can go back to the page analysis and insert a reference to the locator file. The test scenarios can be deleted once the tests are generated. The page analysis sticks around for reuse on future runs against the same page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Teach the generator about existing spec files.&lt;/strong&gt; No more always-create-new-spec behavior. It needs to check whether a relevant spec exists and insert into it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implement Anirban's &lt;code&gt;--grep&lt;/code&gt; and &lt;code&gt;--reporter=json&lt;/code&gt; patterns for the healer.&lt;/strong&gt; Scope every healer run. No more full-suite triage for one failing test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write better prompts.&lt;/strong&gt; Specifically for the planner. The "table contents must match the filter" problem is not solvable by the agent figuring it out. It has to be told.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real Bottleneck
&lt;/h2&gt;

&lt;p&gt;I keep reading articles and Reddit threads making the same point and I think they are right. AI moves the bottleneck, it does not remove it. Code generation is faster. Code review is the same speed it always was. Maybe slower, because now you are reviewing code you did not write and do not have the same mental model of.&lt;/p&gt;

&lt;p&gt;With this run of the agents, 47 generated tests need to be reviewed. The 936-line page analysis needs to be reviewed. The healer's locator fixes need to be reviewed. The agent definitions need to be reviewed. The auto-generated &lt;code&gt;CLAUDE.md&lt;/code&gt; needs to be reviewed. None of it can be skipped, especially in a payment platform where a test that passes when it should not is actively dangerous.&lt;/p&gt;

&lt;p&gt;The time I saved generating tests, I am spending reviewing them. That is the price of delegating to AI.&lt;/p&gt;

&lt;p&gt;I have worked using AI for over a year and I have yet to see real time-saving benefits. Before skills, it was arguing with AI on best code practices and correcting it. Now it is reviewing code and writing better markdown files for it. AI is like my 7 year old daughter. Highly intelligent but inexperienced and needs its hand held.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://playwright.dev/docs/test-agents" rel="noopener noreferrer"&gt;Playwright Test Agents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/Be0ceKN81S8" rel="noopener noreferrer"&gt;Playwright Test Agents on YouTube&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/anirseven/playwrightcli-is-not-npx-playwright-test-and-that-difference-is-costing-your-ai-agent-277f"&gt;The article by Anirban on dev.to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.anthropic.com/en/docs/claude-code" rel="noopener noreferrer"&gt;Claude Code Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>playwright</category>
      <category>qa</category>
      <category>automation</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
