modern-csharp-coding-standards
Skill4 starsChanged 10 months agoMITView on GitHub
Use this skill whenever writing or reviewing C# code to ensure use of modern language features, high performance, and robust API design.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Aaronontheweb/dotnet-skillstheir own version, first seen Aug 7, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- Aaronontheweb/dotnet-skills★ 1.2ksame 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 repository67 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agents-onboardingSkill
- agent-workitem-automationSkill
- architecture-testingSkill
- aspire-integration-testingSkill
- automated-standards-enforcementSkill
- best-practice-introductionSkill
- branching-strategy-and-conventionsSkill
- broken-windowSkill
- change-risk-rollbackSkill
- ci-cd-conformanceSkill
- component-boundary-ownershipSkill
- contract-consistency-validationSkill
- csharp-best-practicesSkill
- deployment-provenanceSkill
- documentation-as-codeSkill
- documentation-scaffoldSkill
- dotnet-bespoke-code-minimisationSkill
- dotnet-best-practicesSkill
- dotnet-domain-primitivesSkill
- dotnet-efcore-practicesSkill
- dotnet-healthchecksSkill
- dotnet-logging-serilogSkill
- dotnet-mapping-standardSkill
- dotnet-open-source-first-governanceSkill
- dotnet-source-generation-firstSkill
- dotnet-specification-patternSkill
- dotnet-testing-assertionsSkill
- environment-traceabilitySkill
- finishing-a-development-branch-iddSkill
- greenfield-baselineSkill
- impacted-scope-enforcementSkill
- incremental-change-impactSkill
- incremental-deploymentSkill
- innersource-governance-bootstrapSkill
- issue-driven-deliverySkill
- library-extraction-stabilisationSkill
- local-dev-experienceSkill
- markdown-authorSkill
- monorepo-orchestration-setupSkill
- observability-logging-baselineSkill
- pair-programmingSkill
- persona-switchingSkill
- process-skill-routerSkill
- quality-gate-enforcementSkill
- release-tagging-planSkill
- repo-best-practices-bootstrapSkill
- repository-foundation-bootstrapSkill
- requirements-gatheringSkill
- runtime-tooling-validationSkill
- safe-brownfield-refactorSkill
- scoped-colocationSkill
- security-processesSkill
- selective-build-testSkill
- semantic-version-impactSkill
- session-awareSkill
- skills-first-workflowSkill
- static-analysis-securitySkill
- structured-review-workflowSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Use of mutable classes where record or readonly record struct is appropriate.
- Distinctive: line 48
Ensure all async calls are awaited and tokens passed.
- Very specific: line 49
Use Span<T> for buffer/string manipulation where performance is key.
- Distinctive: line 51
Run static analysis and linters to ensure compliance.
- Distinctive: line 54
Documentation: Document significant architectural patterns (e.g., Value Objects) in an ADR.
- Very specific: line 61
Use record and readonly record struct for immutable domain modeling.
- Very specific: line 62
Prefer pattern matching over nested if/else branches.
- Very specific: line 64
Use Span<T> and Memory<T> for high-performance parsing and buffers.
- Very specific: line 71
Validation: Ensure Nullable is enabled in .csproj and zero warnings exist.
- Very specific: line 72
Validation: Verify CancellationToken is passed to all downstream async calls.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Modern C# Coding Standards
Intent
Enforce the use of modern C# (12+) features to improve code safety, readability, and performance. This includes a preference for immutability, functional-style patterns, and zero-allocation techniques.
When to Use
- Writing any new C# code (Records, Pattern matching, Primary constructors).
- Refactoring existing C# code to improve maintainability or performance.
- Designing domain models (Value Objects, Entities).
- Implementing high-performance or async-heavy paths.
Precondition Failure Signal
- Use of mutable classes where
recordorreadonly record structis appropriate. - Deep inheritance hierarchies instead of composition and interfaces.
- Manual null checks instead of Nullable Reference Types and pattern matching.
- Blocking on async code (
.Result,.Wait()) or missingCancellationToken. - Excessive allocations in performance-critical paths (not using
Span<T>).
Postcondition Success Signal
- Domain models use
record(DTOs/Entities) andreadonly record struct(Value Objects). - Code leverages
switchexpressions and modern pattern matching. Nullable Reference Typesare enabled and warnings addressed.- Async methods are "async all the way" and respect
CancellationToken. - High-performance paths use
Span<T>,Memory<T>, orArrayPool<T>.
Process
- Source Review: Inspect the code for outdated patterns (mutability, inheritance, blocking async).
- Implementation:
- Refactor to use modern C# features (e.g., convert class to record).
- Ensure all async calls are awaited and tokens passed.
- Use
Span<T>for buffer/string manipulation where performance is key.
- Verification:
- Run static analysis and linters to ensure compliance.
- Execute tests to verify behaviour remains unchanged.
- (Optional) Use benchmarks to demonstrate performance improvements for zero-allocation changes.
- Documentation: Document significant architectural patterns (e.g., Value Objects) in an ADR.
- Review: Tech Lead reviews for adherence to the "Modern C#" spirit.
Key Practices
- Use
recordandreadonly record structfor immutable domain modeling. - Prefer pattern matching over nested
if/elsebranches. - Pass
CancellationTokenthrough async call chains. - Use
Span<T>andMemory<T>for high-performance parsing and buffers.
Example Test / Validation
- Refactor: Convert a mutable DTO class to a positional
record. - Validation: Ensure
Nullableis enabled in.csprojand zero warnings exist. - Validation: Verify
CancellationTokenis passed to all downstream async calls.
Common Red Flags / Guardrail Violations
- "I'm used to the old way" (avoiding records/patterns).
- Ignoring nullable warnings by overusing
!. - Creating
BaseEntityorBaseServicehierarchies. - Using
AutoMapper(preferMapperlyfor compile-time safety).
Recommended Review Personas
- Tech Lead – validates modern pattern usage and architectural alignment.
- Software Engineer – validates implementation details and performance.
Skill Priority
P2 – Consistency & Governance
(Escalate to P1 for performance-critical or security-related code.)
Conflict Resolution Rules
- Modern C# standards override legacy patterns unless explicitly constrained by framework/interop requirements.
- Immutability is the default; mutability must be justified and scoped.
Conceptual Dependencies
- quality-gate-enforcement
- automated-standards-enforcement
Classification
Governance Core
Notes
See skills/modern-csharp-coding-standards/references/reference.md for focused examples and patterns.
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.

