dotnet-guidelines
CommunityC# guidelines for clean, reliable .NET code.
Authorroeibajayo
Version1.0.0
Installs0
System Documentation
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
recordtypes 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
varfor 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
internalfor internal classes or records. - Never inject HttpClient/IHttpClientFactory; use
IRestClient. - Never register services directly in
IServiceCollection; useITransientService,IScopedService, orISingletonService. - Always use
ILoggerwith structured logging. - Always use cancellation tokens for asynchronous methods.
- Always use
IMemoryCorefor 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 buildto 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.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: dotnet-guidelines Download link: https://github.com/roeibajayo/claude-tools/archive/main.zip#dotnet-guidelines Please download this .zip file, extract it, and install it in the .claude/skills/ directory.