Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
github avatar

Dotnet Best Practices

  • 13.7k installs
  • 37.1k repo stars
  • Updated July 28, 2026
  • github/awesome-copilot

.NET Best Practices is a GitHub Copilot instruction providing guidance for .NET/C# development patterns.

About

.NET Best Practices is an instruction/skill entry within the Awesome GitHub Copilot collection. It provides Copilot guidance for .NET development following community standards. Developers use it when they need AI assistance for .NET/C# coding patterns and architecture decisions.

  • Part of Awesome GitHub Copilot community collection
  • Custom instruction for .NET/C# development
  • Integrated with Copilot coding assistance

Dotnet Best Practices by the numbers

  • 13,699 all-time installs (skills.sh)
  • +229 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #1 of 154 .NET & C# skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

dotnet-best-practices capabilities & compatibility

Capabilities
code guidance · architecture support
Use cases
refactoring
npx skills add https://github.com/github/awesome-copilot --skill dotnet-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs13.7k
repo stars37.1k
Security audit3 / 3 scanners passed
Last updatedJuly 28, 2026
Repositorygithub/awesome-copilot

How do you enforce .NET coding conventions pre-commit?

Provide GitHub Copilot guidance for .NET/C# best practices and architecture.

Who is it for?

.NET/C# developers seeking architecture and coding guidance

Skip if: Non-.NET stacks or teams that do not enforce XML docs, namespace layouts, or primary-constructor DI patterns.

When should I use this skill?

User asks to review, validate, or fix .NET/C# code against project best practices before commit.

What you get

Reviewed C# with XML documentation, corrected namespaces, DI patterns, and localization aligned to project rules.

  • Documented C# APIs
  • Corrected namespaces and DI patterns

Files

SKILL.mdMarkdownGitHub ↗

.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 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

Related skills

How it compares

Pick dotnet-best-practices for opinionated .NET convention enforcement rather than generic language linting.

FAQ

What does dotnet-best-practices check in C# code?

dotnet-best-practices verifies XML documentation on public APIs, namespace structure like Core.Feature or Service.Feature, primary constructor dependency injection, localization, and established design patterns across the selected .NET code.

Does dotnet-best-practices work on a selection only?

dotnet-best-practices targets ${selection} when provided and can review the entire project when no selection is active, making it suitable for both focused edits and solution-wide audits.

Is Dotnet Best Practices safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

.NET & C#backend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.