When you ask Claude Code or Cursor to write an API integration, the model builds it from patterns it soaked up during training. If the SDK has moved on since then, with new method names, deprecated parameters, or a restructured response, the model has no idea. So it writes code that looks completely correct and quietly falls apart at runtime.
The natural instinct is to ask the same model to write tests. And that's the trap. Now you've got a closed loop: the model that hallucinated the implementation goes on to hallucinate tests that bless the hallucination. The tests pass. The code ships. Production breaks. Everybody's confused.
The core problem
LLMs are probabilistic. They emit the most likely next token given the context, and "most likely" is not the same thing as "correct." When a model writes resend.emails.send() instead of resend.emails.send({}) with its required fields, it isn't really making a mistake in its own terms. It's producing a statistically plausible output based on what it saw during training.
Tests written by that same model inherit the exact same priors. They'll happily assert that the hallucinated API shape is right, because as far as the model is concerned, it is.
What determinism buys you
api-doctor breaks the loop by being a fundamentally different kind of tool. There's no model inside it. It's hardcoded AST rules pulled straight from provider documentation. The rules don't hallucinate, they don't carry priors, and they give you the same answer for the same input every time.
So when api-doctor flags resend.emails.send() for missing the required from field, it isn't guessing. It's checking your code against a rule written from the Resend docs.
How to use it
Run it before you commit:
npx @api-doctor/cli .
Or install it as an agent skill so your coding agent runs it on its own and fixes the findings before they ever reach you:
npx @api-doctor/cli install
The end state is a nice one. The AI writes the code, api-doctor catches what the AI got wrong, and the AI fixes it. No human babysitting the loop, no production failures.