modern-csharp

Modernize C# code with C# 14 constructs like primary constructors and records.

1|Updated Apr 28, 2026
One-click install
npx skills add https://github.com/Trossitec/dotnet-claude-kit --skill modern-csharp-trossitec
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: modern-csharp
Source: https://github.com/Trossitec/dotnet-claude-kit/tree/main/skills/modern-csharp
Command: npx skills add https://github.com/Trossitec/dotnet-claude-kit --skill modern-csharp-trossitec

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Modern C# feature guidance prevents .NET developers from writing outdated patterns and missing safer, more efficient language constructs, keeping codebases consistent and easier to maintain.

Core Features & Use Cases

  • Modern language-first implementations: Prefer C# 14 features like primary constructors, collection expressions, records, pattern matching, raw string literals, and extension members to reduce boilerplate and improve clarity.
  • Performance-minded constructs: Use value-oriented types such as record structs and leverage Span<T> for low-allocation slicing when handling text and parsing.
  • Correctness and safer state: Apply required members and immutability patterns, and use the field keyword to enforce validation and lazy initialization without manual backing fields.

Use Case Example: When reviewing a service class that uses constructor boilerplate and mutable DTOs, apply primary constructors, convert DTOs to records, use required/init where appropriate, and replace verbose parsing and string handling with Span<T> and raw string literals for clearer, safer C# 14 code.

Quick Start

Load this skill and modernize the following C# codebase to C# 14 using primary constructors, records/value types, pattern matching, raw string literals, and field keyword validation where it improves correctness.

Frequently Asked Questions about modern-csharp

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

FAQPage Schema
How do I modernize outdated C# code to use C# 14 features?▼

Modernize outdated C# code by applying C# 14 constructs like primary constructors, collection expressions, records, and pattern matching to reduce boilerplate and improve clarity. Replace mutable DTOs with records and leverage Span<T> for low-allocation text parsing.

What's the best way to use records and Span<T> for safer C# state management?▼

Use records and required members to enforce immutability and safer state in C#. Leverage Span<T> for low-allocation slicing when handling text, and apply the field keyword to enforce validation without manual backing fields.

Can I use primary constructors and collection expressions in production .NET projects?▼

Primary constructors and collection expressions are recommended for production .NET projects to eliminate constructor boilerplate and simplify initialization. They favor readability and correctness by default when writing new C# 14 code.

When should I avoid over-pattern-matching in modern C#?▼

Avoid over-pattern-matching in modern C# when it reduces readability or introduces unnecessary complexity. The skill enforces correctness by discouraging anti-patterns like over-pattern-matching and legacy backing-field styles in favor of cleaner language constructs.

How does the field keyword improve lazy initialization in C# 14?▼

The field keyword improves lazy initialization in C# 14 by enforcing validation without manual backing fields. It enables safer property patterns and helps maintain correctness by replacing legacy backing-field styles with modern syntax.

Why should I replace legacy backing-field styles with raw string literals and extension members?▼

Replace legacy backing-field styles with raw string literals and extension members to reduce verbose C# code and improve maintainability. Raw string literals simplify string handling while extension members keep codebases consistent and easier to maintain.