dotnet-backend-patterns
Build Production-Grade .NET Backends
Developing .NET backends requires understanding async patterns, dependency injection, and database access strategies. This skill provides proven templates and best practices for building APIs that are maintainable, testable, and performant.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "dotnet-backend-patterns". Generate a product service with Result pattern and caching
Expected outcome:
- Result<T> pattern with Success/Failure static methods
- ICacheService dependency for cache-aside pattern
- FluentValidation integration for request validation
- ILogger injection with proper log levels
- CancellationToken propagation through all async methods
- Soft delete support with repository pattern
Using "dotnet-backend-patterns". Create a user repository using Dapper with parameterized queries
Expected outcome:
- IDbConnection injection via factory pattern
- Parameterized SQL with @Id, @SearchTerm placeholders
- QueryFirstOrDefaultAsync for single records
- QueryAsync for multiple results with DynamicParameters
- Transaction support for multi-statement operations
Using "dotnet-backend-patterns". Set up dependency injection for a payment service
Expected outcome:
- Scoped lifetime for payment processing service
- IOptions<PaymentOptions> configuration binding
- HttpClient registration via IHttpClientFactory
- Singleton ConnectionMultiplexer for Redis
- Keyed services for multiple payment providers
Security Audit
SafeThis is a pure documentation and code template skill containing only educational C#/.NET patterns. Static findings are 100% false positives caused by the scanner misidentifying: (1) markdown code fences as Ruby backticks, (2) SQL/database patterns as cryptographic terms, (3) standard C# namespace imports as reconnaissance. No executable code, network calls, file system access, or command execution exists. All content is static educational material.
Risk Factors
⚙️ External commands (85)
🌐 Network access (1)
📁 Filesystem access (5)
Quality Score
What You Can Build
API Development
Design and implement RESTful APIs using Minimal API endpoints with proper error handling and validation
Data Access Layer
Build repository layers using EF Core for complex domains or Dapper for performance-critical queries
Testing Strategy
Write comprehensive test suites with mocked dependencies and integration tests against test databases
Try These Prompts
Create a service implementation for [EntityName] with CRUD operations using the Result pattern, dependency injection, and validation. Include cache-aside pattern and proper error handling.
Generate a [Dapper/EF Core] repository for [EntityName] with async methods for search, pagination, and bulk operations. Include parameterized queries and proper connection handling.
Write service registrations for [ServiceName] with proper lifetime (scoped/singleton/transient), IOptions configuration, and keyed services if needed.
Write xUnit tests for [ServiceName] using Moq. Include happy path, validation failures, and error scenarios. Use Fact and Theory attributes with proper assertions.
Best Practices
- Use async/await all the way through the call stack and always pass CancellationToken to async methods
- Prefer Result<T> over exceptions for business logic failures and validate inputs at API boundaries
- Use AsNoTracking() for read-only queries and select only needed columns to reduce memory usage
Avoid
- Never block on async code with .Result or .GetAwaiter().GetResult() as this causes deadlocks
- Avoid exposing EF entities directly in API responses - use DTOs for data transformation
- Do not use string concatenation for SQL queries - always use parameterized queries to prevent injection