Give your coding agent a test loop on real phones
How to let Claude Code, Cursor, Codex or Copilot test its own changes on real phones and browsers, read what broke, fix it and prove the fix, before it says it's done.
A coding agent writes a change, runs the unit tests, and says it's done. Then the page is broken on an iPhone, because nothing it ran ever opened the page on one. "Done" from an agent means "it compiles and its own tests pass". To mean "it works for people", the agent needs to see the result where people see it: in real browsers, on real phones.
The loop
- Change. The agent makes its change.
- Test. It starts a test of the running site (a preview, or localhost) on real devices.
- Read. It reads what failed: which device, which step, the exact error, the console, a screenshot.
- Fix. It changes the code for that cause.
- Prove. It tests again on the devices that failed, and only then says it's done.
The important part is the last step. An agent that says "I've fixed it" without running it again on the device that failed is guessing.
What the agent needs
- A way to start a test from its own session. Most coding agents speak MCP (the Model Context Protocol), the standard way to give an agent tools. One connection gives it tools to test a page, wait for the result and read it.
- Results written for it to act on: the failing step, the error text, whose problem it is (the site's, or the test setup's), and what to try. Not a dashboard link it can't open.
- A clear line between a broken site and a broken test. If a phone was locked or lost its network, the agent must not "fix" working code. A good result says so plainly.
Tell it when to test
Agents follow what's written in their instructions file (CLAUDE.md, AGENTS.md, .cursor/rules or .github/copilot-instructions.md). A few lines are enough:
Before you say a change to the site is done:
1. Test the running site on real devices.
2. If anything fails, fix the cause and test again on the devices that failed.
3. Every change people can see adds or updates a flow that checks it.
4. If a result says the test setup failed (not the site), don't change code: tell me what to do.
Flows: tests the agent can write
A flow is a short list of steps in plain words that a test follows, like a person would:
flow Sign up
open /
tap "Start free"
type css=#email "test+signup@example.com"
tap "Continue"
see "Check your email"
Agents write these well, because they read like the feature. Ask for a flow with every feature, and the tests grow with the product instead of going stale (see what to test at each stage of CI/CD).
Keep a person in the loop for what matters
- Let the agent test and fix freely on previews and localhost.
- Read the flow it wrote: it's the agent's own description of what the feature does, and the fastest review you'll do.
- A failure on production goes to a person first.
With PocketQA
Connect PocketQA to your agent once (how, for each agent). It can then test a preview or localhost on your own phones and browsers with test_url, wait for the result, read each failure with its error and whose problem it is, and test again after a fix with rerun_failed. A result that the lab caused, not your site, says so, and tells the agent not to change code for it.