AI Code Testing: Test Code Claude Code Wrote
AI code testing for Claude Code output: run a recorded API flow after every change and read the failing step. The same loop works for Cursor and Codex.

To test code Claude Code wrote, run an API flow against the running app after every change, and read the failing step before the agent edits anything. The unit tests an agent writes can move with its code. In our measured run, 2,189 agent-written unit tests missed a broken login that one API flow caught. A recorded flow checks the app from outside, the way a client uses it. Stresseur stores those flows as files in your repo, and the same loop works for Cursor and Codex output.
What agent-written code breaks that unit tests miss
A unit test asks whether a function does what the agent meant it to do. It does not ask whether a client can still use the app. The gap opens when the agent changes a contract and updates the tests in the same commit. The guide to giving agents API tests covers the setup, and this post covers what to run and why.
We ran the comparison on a small shop app. A coding agent wrote the unit suite, 2,189 tests in all, and every test passed. We then made eight ordinary commits that break the app. The unit tests failed on 5 of the 8, and one API flow test, recorded while using the app, failed on 6. Each side caught bugs the other missed, and one bug got past both.
The clearest miss was a rename. One commit changed token to accessToken in the login response and updated the unit tests that read it. All 2,189 tests passed, and the web app still read token, so nobody could log in. The flow reads the token from the login response like any client does, so its next request went out without one and got a 401.
A smaller case is the same story: one commit changed a status code and the tests that check it. In both, the commit changed the code and the tests together, so the tests agreed with the code even though the app no longer agreed with its clients.
Unit tests still earn their place. The unit suite caught a bug the flow could not see, and a unit failure points at the line. One more bug got past both: the flow checks status codes and a few fields, and the renamed field was not one of them. Treat the flow as a second check beside the unit tests, which is the same idea Agentic Testing for APIs covers for agents in general. The unit test vs integration test comparison covers what each layer catches. These results come from one app, so read them as a pattern and not as a rate.
Run a recorded flow after every agent change
Install the CLI and the recorder in your app’s project, then write the instructions for your coding agent.
npm install -D stresseur stresseur-recorder
npx stresseur install-skill
install-skill writes .claude/skills/stresseur/SKILL.md, a section in AGENTS.md and .cursor/rules/stresseur.mdc. Record a session while you use the app, starting with the journey that matters most, such as login or checkout, and generate flows from it.
npx stresseur record
npx stresseur generate
The flows land in the repo under api-tests/ as *.yamlflow.yaml files. The agent can open one and edit it like any other file, and you can review the change in a diff. If you would rather start with one command, npx stresseur init has a --json option for tools and coding agents. The page for coding agents shows the same setup.
After each change to a route, a handler or a migration, tell the agent to run the flows that touch it. Use your own file and flow name:
npx stresseur flow run api-tests/checkout.yamlflow.yaml checkout
Flows read the app’s URL from APP_URL, so point it at the instance the agent just changed. Before the push, run npx stresseur ci. It runs each flow 13 times (1 warm-up, 12 measured), prints per-step timings and exits 1 if any step failed.
Then let the pull request run the same flows. npx stresseur init-ci writes the GitHub Actions workflow. Stresseur posts one check, “Stresseur / performance”, and one comment per pull request, updated in place on each push. The post on API smoke tests on every pull request walks through that setup.
What the agent sees when a flow fails
A check only helps if the agent can act on its failure. On one shop journey, ten runs of the browser test took 11.2 s in total, and ten runs of the API flow took 2.2 s. The failure messages differed as well. The flow’s failure named the step and the server’s answer, and the UI test’s failure said element(s) not found.
In a second run on the same app, the same coding agent, with the same model and prompt, fixed each broken test 3 times from a fresh copy. The median time to green was 21 s for the flow and 61 s for the UI test. That is one app, not a general benchmark, and it says nothing about a larger codebase.
The agent also gets exit codes to branch on. flow run exits 0 when done, 99 when a threshold failed, 108 when aborted and 1 when it could not run. The flow does not replace the browser test. In our run the browser test was still the only check that would catch a broken Edit button.
Keep the agent from weakening the test
An agent told to make the tests pass can make them pass by making them weak. Put one rule in the prompt: fix the code, not the assertion, unless the requirement itself changed, and say so when it did. Read any diff under api-tests/ the way you read a change to a production file, because a loosened check changes what you test.
Generated flows give the agent less room to do that. They send fresh sign-up values each run and check each answer along with the status.
Know what Stresseur does not do for the agent yet. Writing missing flows from the AI test engineer is not available. Draft fix pull requests from it are built, behind a flag, and not on for customers. Code changes stay with you and the agent you chose to run. If you write the failing flow before the change, the loop becomes TDD with Claude Code.
Cursor and Codex output: the same loop
Nothing in the loop depends on the editor. In Cursor, install-skill writes the rule file .cursor/rules/stresseur.mdc, and the --agent flag takes claude, codex, cursor or all. The Cursor rules documentation says project rules live in .cursor/rules as .mdc files and are version-controlled. In Claude Code, the skills documentation says project skills load from .claude/skills/ in the directory where you start it and in every parent directory up to the repository root.
Codex is not a listed Stresseur integration. The listed coding-agent integrations are Claude Code and Cursor. The install command still writes a section in AGENTS.md, which describes itself as a simple, open format for guiding coding agents. Whether a given agent reads that file is a question for its own documentation. The commands are ordinary npx stresseur commands, so you can paste them into a Codex prompt and check the result the same way.
Where to start
Pick the one journey that matters most, record it, and generate the flow. Ask the agent to run it after every change and to read the failing step before it edits anything. Keep your unit tests, and add the flow as the check that the pieces still work together.
Frequently asked questions
Can I trust the unit tests Claude Code wrote?
Trust them for what they check, and add a second check from outside the code. In our run, 2,189 agent-written unit tests all passed after a commit that renamed the login token, and nobody could log in. One API flow caught it, because its next request went out without a token and got a 401.
Does the agent need a browser to run the flows?
No. An API test sends the same requests the UI would send, with no browser.
Does Stresseur work with Codex?
Codex is not a listed Stresseur integration. The listed coding-agent integrations are Claude Code and Cursor. The `--agent` flag of `install-skill` does accept `codex` as a value, and the commands are ordinary `npx stresseur` commands.
Does Stresseur write the failing test for me?
No. Writing missing flows from the AI test engineer is not available yet. Record the flow, then edit the flow file to describe the new behavior.
How do I run a flow from the command line?
Run `npx stresseur flow run` with the path to the flow file and the flow name. It exits `0` when done, `99` when a threshold failed, `108` when aborted and `1` when it could not run.