One practical Cursor + .NET pattern per day.
Field notes from building a stateful AI partner for production C#/.NET codebases. A new Daily Senior Rule lands here every morning at 09:17 UTC, with longer essays mixed in.
Subscribe via RSS-
Rule 12: IOptionsSnapshot Over Raw Config
Business code should never call IConfiguration directly. Strongly-typed IOptions or IOptionsSnapshot bindings only. The AI loves to "just grab the config value" — refuse it and force a settings class with validation attributes.
-
Rule 11: Rethrow, Don't throw ex
throw ex resets the stack trace. throw preserves it. Cursor gets this wrong about 40 percent of the time when generating catch blocks. Rewrite any naked throw ex to throw unless the exception has been explicitly wrapped.
-
Rule 10: AsNoTracking for Reads
Every read-only EF Core query should call AsNoTracking. Add a rule that recognises query methods returning DTOs (not entities) and inserts the call. Cursor never does this by default and your read perf degrades silently across releases.
-
Rule 9: Scoped Capture in Singleton
The single most expensive .NET runtime bug: a Singleton holding a Scoped service. Cursor cheerfully writes this without warning. Audit constructor parameters of any class registered as Singleton — if any are typically Scoped (DbContext, repositories, MediatR sender), flag it before merge.
-
Teach Cursor Result<T> instead of throwing
Stop the AI from undoing your Result/ErrorOr error model with throw and null on every new prompt.
Read post → -
Rule 8: CancellationToken Propagation
Every async method in your codebase should accept and forward a CancellationToken. Make it a rule that any new async signature without one is flagged. Stops the AI from quietly losing cancellation half-way down a call chain.
-
Seven words that stop Cursor hallucination loops
The correction spiral — and the circuit-breaker rule that ends it before you type the stop phrase.
Read post → -
Rule 2: Persistence Boundaries
Never let the AI write database logic in your Controllers. Enforce a strict boundary where all IQueryable access stays in the Infrastructure layer. This keeps your business logic "pure" and readable for the LLM.
-
The Scoped→Singleton DI bug your AI just suggested (and how to catch it)
The .NET lifetime bug that ships to production silently — and the one Cursor rule that catches it before merge.
Read post → -
The Context Tax: Why every Cursor session costs you 15 minutes
The hidden cost senior engineers pay every morning — and a four-rule architecture for eliminating it.
Read post →
Don't want to wait for the next post?
The full kit — 4 specialist rules + the persistence engine — is £19.99 one-time.
Get Agentic Architect →