dotnet-backend-patterns
Skill72 starsChanged 7 months agoMITView on GitHub
Provides .NET and ASP.NET Core patterns for REST APIs, Entity Framework, dependency injection, and middleware. Use when working with C# files (*.cs, *.csproj) or when the user mentions .NET, ASP.NET Core, C#, or Entity Framework.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
- CodeWithBehnam/cc-docstheir own version, first seen Mar 15, 2026
- xfstudio/skillstheir own version, first seen Jan 22, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- CodeWithBehnam/cc-docs★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository117 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-healthSkill
- agent-styleSkill
- angular-best-practicesSkill
- annotateSkill
- api-designSkill
- architecture-decision-recordsSkill
- aws-serverlessSkill
- backend-architectSkill
- backend-patternsSkill
- brainstormSkill
- bug-reportSkill
- changelogSkill
- claude-apiSkill
- cloud-architectSkill
- cloud-run-puppeteerSkill
- code-review-checklistSkill
- code-reviewSkill
- code-simplificationSkill
- codex-sddSkill
- commitSkill
- context-engineeringSkill
- database-architectSkill
- db-reviewSkill
- deep-interviewSkill
- design-reviewSkill
- design-systemSkill
- devops-deploySkill
- diagnoseSkill
- django-patternsSkill
- docker-patternsSkill
- dreamSkill
- drizzle-orm-expertSkill
- estimateSkill
- event-sourcing-architectSkill
- fastapi-proSkill
- fork-joinSkill
- freezeSkill
- frontend-designSkill
- frontend-patternsSkill
- frontend-ui-dark-tsSkill
- gate-checkSkill
- gemini-api-integrationSkill
- gitlab-ci-patternsSkill
- guardSkill
- handoffSkill
- hotfixSkill
- hybrid-cloud-architectSkill
- kubernetes-architectSkill
- laravel-patternsSkill
- launch-checklistSkill
- learnerSkill
- llm-app-patternsSkill
- localizeSkill
- map-systemsSkill
- map-workflowSkill
- markdown-injection-scannerSkill
- microservices-patternsSkill
- milestone-reviewSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 56
Use .AsNoTracking() for read-only queries
- Very specific: line 57
Avoid N+1 with .Include() or projection
- Distinctive: line 58
Use compiled queries for hot paths
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
.NET Backend Development Patterns
C#/.NET patterns for production-grade APIs, MCP servers, and enterprise backends.
API Structure (Minimal API + Controllers)
```csharp
// Program.cs - Minimal API
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(o => o.UseNpgsql(connStr));
builder.Services.AddScoped<IOrderService, OrderService>();
var app = builder.Build(); app.MapGet("/orders/{id}", async (int id, IOrderService svc) => await svc.GetByIdAsync(id) is { } order ? Results.Ok(order) : Results.NotFound()); ```
Dependency Injection Patterns
```csharp // Register services builder.Services.AddScoped<IPaymentService, StripePaymentService>(); builder.Services.AddSingleton<ICacheService, RedisCacheService>(); builder.Services.AddHttpClient<IApiClient, ExternalApiClient>(client => { client.BaseAddress = new Uri("https://api.external.com"); }); ```
Lifetime guide: Singleton (stateless/cache), Scoped (per-request), Transient (stateless utility).
Entity Framework Core
```csharp
// DbContext with conventions
public class AppDbContext : DbContext {
public DbSet<Order> Orders => Set<Order>();
protected override void OnModelCreating(ModelBuilder builder) {
builder.Entity<Order>().HasIndex(o => o.UserId);
builder.Entity<Order>().Property(o => o.Total).HasPrecision(18, 2);
}
}
```
Performance tips:
- Use
.AsNoTracking()for read-only queries - Avoid N+1 with
.Include()or projection - Use compiled queries for hot paths
Middleware Pipeline
```csharp
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseAuthentication();
app.UseAuthorization();
app.UseRateLimiter();
app.MapControllers();
```
Error Handling
```csharp
// Global exception handler
app.UseExceptionHandler(err => err.Run(async context => {
var exception = context.Features.Get<IExceptionHandlerFeature>()?.Error;
var (status, message) = exception switch {
NotFoundException => (404, exception.Message),
UnauthorizedAccessException => (403, "Forbidden"),
_ => (500, "Internal server error")
};
context.Response.StatusCode = status;
await context.Response.WriteAsJsonAsync(new { error = message });
}));
```
Configuration (IOptions pattern)
```csharp
builder.Services.Configure<StripeSettings>(
builder.Configuration.GetSection("Stripe"));
// Usage
public class PaymentService(IOptions<StripeSettings> opts) {
private readonly string _key = opts.Value.SecretKey;
}
```
Testing
```csharp
// Integration test with WebApplicationFactory
public class OrderApiTests : IClassFixture<WebApplicationFactory<Program>> {
private readonly HttpClient _client;
[Fact]
public async Task GetOrder_ReturnsOk() {
var response = await _client.GetAsync("/orders/1");
response.StatusCode.Should().Be(HttpStatusCode.OK);
}
}
```
Related Skills
backend-architect— architecture decisionsdatabase-architect— schema designdrizzle-orm-expert— Node.js ORM alternative
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

