Blog · Guides · 2026-11-02

Claude Code Testing: How to QA What the Agent Ships

TL;DRClaude Code testing means verifying behaviour across the whole repo, not just confirming the code compiled. An agent can reliably prove its code type-checks, lints and passes the tests it chose to run — it cannot prove the requirement was understood, the UI is usable, or nothing else regressed, because it checks its own work through a terminal rather than a browser.

Claude Code testing means verifying the behaviour of code an agent wrote across your whole repository — not just confirming it compiled. Because Claude Code works agentically, it can edit a dozen files in one pass and run your test suite itself, so a green terminal tells you the commands the agent chose to run passed. It does not tell you the feature works. The gap to close is behavioural: does the finished flow work in a real browser, for a real user, on the paths nobody wrote a test for?

That gap is where the bugs your client finds live. This guide covers what an agent can verify about its own output, what it structurally cannot, and how to build a testing loop around the difference.

What does Claude Code testing actually have to cover?

Agent-written code fails differently from hand-written code, so the testing surface is shaped differently too. Three properties of agentic coding drive everything else:

  • The blast radius is wider than the diff you read. A single instruction like "add tenant scoping to the reports endpoint" can touch a route, a query builder, a migration, a type definition and two call sites. Reviewing the agent's summary is not reviewing the change. The diff is the change.
  • The same model wrote the code and the tests. If the agent misunderstood the requirement, it will usually encode that same misunderstanding in the test it writes to prove the code works — and the test will pass. Tests authored alongside an implementation are a regression net, not an independent check of intent.
  • Verification happens through a terminal, not a viewport. By default an agent confirms work by exit codes, log output and test results. It is not looking at the rendered page. Layout breakage, a button that is visually present but not clickable, a modal that traps focus, a form that silently drops a field — none of these produce a non-zero exit code.

So a useful Claude Code testing strategy is not "write more unit tests." It is: let the agent own the checks it can run deterministically, and put an independent behavioural layer on top of everything it can't see.

Why isn't a green test run enough?

There are two separate reasons, and they compound.

The first is scope. An agent runs the tests it believes are relevant. If it added a feature and ran that feature's spec file, the suite it ran is green and the suite it skipped is unknown. Always re-run the full suite yourself, in CI, on the pushed branch — not in the agent's working session.

The second is environment drift. The agent's sandbox has its own installed dependencies, its own environment variables, and whatever state previous steps left behind. Code that passes locally can fail in CI on a missing env var, an unpinned dependency, or a lockfile the agent regenerated. Treat the agent's green run as a signal to open a pull request, not as permission to merge.

There is also a subtler issue specific to non-deterministic authors: run the same prompt twice and you get two different implementations. That means your regression suite should pin observable behaviour — status codes, rendered text, redirect targets, persisted rows — rather than internal function names or call structure, or it will break every time the agent refactors.

What can the agent verify itself, and what can't it?

This split is the most practical thing to internalise. Push work leftward where you can; cover the right-hand column with something else.

CheckAgent can verify itselfNeeds an independent layer
Compiles / type-checksYes — reliably—
Linting and formattingYes — reliably—
Unit tests passYes, for tests it runsFull-suite run in CI
Requirement was understood correctlyNo — same author biasHuman review or independent test
UI renders and is usableNo — no viewportBrowser-level testing
Real user journeys end to endPartially, if E2E tests existPersona / journey testing
Auth and tenant boundaries holdNo — it tests the happy pathAdversarial, multi-account testing
Nothing else regressedNoFull regression run

What should a Claude Code testing loop look like?

A loop that works in practice, in order:

  1. Make the agent's checks mandatory, not optional. Put type-check, lint and the unit suite in a single command the agent is instructed to run before declaring done. If it is one command, it gets run; if it is four, it gets partly run.
  2. Read the whole diff before anything else. Specifically look for files you did not expect to be touched — those are where unrequested changes hide. See how to review AI-generated code for what to prioritise when the diff is large.
  3. Re-run everything in CI on the branch. Clean environment, full suite, no agent session state.
  4. Exercise the feature in a browser. Not a glance at the happy path — the empty state, the error state, a second user account, a slow network, a mobile width.
  5. Capture anything broken with full context the first time. A screenshot with no console log, network trail or DOM state becomes a "cannot reproduce" ticket and a second round trip.
  6. Turn each confirmed bug into a regression test that asserts behaviour, so the next agent pass cannot silently reintroduce it.

How does this compare to testing other AI coding tools?

The principles carry across, but the emphasis shifts. With in-editor assistants the unit of change is a file or a function, so review is tractable and the main risk is subtle logic error — that is the world of Cursor IDE testing. With prompt-to-app builders, you often cannot meaningfully review the code at all, so verification is almost entirely behavioural.

Claude Code sits in between and inherits the hard parts of both: the changes are large and multi-file like a builder's, but you do have a real repository, real CI and a real diff to work with. That combination is good news — it means you can automate most of the verification instead of clicking through it by hand.

What tools fit a Claude Code testing workflow?

Three jobs need covering, and they map onto Klavity's pieces:

  • Catching what you see. Snap turns a right-click into a bug report carrying the console log, network requests, DOM state and environment — so the report lands reproducible instead of becoming a thread.
  • Catching what you didn't think to try. Sims runs AI personas through your app the way different real users would, which is how you find the broken path that no spec described and no test covered.
  • Keeping it caught. AutoSim maintains self-healing end-to-end tests, which matters specifically here: when an agent refactors the markup, brittle selector-based suites break and get deleted. A suite that repairs itself survives agentic churn.

For the wider picture of where automated checks fit against human review, start with the complete guide to AI QA.

The short version

Claude Code will reliably tell you that your code compiles, lints and passes the tests it ran. It cannot tell you that the feature does what you meant, that the UI works, or that nothing else broke — because it is checking its own homework through a terminal. Keep the deterministic checks with the agent, keep behavioural verification independent of it, and ship at agent speed without finding out from your client.

Try Klavity free — point it at your next agent-built feature and see what the terminal missed.

Key takeaways

  • Read the full diff, not the agent's summary — unexpected files are where unrequested changes hide.
  • Re-run the complete suite in CI on the branch, never trust the agent's session environment.
  • Cover the viewport yourself: empty states, error states, a second account, mobile width.
  • Turn every confirmed bug into a behaviour-level regression test, not a selector-level one.

FAQ

Does Claude Code test its own code?

It runs the checks it decides are relevant — type-checks, linting and usually the test file for the feature it just touched. That is genuine verification, but it is scoped to what the agent chose to run and executed inside its own session environment. Re-run the full suite in CI on the pushed branch before you treat it as verified.

Why can't I rely on tests the agent wrote itself?

Because the same model wrote the implementation and the test. If it misread the requirement, that misreading is usually encoded in both, and the test passes. Agent-written tests are a good regression net for future changes; they are not an independent check that the current change does what you meant.

What does Claude Code testing miss most often?

Anything that only shows up in a viewport. An agent verifies by exit codes and log output, so broken layout, an element that renders but isn't clickable, a focus trap, or a form field that silently drops data all produce a passing run. Browser-level and journey-level testing is the layer that catches those.

How do I stop agent refactors from breaking my E2E tests?

Assert observable behaviour — rendered text, status codes, redirect targets, persisted data — rather than internal structure or brittle CSS selectors. Re-running the same prompt produces different implementations, so tests tied to implementation detail break on every pass. Self-healing suites like AutoSim are built for exactly this churn.

Catch bugs the moment a human sees them

Klavity: right-click bug reports, AI personas that review your product, and self-healing tests.

Get started free