dotnet-best-practices▌
github/awesome-copilot · updated Apr 16, 2026
Validate .NET/C# code against comprehensive best practices for your solution and project.
- ›Covers 10+ practice areas including XML documentation, design patterns, dependency injection, async/await, testing standards, and error handling
- ›Enforces specific patterns: primary constructors for DI, Command Handler pattern with generics, interface segregation, and Factory pattern for object creation
- ›Includes resource management with ResourceManager for localization, structured logging via Mic
.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 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 Kernel & AI Integration
- Use Microsoft.SemanticKernel for AI operations
- Implement proper kernel configuration and service registration
- Handle AI model settings (ChatCompletion, Embedding, etc.)
- Use structured output patterns for reliable AI responses
Error Handling & Logging
- Use structured logging with Microsoft.Extensions.Logging
- Include scoped logging with meaningful context
- Throw specific exceptions with descriptive messages
- Use try-catch blocks for expected failure scenarios
Performance & Security
- Use C# 12+ features and .NET 8 optimizations where applicable
- Implement proper input validation and sanitization
- Use parameterized queries for database operations
- Follow secure coding practices for AI/ML operations
Code Quality
- Ensure SOLID principles compliance
- Avoid code duplication through base classes and utilities
- Use meaningful names that reflect domain concepts
- Keep methods focused and cohesive
- Implement proper disposal patterns for resources
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.8★★★★★43 reviews- ★★★★★Aanya Wang· Dec 16, 2024
Registry listing for dotnet-best-practices matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Aditi Liu· Dec 12, 2024
dotnet-best-practices has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Noah Srinivasan· Nov 3, 2024
Useful defaults in dotnet-best-practices — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Soo Kim· Oct 22, 2024
I recommend dotnet-best-practices for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Oshnikdeep· Sep 25, 2024
Registry listing for dotnet-best-practices matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Noah Tandon· Sep 21, 2024
dotnet-best-practices fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Piyush G· Sep 17, 2024
We added dotnet-best-practices from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Mia Anderson· Sep 13, 2024
Registry listing for dotnet-best-practices matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Charlotte Iyer· Sep 13, 2024
Keeps context tight: dotnet-best-practices is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Charlotte Thompson· Sep 5, 2024
We added dotnet-best-practices from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
showing 1-10 of 43