modern-csharp-coding-standards

Apply modern C# patterns like records, pattern matching, and Span<T> across project layers.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/afonsoft/VideoChat --skill modern-csharp-coding-standards-afonsoft
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modern-csharp-coding-standards
Source: https://github.com/afonsoft/VideoChat/tree/main/.agents/skills/modern-csharp-coding-standards
Command: npx skills add https://github.com/afonsoft/VideoChat --skill modern-csharp-coding-standards-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers face difficulty maintaining consistency across large C# codebases, risking performance gaps and brittle APIs. This Skill provides a cohesive set of modern C# patterns and practices to standardize design, typing, and high-performance code.

Core Features & Use Cases

  • Immutability by default with records and init properties to simplify reasoning.
  • Value objects via readonly record structs for performance and safety.
  • Modern pattern matching and advanced APIs for clean domain models.
  • Async-first approaches, Span<T>/Memory<T> usage, zero-allocation techniques.
  • Composition over inheritance to improve testability and flexibility.
  • Performance-oriented API design and explicit error handling patterns.

Quick Start

Refactor a sample domain model to use records, value objects, and pattern matching, then benchmark the performance improvements.

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 immutability and performance?

Modern C# coding standards enforce immutability and performance by adopting records with init properties and readonly record structs for value objects. This approach simplifies domain reasoning while ensuring safe, zero-allocation APIs across typical project layers.

What is the best way to handle errors in modern C# APIs without exceptions?

Modern C# APIs handle errors using explicit Result types rather than exceptions. This performance-oriented pattern provides well-typed boundaries, ensuring safe error handling and clear domain models while maintaining composition over inheritance for better testability.

How do I use Span<T> and Memory<T> for zero-allocation techniques in C#?

Span<T> and Memory<T> enable zero-allocation techniques by providing safe, contiguous memory access without garbage collection overhead. Combined with async-first approaches, these advanced APIs optimize domain models and enforce explicit, well-typed boundaries across application layers.

Can I use modern C# pattern matching and value objects in legacy library code?

Yes, modern C# pattern matching and value objects via readonly record structs can be applied to legacy library code. Refactoring domain models to use these patterns, alongside composition over inheritance, improves maintainability and readability without breaking existing application boundaries.

Why should I choose composition over inheritance in C# application layers?

Composition over inheritance in C# improves testability and flexibility by avoiding brittle class hierarchies. Combined with modern pattern matching, async patterns, and explicit error handling using Result types, it standardizes design and ensures well-typed boundaries across library and application code.