Agent skill · software engineering · github

dotnet-best-practices

Ensure .NET/C# code meets best practices for the solution/project.

Why this skill is useful

Codifies specific .NET/C# best practices and patterns that the AI wouldn't reliably generate on its own.

What it needs

About 2k tokens when loaded. Last updated 2026-08-07. 37,534 stars on the source repository.

What this skill does

.NET/C# Best Practices Your task is to ensure .NET/C# code in ${selection} meets the best practices specific to this solution/project. This includes: Documentation & Structure Create comprehensive XML documentation comments for all public classes, interfaces, methods, and properties Include parameter descriptions and return value descriptions in XML comments Follow the established namespace structure: {Core Console App Service}.{Feature} Design Patterns & Architecture Use primary constructor syntax for dependency injection (e.g., public class MyClass(IDependency dependency)) Implement the Command Handler pattern with generic base classes (e.g., CommandHandler<TOptions>) Use interface segregation with clear naming conventions (prefix interfaces with 'I') Follow the Factory pattern for complex object creation. Dependency Injection & Services Use constructor dependency injection with null checks via ArgumentNullException Register services with appropriate lifetimes (Singleton, Scoped, Transient) Use Microsoft.Extensions.DependencyInjection patterns Implement service interfaces for testability Resource Management & Localization Use ResourceManager for localized messages and error strings Separate LogMessages and ErrorMessages resource files Access resources via resourceManager.GetString("MessageKey") Async/Await Patterns Use async/await for all I/O operations and long-running tasks Return Task or Task<T> from async methods Use ConfigureAwait(false) where appropriate Handle async exceptions properly Testing Standards Use MSTest framework with FluentAssertions for assertions Follow AAA pattern (Arrange, Act, Assert) Use Moq for mocking dependencies Test both success and failure scenarios Include null parameter validation tests Configuration & Settings Use strongly-typed configuration classes with data annotations Implement validation attributes (Required, NotEmptyOrWhitespace) Use IConfiguration binding for settings Support appsettings.json configuration files Semantic Ke …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills github/dotnet-best-practices

View the source on GitHub

Browse the @skills marketplace