dotnet-patterns

Enforce idiomatic async/await, dependency injection, and immutability in C# code.

2|Updated May 11, 2026
One-click install
npx skills add https://github.com/himanshu231204/AI_Research_agent --skill dotnet-patterns-himanshu231204
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-patterns
Source: https://github.com/himanshu231204/AI_Research_agent/tree/main/.opencode/skills/dotnet-patterns
Command: npx skills add https://github.com/himanshu231204/AI_Research_agent --skill dotnet-patterns-himanshu231204

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing C# and .NET code often leads to inconsistent quality, common anti-patterns like deadlocks from blocking async calls, or poor maintainability from mutable state and missing dependency injection, which increase bug rates and technical debt for .NET applications.

Core Features & Use Cases

  • Idiomatic Pattern Guidance: Covers immutability, explicit nullability, dependency injection, async/await best practices, and the options pattern for clean, maintainable code.
  • Production-Ready Examples: Includes concrete implementations for EF Core repository patterns, custom middleware, minimal APIs, guard clauses, and the result pattern for explicit error handling.
  • Anti-Pattern Avoidance: Explicitly lists common .NET pitfalls like async void methods, blocking on async code, and mutable static state with clear fixes.
  • Use Case: When building an ASP.NET Core e-commerce API, use this skill to implement proper DI for your order repository, avoid deadlocks in async service methods, and structure your code for long-term maintainability.

Quick Start

Use the dotnet-patterns skill to review your existing C# user service implementation to identify async anti-patterns and suggest improvements for immutability and dependency injection adherence.

Frequently Asked Questions about dotnet-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid deadlocks when blocking on async code in C#?

To avoid deadlocks when blocking on async code in C#, eliminate async void methods and never call .Result or .Wait() on tasks. Apply idiomatic async/await usage to prevent thread starvation and ensure maintainable execution.

What is the best way to configure dependency injection in ASP.NET Core?

The best way to configure dependency injection in ASP.NET Core is implementing the options pattern and immutability principles. This ensures explicit nullability, clean code architecture, and reduces maintenance costs for application services.

How do I implement the repository pattern with EF Core?

Implement the repository pattern with EF Core by structuring concrete implementations for data access. This approach enforces immutability, separates persistence logic, and provides production-ready examples for explicit error handling.

Why does mutable static state cause bugs in .NET applications?

Mutable static state causes bugs in .NET applications because it introduces shared state concurrency issues and poor maintainability. Avoiding mutable static state is a critical anti-pattern fix that enforces immutability and reduces technical debt.

Can I use the result pattern for error handling in minimal APIs?

Yes, you can use the result pattern for explicit error handling in minimal APIs. It provides production-ready implementations for custom middleware and guard clauses, ensuring robust error management without relying on exceptions.