Cursor keeps inventing .NET methods that don't exist. Here's the seven-word fix.

You ask Cursor to use DbContext.RunQueryAsync() — which does not exist. You correct it. Cursor apologises and suggests DbContext.ExecuteQueryAsync(). Also does not exist. Twenty minutes later you have a function that pattern-matches what EF Core "should" look like and does not compile. This is a hallucination loop. The fix is a single circuit-breaker rule that forces the AI to ground itself in real code before suggesting another invented method.

The short answer

Add a rule to .cursor/rules/ that contains the phrase "if unsure, search the codebase first". When the AI's next suggestion contains a method or property name it cannot point to in your code, the rule fires and the AI must either run the search and ground itself, or admit it does not know. Pair this with a rule that forbids invented namespaces and you cut the loop length from twenty minutes to twenty seconds.

What's actually happening in a hallucination loop

An LLM is a next-token predictor. When you ask for an EF Core query, it produces tokens that statistically look like EF Core methods — based on every snippet of EF Core it has ever seen. Most of those tokens are real method names. Some, on the edges, are confident-looking inventions. The model has no internal flag for "real" vs "plausible". To it, both feel the same.

When you correct an invented method, the model does not learn from the correction in any structural way. It samples another plausible next token, which is often another invented method with a slightly different name. That is the loop. The longer you stay in it, the further from your real codebase you drift, because each turn is grounded in the previous wrong suggestion, not in your actual repository.

The circuit-breaker pattern

The fix is to give the AI a forced grounding step. A bug-breaker.mdc rule that says, in plain language:

  • "Before suggesting any method or property on an external library, confirm it exists. If you cannot, say so."
  • "If a suggestion is corrected, do not propose a similar variant. Stop, search the codebase, then propose."
  • "Never invent namespaces or types. If you are guessing, ask."

The rule is short. It loads on every prompt because hallucination is universal — but it adds maybe 60 tokens. The cost is negligible compared to a single half-hour debugging session.

The fix in 60 seconds

Commit a single bug-breaker.mdc rule file with the three bullets above and the next time Cursor hallucinates an EF Core method, the next suggestion will be either a real method or "I'm not certain — could you point me to the repository's data-access helpers?" — which is what a junior engineer would say, and is the exact behaviour that ends the loop.

Want the full picture?

The long-form essay shows the seven exact words that work in the rule, the failure modes of cheaper attempts, and the framing that makes engineers stop blaming the AI for what is, structurally, a rule-writing problem.

→ Read: Seven words that stop Cursor hallucination loops


Try the boundary rule for free

The arch-core-lite.mdc rule is the boundary-guardian preview from the kit — a single drop-in rule that catches the cross-layer hallucinations Cursor ships most often. No signup, no email.

Download arch-core-lite.mdc →

Or get the full circuit-breaker (and the other three rules).

The complete kit — including the full bug-breaker.mdc hallucination circuit-breaker — is £19.99 one-time. Lifetime updates. MIT-licensed. 14-day refund.

Get Agentic Architect — £19.99 →