Coding Agents: API Tests for Claude Code, Cursor

Coding agents change a lot of code fast. Give Claude Code, Cursor or Codex an API test it can run after every change, set up with one CLI.

Mustafa BayramogluMustafa BayramogluA line of light passing through a row of glowing gates

A coding agent needs a test it can run against the API after every change, and the test has to finish in seconds so the agent runs it every time. With Stresseur you record flows from real use of your app, generate YAML tests that live in your repo, and run them with npx stresseur flow run. npx stresseur install-skill writes the instructions for Claude Code and Cursor, and a section in AGENTS.md for other agents. The sections below cover why the API layer fits, the setup, each agent, and what the AI test engineer does and does not do.

Why a coding agent needs a test at the API

An agent can edit a route, a handler and a migration in one go. It then needs to know whether the checkout flow still works. If the only end-to-end check is a slow browser suite, it gets skipped. The agent has no reason to wait on a check that costs more than the edit did, and a check it skips protects nothing.

An API test avoids most of that cost. It sends the same requests the UI would send, with no browser. There is no page to wait for and no selector to find. That fits the failures an API change causes, such as a new required value on a request.

We measured the speed difference 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. That is one app, not a general benchmark, so read it as an illustration of the gap and not as a number to plan around. The method and the browser test’s own advantages are in the end-to-end testing guide.

An API test does not replace every other check. In our run the browser test was still the only one that would catch a broken Edit button. The unit test vs integration test comparison covers what each layer catches. The point here is narrower: the agent needs one check at the API that it can afford to run on every change.

What the test has to give the agent

Three properties decide whether an agent uses a test or routes around it.

It lives in the repo and is readable. Stresseur flows are files in your repository under api-tests/, named *.yamlflow.yaml. The agent can open one, read each step and edit it like any other file, and you can review the change in a diff.

It runs on your local app. The tests run at the API level against your local app, and they cover the flows your users take because they are generated from recorded, real usage. An agent that has to deploy before it can test will not test often.

It fails with a reason. A red check with no cause sends the agent guessing. A flow failure names the step and the server’s answer, while in our measured run the browser test’s failure said only that an element was not found. The measured example is below.

A test that is fast, readable and specific is also easier for you to trust when the agent says the change is done. The guide to keeping API tests current explains why tests that nobody maintains stop being trusted, which matters more once an agent is producing most of the changes. The AI code testing guide applies the same idea to code Claude Code has just written.

Set up the loop with one CLI

The setup is a few commands. Every command people copy is written npx stresseur <command>. Install the CLI and the recorder in your app’s project:

npm install -D stresseur stresseur-recorder

Install the instructions for your coding agent:

npx stresseur install-skill

This writes .claude/skills/stresseur/SKILL.md, a section in AGENTS.md, and .cursor/rules/stresseur.mdc. The --agent flag takes claude, codex, cursor or all, and the default is all.

Then record a session while you use your app, and generate tests from it:

npx stresseur record
npx stresseur generate

Flows land in api-tests/. Run one with:

npx stresseur flow run api-tests/checkout.yamlflow.yaml checkout

You can also start with npx stresseur init, whose --json option is for tools and coding agents. The skill itself runs npx stresseur init. The CLI reference lists every flag, and the page for coding agents shows the same setup with the recorder snippet.

Using it from Claude Code

A skill is a SKILL.md file with instructions, and Claude adds it to its toolkit. The Claude Code skills documentation adds that Claude Code loads project skills from .claude/skills/ in the directory where you start it and in every parent directory up to the repository root. After install-skill, the Stresseur skill sits in that folder with the rest of your repo.

The same page says Claude uses skills when relevant, or you can invoke one directly with /skill-name. Ask for the change, then ask the agent to run the flows when it is done.

What the skill tells the agent to do is specific. It runs npx stresseur init, fixes failing steps, adds expect: checks to AI endpoints, and offers a HAR file when the recorder can’t be used. A sensible first prompt is: “Add a SKU field to product creation, then run the Stresseur flows and fix any step that fails.” The agent has a command to run and a pass or fail result to act on.

Commit the skill file with the rest of the repo. A teammate who starts Claude Code in the same repository then gets the same instructions, and the agent does not depend on what one person typed into one session.

Using it from Cursor

According to the Cursor rules documentation, project rules live in .cursor/rules as .mdc files and are version-controlled. Rules provide system-level instructions to Agent.

install-skill writes .cursor/rules/stresseur.mdc, so the rule is in place after the same single command. If Cursor is the only agent your team uses, npx stresseur install-skill --agent cursor writes just that file.

The loop is the same as in Claude Code. Make the change, run the flows, read the failing step, fix it, run again. Nothing in the flows depends on the editor, because they are plain files in api-tests/ and plain npx stresseur commands. Write the failing flow before the change and the same loop becomes TDD with Claude Code.

Codex and other agents

Codex is not a listed Stresseur integration, and this post does not claim one. Stresseur’s listed coding-agent integrations are Claude Code and Cursor.

What the command does for other agents is write a section in AGENTS.md. AGENTS.md describes itself as a simple, open format for guiding coding agents. The install command also accepts codex as an --agent value. Whether a given agent reads that file is a question for that agent’s own documentation.

Nothing in the loop depends on the agent. The steps are ordinary npx stresseur commands: record, generate, run. If you use Codex, you can paste those commands into your prompt or your own instructions file. Check the results the same way you would for any other agent, by reading the failing step and the exit code.

Check that the generated flows test something

An agent that is told to make the tests pass can make them pass by making them weak. Review what generate wrote before the agent starts leaning on it, and keep the suite small enough that you can.

