C# · .NET · ASP.NET Core
ASP.NET Core rules for Cursor
Dependency injection, async and EF Core rules for ASP.NET Core APIs.
The rule
Save as .cursor/rules/dotnet.mdc. Cursor picks it up on the next request.
.cursor/rules/dotnet.mdc
---
description: ASP.NET Core conventions
globs: **/*.cs, **/appsettings*.json
alwaysApply: false
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.
How Cursor loads this rule
Read from the frontmatter above, per Cursor's rules documentation.
alwaysApply: falsewithglobs: **/*.cs, **/appsettings*.json: attached automatically when a matching file is in context.- Keep the
.mdcextension. A plain.mdfile in .cursor/rules is ignored by the rules system. - Prefer to generate your own? Type
/create-rulein Agent and describe what you want; Cursor saves the file to .cursor/rules. - Team Rules come first, then Project Rules like this one, then User Rules. Earlier sources win when guidance conflicts.
Cursor rules setup guideCursor Team RulesLet Cursor run commands without asking
ASP.NET Core rules for Claude Code, Copilot, Kiro and other agents
The same instructions work as plain Markdown in AGENTS.md, which Codex, Gemini CLI, GitHub Copilot and most other coding agents read.
AGENTS.md (section)
## ASP.NET Core
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.
ASP.NET Core rules for Claude Code.claude/rules/dotnet.md
.claude/rules/dotnet.md
---
paths:
- "**/*.cs"
- "**/appsettings*.json"
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.ASP.NET Core rules for GitHub Copilot.github/instructions/dotnet.instructions.md
.github/instructions/dotnet.instructions.md
---
applyTo: "**/*.cs,**/appsettings*.json"
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.ASP.NET Core rules for Kiro.kiro/steering/dotnet.md
.kiro/steering/dotnet.md
---
inclusion: fileMatch
fileMatchPattern: ["**/*.cs", "**/appsettings*.json"]
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.ASP.NET Core rules for Antigravity.agents/rules/dotnet.md
.agents/rules/dotnet.md
---
trigger: glob
globs: "**/*.cs, **/appsettings*.json"
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.ASP.NET Core rules for Devin Desktop (Windsurf).devin/rules/dotnet.md
.devin/rules/dotnet.md
---
trigger: glob
globs: **/*.cs, **/appsettings*.json
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.ASP.NET Core rules for Cline.clinerules/dotnet.md
.clinerules/dotnet.md
---
paths:
- "**/*.cs"
- "**/appsettings*.json"
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.ASP.NET Core rules for Continue.continue/rules/dotnet.md
.continue/rules/dotnet.md
---
name: "dotnet"
globs: ["**/*.cs", "**/appsettings*.json"]
---
- Follow the project's existing style: minimal APIs or controllers. Do not mix both in one feature.
- Register services in Program.cs and inject them through constructors; never new up services or use a static service locator.
- Use async all the way down and accept a CancellationToken; never call .Result or .Wait().
- Bind settings with the options pattern (IOptions<T>) and keep secrets in user secrets or environment variables, not appsettings.json.
- Return TypedResults or ActionResult<T>, and use AddProblemDetails for error responses.
- Use IHttpClientFactory or typed clients; never create a new HttpClient per request.
- Log with ILogger<T> and message templates ("Order {OrderId} failed"), not string interpolation.
- With EF Core, use AsNoTracking for read-only queries and change the schema only through dotnet ef migrations.
- Keep nullable reference types enabled and fix new warnings; run dotnet build and dotnet test before finishing.More templates
Get Cursor rules and settings changes by email
When Cursor changes how rules, run modes or settings work, we update these templates from the docs and send a short note. One email a week at most.
Reviewed Oct 20, 2026. Written by AgentAtlas. Adapt it to your codebase before relying on it.