dotnet-best-practices

Enforce .NET/C# best-practices compliance across a solution.

1|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/leonanpereirapinto/ai-utils --skill dotnet-best-practices-leonanpereirapinto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-best-practices
Source: https://github.com/leonanpereirapinto/ai-utils/tree/main/skills/dotnet/dotnet-best-practices
Command: npx skills add https://github.com/leonanpereirapinto/ai-utils --skill dotnet-best-practices-leonanpereirapinto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensures .NET/C# code in your solution adheres to established best practices, improving maintainability, readability, and reliability.

Core Features & Use Cases

  • Documentation & Structure: enforce XML documentation comments for all public classes, interfaces, methods, and properties; include parameter and return value descriptions; maintain a consistent namespace structure (Core|Console|App|Service).
  • Design Patterns & Architecture: promote primary constructor syntax for DI, Command Handler patterns with generic base classes, interface segregation, and factory patterns.
  • Dependency Injection & Services: enforce constructor DI with null checks, proper service lifetimes (Singleton/Scoped/Transient), and testable service interfaces.
  • Testing Standards: align with MSTest/FluentAssertions, apply AAA, use Moq, test success and failure scenarios, and validate null parameters.
  • Other Pragmatic Practices: resource management (ResourceManager usage), async/await patterns, configuration with strongly-typed settings, error handling with structured logging, and secure coding practices.

Quick Start

Run a targeted refactor pass to align the solution with the listed .NET best-practices guidelines.

Frequently Asked Questions about dotnet-best-practices

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

FAQPage Schema
How do I enforce C# best practices across a .NET solution?

To enforce C# best practices across a .NET solution, apply automated guidelines for XML documentation, constructor dependency injection with null checks, structured logging, and consistent namespace structures spanning Core, Console, App, and Service.

What is the best way to structure dependency injection in .NET applications?

The best way to structure dependency injection in .NET applications is using primary constructor syntax with null checks, configuring proper service lifetimes like Singleton, Scoped, or Transient, and ensuring service interfaces remain testable.

How do I set up MSTest and FluentAssertions for .NET testing standards?

To set up MSTest and FluentAssertions for .NET testing standards, align test frameworks with the AAA pattern, use Moq for mocking, test both success and failure scenarios, and validate null parameters comprehensively.

Does this .NET best practices guidance support Console and Service projects?

Yes, this .NET best practices guidance supports Console and Service projects alongside Core and App namespaces, ensuring consistent architecture, configuration validation, and secure coding practices across all project types.

When do I need to use async patterns and structured logging in C#?

You need to use async patterns and structured logging in C# when implementing error handling and performance improvements, ensuring reliable resource management with ResourceManager and strongly-typed configuration settings.