home / skills / sickn33 / antigravity-awesome-skills / dotnet-backend-patterns

dotnet-backend-patterns skill

/skills/dotnet-backend-patterns

This skill helps you master C#/.NET backend patterns for robust APIs, DI, EF Core, caching, testing, and resilient architectures.

This is most likely a fork of the dotnet-backend-patterns skill from xfstudio
npx playbooks add skill sickn33/antigravity-awesome-skills --skill dotnet-backend-patterns

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
1.5 KB
---
name: dotnet-backend-patterns
description: Master C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.
---

# .NET Backend Development Patterns

Master C#/.NET patterns for building production-grade APIs, MCP servers, and enterprise backends with modern best practices (2024/2025).

## Use this skill when

- Developing new .NET Web APIs or MCP servers
- Reviewing C# code for quality and performance
- Designing service architectures with dependency injection
- Implementing caching strategies with Redis
- Writing unit and integration tests
- Optimizing database access with EF Core or Dapper
- Configuring applications with IOptions pattern
- Handling errors and implementing resilience patterns

## Do not use this skill when

- The project is not using .NET or C#
- You only need frontend or client guidance
- The task is unrelated to backend architecture

## Instructions

- Define architecture boundaries, modules, and layering.
- Apply DI, async patterns, and resilience strategies.
- Validate data access performance and caching.
- Add tests and observability for critical flows.
- If detailed patterns are required, open `resources/implementation-playbook.md`.

## Resources

- `resources/implementation-playbook.md` for detailed .NET patterns and examples.

Overview

This skill teaches C#/.NET backend development patterns for building robust, production-grade APIs, MCP servers, and enterprise applications. It focuses on modern practices for 2024/2025 including async/await, dependency injection, EF Core and Dapper, configuration, caching, and testing with xUnit. Use it to raise code quality, performance, and maintainability in .NET backends.

How this skill works

The skill inspects architecture boundaries, layering, and module responsibilities, then recommends concrete patterns for DI, async patterns, and resilience (retries, circuit breakers). It evaluates data access choices and caching strategies, highlights observability and testing gaps, and delivers prescriptive actions to improve performance and reliability. For deep implementation patterns, it points to the playbook for code examples and recipes.

When to use it

  • Starting a new .NET Web API or MCP server project
  • Performing code reviews to improve C# backend quality
  • Designing service-level architecture and dependency injection
  • Optimizing database access with EF Core or Dapper
  • Implementing caching (Redis) and configuration via IOptions
  • Adding unit and integration tests using xUnit

Best practices

  • Define clear layer boundaries (API, domain, data) and keep models separated
  • Use constructor DI and limit service lifetimes to correct scopes
  • Favor async/await-end-to-end to avoid thread starvation
  • Prefer EF Core for rich domain mapping and Dapper for high-performance queries
  • Centralize configuration with IOptions and validate at startup
  • Add automated unit and integration tests; assert performance for critical flows

Example use cases

  • Designing an API project structure with domain, application, and infrastructure layers
  • Refactoring a slow endpoint by switching heavy queries to Dapper and adding Redis caching
  • Hardening service reliability with Polly-based retry and circuit-breaker policies
  • Reviewing pull requests to enforce DI patterns and eliminate synchronous I/O on request threads
  • Creating xUnit integration tests that run against a transient test database and mocked external services

FAQ

When should I pick EF Core vs Dapper?

Choose EF Core for complex domain models, migrations, and change tracking; choose Dapper for raw performance and simple, hand-optimized SQL queries.

How do I handle configuration safely across environments?

Centralize settings with IOptions/IOptionsMonitor, validate configuration at startup, and keep secrets in a secure store like Azure Key Vault or environment variables.