dotnet-best-practices
Skill1 starsChanged 9 months agoMITView on GitHub
Ensure .NET/C# code meets best practices for the solution/project.
3 other projects use a version of this, 1 of them edited; 1 of 1 edited versions we compared changed its rules.
How people change it
1 of 1 edited versions changed its rules.
Of the 1 edited version we compared: 1 made changes of their own.
We split this file and each edited version into the rules they give an agent and match them by wording. A version that adds no rule of its own and has not changed since this file last did reads as an older text, so what it lacks is not counted as dropped. We keep no past texts of a file, so that is inferred, and an edited version that started from an older text still counts its gaps as drops.
Adopted by
Most recently taken up by
- github/awesome-copilotword for word, first seen Sep 23, 2026
- PracticalSwan/agent-skillsedited, first seen Sep 14, 2026
- mduongvandinh/ai-best-practices-skillstheir own version, first seen Feb 19, 2026
Other versions3 projects use a version of this.
Word for word · 1
- github/awesome-copilot★ 40k100% same
Edited · 1
- PracticalSwan/agent-skills★ 1847% same
Wrote their own version · 1
- mduongvandinh/ai-best-practices-skills★ 18same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- aspireSkill
- brainstormingSkill
- create-github-issue-feature-from-specificationSkill
- create-github-issues-feature-from-implementation-planSkill
- create-implementation-planSkill
- create-specificationSkill
- csharp-asyncSkill
- csharp-docsSkill
- csharp-mcp-server-generatorSkill
- csharp-mstestSkill
- csharp-nunitSkill
- csharp-tunitSkill
- csharp-xunitSkill
- dispatching-parallel-agentsSkill
- dotnet-design-pattern-reviewSkill
- dotnet-upgradeSkill
- editorconfigSkill
- ef-coreSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- skill-creatorSkill
- update-packagesSkill
- using-superpowersSkill
- verification-before-completionSkill
- writing-plansSkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
26 rules. About 0 are common, 25 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈25
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Create comprehensive XML documentation comments for all public classes, interfaces, methods, and properties
- Distinctive: line 14
Follow the established namespace structure: {Core|Console|App|Service}.{Feature}
- Very specific: line 18
Use primary constructor syntax for dependency injection (e.g., public class MyClass(IDependency dependency))
- Distinctive: line 20
Use interface segregation with clear naming conventions (prefix interfaces with 'I')
- Distinctive: line 21
Follow the Factory pattern for complex object creation.
- Distinctive: line 25
Use constructor dependency injection with null checks via ArgumentNullException
- Distinctive: line 32
Use ResourceManager for localized messages and error strings
- Distinctive: line 38
Use async/await for all I/O operations and long-running tasks
- Distinctive: line 40
Use ConfigureAwait(false) where appropriate
- Distinctive: line 45
Use MSTest framework with FluentAssertions for assertions
- Distinctive: line 46
Follow AAA pattern (Arrange, Act, Assert)
- Distinctive: line 47
Use Moq for mocking dependencies
- Distinctive: line 48
Test both success and failure scenarios
- Distinctive: line 53
Use strongly-typed configuration classes with data annotations
- Distinctive: line 55
Use IConfiguration binding for settings
- Distinctive: line 60
Use Microsoft.SemanticKernel for AI operations
- Distinctive: line 63
Use structured output patterns for reliable AI responses
- Distinctive: line 67
Use structured logging with Microsoft.Extensions.Logging
- Distinctive: line 70
Use try-catch blocks for expected failure scenarios
- Distinctive: line 74
Use C# 12+ features and .NET 8 optimizations where applicable
- Distinctive: line 76
Use parameterized queries for database operations
- Distinctive: line 77
Follow secure coding practices for AI/ML operations
- Distinctive: line 81
Ensure SOLID principles compliance
- Distinctive: line 82
Avoid code duplication through base classes and utilities
- Distinctive: line 83
Use meaningful names that reflect domain concepts
- Distinctive: line 84
Keep methods focused and cohesive
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
.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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

