What problem does it solve?
This Skill codifies C# coding guidelines and best practices to reduce bugs and improve maintainability across .NET projects.
Core Features & Use Cases
- Always use Primary Constructors for classes.
- Always prefer
record types for immutable data structures.
- Never mix multiple classes or DTOs in a single file; filename MUST match the class/DTO name (e.g.,
UserDto.cs).
- Avoid private fields prefixed with
_.
- Add a trailing period to all server-side log messages.
- Use
string? for nullable strings.
- Use
var for local variables when the type is obvious.
- Avoid Regions in code files.
- Use collection initializers and static lambdas when applicable.
- Always seal accessors for classes or records if not intended for inheritance.
- Always use
internal for internal classes or records.
- Never inject HttpClient/IHttpClientFactory; use
IRestClient.
- Never register services directly in
IServiceCollection; use ITransientService, IScopedService, or ISingletonService.
- Always use
ILogger with structured logging.
- Always use cancellation tokens for asynchronous methods.
- Always use
IMemoryCore for time-based in-memory caching.
- Always use DTOs for API communication, validated with attributes.
- Always name lambda parameters with
x.
- Never use try-catch blocks solely to log and rethrow exceptions.
- If backend changes are made, run
dotnet build to ensure no errors.
Quick Start
Review a .cs file (e.g., UserService.cs) to verify primary constructors, immutable DTO usage, and absence of Regions; propose concrete fixes.