Stresseur’s generated flows already check more than a status code. They send fresh sign-up values each run and check each answer along with the status. After a create, a later read of the list or page must hold the new id, or a value the user typed, made unique per run. A create that cannot be read back afterwards fails the check.

Two habits keep the suite strict when an agent is editing it. First, read the diff of any change to a file under api-tests/ the way you would read a change to a production file, because a loosened check is a change in what you test. Second, prefer regenerating a flow from a fresh recording over hand-editing a step the agent finds inconvenient. If the agent wants to delete an assertion to get to green, that is the moment to look at the code it changed.

Point the flows at the right app

A flow that runs against the wrong server tells the agent nothing. Flows read the app’s URL from APP_URL, locally and as the CI repository variable. Give the agent the URL of the instance it just changed. A local dev server is the usual choice, because the change under test is running there.

For a one-off run against a specific server, set the variable in the shell, for example APP_URL=http://localhost:3000 npx stresseur flow run api-tests/checkout.yamlflow.yaml checkout. Variables set in the shell win. That lets the agent test a branch on a spare port without editing a file that is committed.

When the agent changes an AI endpoint

If your app calls a language model, a status code tells you little about that endpoint. Stresseur lets any request step carry expect: checks, such as a JSON schema or a maximum latency. The checks run after the flow’s steps, so they never count in timings.

When generate sees an AI endpoint, it prints a hint to add expect: checks, and the skill adds them after generating. npx stresseur ci then turns each check into a pass rate across the measured runs. After the agent edits a prompt or a model setting, the pass rate is the number to watch. The AI checks documentation has the full list of checks and when each one runs.

A short prompt for the agent

Put the rule where the agent will read it, and keep it short. A version that works with any of the agents above:

  1. After any change to a route, a handler or a migration, run the Stresseur flows that touch it with npx stresseur flow run.
  2. If a step fails, read the step name and the server’s answer before editing anything.
  3. Fix the code, not the assertion, unless the requirement itself changed. Say so when it did.
  4. Run npx stresseur ci before reporting the work as done.

The skill, rule and AGENTS.md section from install-skill already carry the workflow for recording and generating flows. The four lines above add the habit that matters most: run the flows after every change and read the failure before touching anything.

What the agent sees when a flow fails

A test only helps the loop if the failure is something the agent can act on. We tested this on one shop journey: log in, add a category, create a product, change its price. Then we made the API require a SKU on new products, which broke both tests. The same coding agent, with the same model and prompt, fixed each 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.

The flow’s failure named the step and the server’s answer. The UI test’s failure said element(s) not found. Both fixes were small. These numbers come from one app, not a general benchmark. They say nothing about Cursor or Codex, and nothing about a larger codebase.

The agent also gets exit codes it can branch on. flow run exits 0 when done, 99 when a threshold failed, 108 when aborted and 1 when it could not run. If a variable the flow uses is not set, it stops before the first step and names it, so the agent knows what to set.

To run every flow the way CI does, use npx stresseur ci. It runs each flow in api-tests/ 13 times (1 warm-up, 12 measured), prints per-step timings and exits 1 if any step failed. Use flow run for the quick loop after an edit and ci before you push.

On every pull request, and asking @stresseur

The agent’s local check is the first line. The second is the pull request. The same flows run in GitHub Actions on every pull request. Stresseur posts one check (“Stresseur / performance”) and one comment per pull request, and the check and comment say which flow got slower and which step took the time. The comparison of two slower pull requests shows what that looks like.

Stresseur also has an AI test engineer. Tag @stresseur in a pull request or issue comment, or ask from the app. Today it answers questions:

  • @stresseur why is this slower says which steps slowed, since when, by how much, and the likely cause in code.
  • “test this” runs the flows the pull request touches against its verified preview.

Every number in a reply links to the run it came from, and anything read from code is labelled inferred. The test engineer docs list the other commands.

Here is what it does not do. The AI test engineer does not fix code or write tests on its own. Fix pull requests and writing new flows are not available yet. It never merges, never approves and never pushes to the default branch. Code changes stay with people and with the coding agent you chose to run. The guide to API testing is the place to start if the vocabulary here is new. The Team plan includes 50 AI test engineer tasks a month.

Where this leaves your agent

Give the agent one check at the API that is fast, readable and specific about failures. Install it with one command, put the flows in the repo, and ask the agent to run them after each change. Let CI run the same flows on every pull request, and ask @stresseur when a check turns red and the cause is not obvious. Start with a single flow for the journey that matters most, such as checkout or login, and add more once the first one runs on every change.

Frequently asked questions

Does Stresseur work with Claude Code?

Yes. `npx stresseur install-skill` writes `.claude/skills/stresseur/SKILL.md`, and the skill runs `npx stresseur init`, fixes failing steps and adds `expect:` checks to AI endpoints.

Does Stresseur work with Cursor?

Yes. `npx stresseur install-skill` writes a Cursor rule to `.cursor/rules/stresseur.mdc`. Pass `--agent cursor` to write only that one.

Can Codex use Stresseur?

Codex is not a listed Stresseur integration. The install command lists `claude`, `codex` and `cursor` as `--agent` values and writes a section in `AGENTS.md`. The commands are ordinary `npx stresseur` commands.

Does the AI test engineer write or fix tests?

No. Fix pull requests and writing new flows are not available yet. It never merges, never approves and never pushes to the default branch.

How do I run a flow from the command line?

Run `npx stresseur flow run api-tests/checkout.yamlflow.yaml checkout`, with your own file and flow name. If a variable the flow uses is not set, it stops before the first step and names it.

Does the agent need a browser to run the tests?

No. An API flow test sends the same requests the UI would send, with no browser.

All posts