Write modern, high-performance C# code using records, pattern matching, value objects, async/await, Span<T>/Memory<T>, and best-practice API design patterns. Emphasizes functional-style programming with C# 12+ features.
Modern C# Coding Standards is a reference-and-guidance skill that teaches an agent (or developer) how to write idiomatic, high-performance C# using recent language features. It addresses the common problem of legacy, allocation-heavy, inheritance-driven C# by codifying a set of opinionated principles: immutability by default, strong type safety, extensive pattern matching, async everywhere, and zero-allocation patterns for hot paths. The material is framed as best-practice conventions applied when writing new code, refactoring, designing public APIs, or optimizing performance-critical paths.
The skill is organized around a SKILL.md overview plus four focused reference files. It covers records for immutable DTOs and domain entities, value objects modeled as `readonly record struct` with validation-at-construction (OrderId, Money, EmailAddress, AbsoluteUrl and similar constraint-enforcing types), switch-expression and property/relational/list pattern matching, nullable reference types, `Span<T>`/`Memory<T>` usage and API-design principles, composition over inheritance with a Result type for error handling, and an explicit catalogue of anti-patterns including reflection avoidance. Every recommendation is accompanied by concrete C# 9-12 code examples.
It targets .NET library authors, backend and service developers, and teams standardizing on modern C# idioms, especially those building domain models, high-throughput or buffer-heavy code, and async-first applications. It is a pure knowledge asset (`invocable: false`) with no scripts to execute, so it functions as a style guide and code-review companion rather than an automated tool.
It targets modern C#, with examples spanning C# 8 through 12 (records, switch expressions, list patterns, relational patterns). It also assumes nullable reference types are enabled in the project.
No. It is marked invocable: false and consists of SKILL.md plus reference markdown files. It provides patterns and code examples to follow, not executable scripts.
When writing or refactoring C#, designing public library/service APIs, implementing strongly-typed domain models, or optimizing performance-critical, allocation-sensitive code paths.
For value semantics (content-based equality), stack allocation to reduce GC pressure, immutability, and clean interaction with pattern matching. It also advises validating at construction and avoiding implicit conversions to preserve type safety.
No. The guidance is language-level and framework-agnostic, applicable to any modern .NET codebase.
Quick Setup:
.claude/skills/Repository
aaronontheweb/dotnet-skills