# "Cursor Browser control Self improving coding agent" <!-- ref: @content/youtube/ai-jason/2025-05-07-cursor-browser-control-self-improving-coding-agent triggers: [UI feels off, need for regression tests, agentic exploration, automated test generation] trigger_prompt: When the coding agent needs to validate its UI output or generate reusable tests after successful exploratory runs. version: 4 updated_at: 2026-10-31T18:27:51.254Z --> From AI Jason, 2025-05-07: Playwright MCP collapses the gap between "AI writes code" and "AI verifies code" — instead of humans authoring brittle selectors and test scripts, the Cursor agent becomes the QA tester, screenshotting and iterating on the live app until it matches intent. AI Jason walks through wiring Playwright MCP into Cursor so the coding agent can drive a real browser, critique its own UI, and generate durable regression tests from its exploratory runs. ## Core Thesis Playwright MCP collapses the gap between "AI writes code" and "AI verifies code" — instead of humans authoring brittle selectors and test scripts, the Cursor agent becomes the QA tester, screenshotting and iterating on the live app until it matches intent. Once a flow works, the same agent codifies it into a deterministic Playwright test plus a GitHub Action, yielding a two-phase system: agentic exploration for novel flows, cheap scripted regression for every push. ## Key Insights - **The "last 20-30%" problem is a verification problem.** AI-coded UIs usually look almost right but feel off; giving the agent eyes on its own output via screenshot → critique → iterate closes that gap without human pixel-pushing. - **Split vision and non-vision MCP servers.** Vision models are great at *seeing* UI state but poor at *targeting* elements for clicks. Run two configs — `playwright` with `--vision` for UI polish, `playwright-test` without vision for deterministic interaction — and toggle per task. - **Cursor rules steer MCP failure modes.** Recurring issues (viewport size, tab-index starting at 1 vs 0) are fixable by embedding rules rather than re-prompting each run. - **Agentic runs are expensive; generated tests are cheap.** Every live MCP run burns tokens. The payoff is prompting the agent to convert a successful run into a reusable Playwright script, so regression cost drops to near zero. - **"Continue" is a self-healing primitive.** When generated tests fail, a single "continue" prompt lets the agent read the error, patch the test, and re-run — no manual debugging loop. - **Version pin matters.** Latest Playwright MCP is unstable; pin to `0.0.2`. ## Actionable Takeaways 1. Install two MCP servers in Cursor: `npx @playwright/[email protected] --config <vision-config>` and a second without vision, toggling one at a time. 2. For UI polish work, prompt: *"Use Playwright MCP to view the UI, identify areas to improve, and iterate until it looks perfect."* 3. Store reusable natural-language tests as prompt files in `/tests` so the agent can replay them on demand. 4. After a successful agentic run, prompt: *"Create a reusable Playwright UI test based on the flow above so I can run as automated test every time."* 5. Have the agent scaffold a GitHub Action gating merges on test passage — regression is enforced by the merge pipeline, not by memory. 6. Add Cursor rules for known MCP quirks (force viewport to 700px, remind the agent tab index starts at 1). 7. Use `"continue"` as a cheap iteration prompt when tests fail, rather than re-authoring the request. ## Notable Quotes > "Instead of you defining very static test yourself, you can get cursor to use Playwright to run the browser and become your QA tester." > "It's that 20 or 30% missing that makes the UI just not as sleek." > "Vision model is particularly good at view what's going on the page and iterate the UI, but it is less good at allocated specific position to click." > "Now let's create a reusable Playwright UI test based on the flow above so I can run as automated test every time." > "Only after those tests are passed then you will be able to push to production, which will make the whole process fairly automated." --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*