modern-csharp-coding-standards

Enforce modern C# coding practices for .NET projects using records and Span<T>.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/Thorstensen/claude-template --skill modern-csharp-coding-standards-thorstensen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modern-csharp-coding-standards
Source: https://github.com/Thorstensen/claude-template/tree/main/.claude/skills/csharp-coding-standards
Command: npx skills add https://github.com/Thorstensen/claude-template --skill modern-csharp-coding-standards-thorstensen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This set of guidelines helps teams adopt modern C# coding practices to improve maintainability, readability, and performance of .NET applications by promoting immutable design, explicit patterns, and safe, expressive constructs.

Core Features & Use Cases

  • Immutability by default using records and readonly structs for stable, testable domain models and DTOs.
  • Type safety and nullability discipline with nullable reference types and explicit value objects.
  • Modern pattern matching, robust async/await usage, and zero-allocation techniques (Span<T>/Memory<T>) for high-performance code.
  • Emphasis on composition over inheritance and API design that favors clear abstractions and stable boundaries.

Quick Start

Provide a short, ready-to-run C# example that demonstrates a record-based DTO and a readonly record struct value object.

Frequently Asked Questions about modern-csharp-coding-standards

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce modern C# coding standards for records and value objects?

Modern C# coding standards enforce immutability by requiring records and readonly structs for domain models and DTOs, ensuring stable and testable data structures. Using readonly record structs creates explicit value objects with built-in equality.

What is the best way to implement zero-allocation patterns in .NET high-performance apps?

Zero-allocation patterns in high-performance C# apps utilize Span<T> and Memory<T> to safely manage memory without allocating on the heap. These constructs enable efficient processing of contiguous memory regions while maintaining type safety.

How do I use nullable reference types properly when refactoring C# code?

Nullable reference types in C# refactoring require explicit nullability discipline to prevent NullReferenceExceptions. Enabling nullable context forces developers to annotate reference types, creating clear boundaries for APIs and ensuring type safety.

Can I use pattern matching to improve C# API design and readability?

Pattern matching improves C# API design by replacing complex conditional logic with expressive type checks and data extraction. Modern C# applies pattern matching to create clear abstractions and stable boundaries, favoring composition over inheritance.

When should I use async programming in .NET, and what are the constraints?

Async programming in .NET should be used for I/O-bound operations to improve application responsiveness, but requires robust async/await usage to avoid deadlocks. Avoid async void methods and ensure proper ConfigureAwait usage in library code.

Does modern C# favor composition over inheritance for domain models?

Modern C# standards favor composition over inheritance to build flexible domain models and APIs. By combining immutable records and explicit value objects, developers create stable abstractions without the fragility of deep inheritance hierarchies.