Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET AI coding rules (free subset)

Out of the box, AI coding assistants write C# that looks like it was written by someone who mostly writes JavaScript. They block on async with .Result, return EF Core entities straight from controllers, and generate N+1 queries without noticing. It happens because the training data is dominated by web/JS patterns, so the model regresses to that average unless you tell it otherwise.

This repo is a small, MIT-licensed set of rules and a prompt that push Cursor (and Claude Code / Copilot) toward idiomatic, senior-grade .NET. Everything here is free to use, copy, and modify. No signup, no expiry.

What's inside

cursor/rules/
  csharp-async-correctness.mdc   # no sync-over-async, cancellation, no async void
  ef-core-safe-queries.mdc       # no N+1, AsNoTracking, pagination, projection
prompts/
  optimize-slow-ef-query.md      # a task prompt to diagnose + fix a slow query
LICENSE                          # MIT
CONTRIBUTING.md
  • csharp-async-correctness.mdc — stops the assistant blocking on tasks (.Result / .Wait() / .GetAwaiter().GetResult()), enforces async all the way, CancellationToken propagation, and no async void outside event handlers.
  • ef-core-safe-queries.mdc — prevents N+1, requires AsNoTracking on read-only queries, pagination on unbounded queries, and DTO projection over loading full entities.
  • optimize-slow-ef-query.md — a ready-to-paste prompt for fixing a slow EF Core query the right way.

Install (Cursor)

From your repository root:

mkdir -p .cursor/rules
# copy the two rule files into your project's Cursor rules directory
cp cursor/rules/csharp-async-correctness.mdc .cursor/rules/
cp cursor/rules/ef-core-safe-queries.mdc .cursor/rules/

Reload Cursor, then check Cursor Settings → Rules to confirm both files appear. Both use alwaysApply: false, so add them to chat context when you're working on the relevant code, or toggle them on from Cursor's rules interface.

The rules are plain markdown with YAML front matter, so the guidance is also useful pasted into a Claude Code CLAUDE.md or a Copilot instructions file — the principles are tool-agnostic even though the install steps above are Cursor's.

Free subset vs. the full pack

This repo is deliberately narrow: two rules and one prompt, covering async and EF read queries. It is genuinely useful on its own and it is not a crippled trial.

The full .NET AI Coding Pack is a separate, paid product ($29, single-seat commercial license). It is the only pack I know of that spans Cursor, Claude Code subagents, and GitHub Copilot together, opinionated to senior .NET / EF Core / Azure practice. It adds:

  • eight scoped Cursor rules — core C#, Clean Architecture, EF Core, ASP.NET Core Web APIs, testing, security, performance, and Azure (this repo trims two of them);
  • Claude Code project guidance plus four agents (code reviewer, test writer, refactorer, PR describer);
  • a GitHub Copilot repository-instructions file;
  • an 18-prompt .NET task library;
  • a commercial/client-work license.

If these two rules save you time, that's the whole pitch — the paid pack is the same idea across your whole .NET stack and all three tools. No pressure: this subset stays free and MIT either way.

  • Want one more free rule plus a refactor prompt? There's a separate free async sample linked from the pack page below.
  • Full pack ($29): venturescape6.gumroad.com/l/pnmgwv

License

MIT — see LICENSE. Use it anywhere, including commercial projects. The paid pack is under a separate commercial license; nothing in this repo is copied from it under that license — these two rules are re-authored, trimmed versions released under MIT on purpose.

About

Free MIT Cursor rules for senior-grade C#

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors