dotnet-backend-patterns
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.
npx skills add wshobson/agents --skill dotnet-backend-patterns --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
A skill that instructs an AI coding agent on implementing and reviewing C#/.NET backend patterns, covering project structure, dependency injection, async/await usage, configuration with IOptions, data access with EF Core and Dapper, result handling, caching patterns, and multi-level caching, plus testing approaches.
How it works
- Provides a full project layout (Domain, Application, Infrastructure, Api) as a pattern for clean architecture.
- Demonstrates dependency injection setup with various lifetimes (Scoped, Singleton, Transient), options pattern registrations, factory-based and keyed services, and usage in consumer classes.
- Shows correct and incorrect async practices, including awaiting, WhenAll usage, ConfigureAwait, ValueTask for cached paths, and guidance against blocking on async calls.
- Details configuration patterns via IOptions, IOptionsSnapshot, and IOptionsMonitor, including example options classes and their registration/usage.
- Introduces a generic Result<T> type for flow-control without exceptions, including mapping helpers and usage in services and endpoints.
- Outlines data access patterns with EF Core (DbContext, configurations, repositories) and Dapper (queries, parameter handling, multi-mapping).
- Illustrates caching strategies, including multi-level caching with Memory Cache and Distributed Cache, and patterns for cache keys and invalidation (partial content shown in excerpt).
When to use it
- When developing new .NET Web APIs or MCP servers
- When reviewing C# code for quality and performance
- When designing service architectures with dependency injection
- When implementing caching strategies with Redis
- When writing unit and integration tests
- When optimizing database access with EF Core or Dapper
- When configuring applications with IOptions pattern
- When handling errors and implementing resilience patterns
What it can touch
- Tools listed: claude-code, codex, copilot, cursor
- Code examples appear in C# (.NET 6+/8+) alongside configuration and DI usage
- File structure references such as src/ and specific classes like AppDbContext, ProductRepository, DapperProductRepository, and various option classes are shown explicitly in the instructions
Caveats
- The skill demonstrates advanced patterns and requires an environment supporting C#/.NET, EF Core, and Dapper; actual runtime behavior depends on concrete project setup.
- Licensing noted as MIT; usage should comply with repository license terms.
# .NET Backend Development Patterns Master C#/.NET patterns for building production-grade APIs, MCP servers, and enterprise backends with modern best practices (2024/2025). ## When to Use This Skill - 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 ## Core Concepts ### 1. Project Structure (Clean Architecture) ``` src/ ├── Domain/ # Core business logic (no dependencies) │ ├── Entities/ │ ├── Interfaces/ │ ├── Exceptions/ │ └── ValueObjects/ ├── Application/ # Use cases, DTOs, validation │ ├── Services/ │ ├── DTOs/ │ ├── Validators/ │ └── Interfaces/ ├── Infrastructure/ # External implementations │ ├── Data/ # EF Core, Dapper repositories │ ├── Caching/ # Redis, Memory cache │ ├── External/ # HTTP clients, third-party APIs │ └── DependencyInjection/ # Service registration └── Api/ # Entry point ├── Controllers/ # Or MinimalAPI endpoints ├── Middle
- When to Use This Skill
- Core Concepts
- 1. Project Structure (Clean Architecture)
- 2. Dependency Injection Patterns
- 3. Async/Await Patterns
- 4. Configuration with IOptions
- 5. Result Pattern (Avoiding Exceptions for Flow Control)
- Data Access Patterns
- Entity Framework Core
- Dapper for Performance
- Caching Patterns
- Multi-Level Cache with Redis
- Testing Patterns
- Unit Tests with xUnit and Moq
What does the dotnet-backend-patterns skill do?
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.
How do I install it?
Run `npx skills add wshobson/agents --skill dotnet-backend-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From wshobson/agents, a repository with 38,479 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.