modern-csharp

Refactor .NET 8+ C# classes using C# 12–14 language features.

4|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/zdanovichnick/dotnet-pilot --skill modern-csharp-zdanovichnick
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modern-csharp
Source: https://github.com/zdanovichnick/dotnet-pilot/tree/main/skills/modern-csharp
Command: npx skills add https://github.com/zdanovichnick/dotnet-pilot --skill modern-csharp-zdanovichnick

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you use modern C# language features correctly, so your .NET code stays clean, expressive, and aligned with current best practices instead of reverting to outdated patterns.

Core Features & Use Cases

  • C# 12–14 feature guidance: Covers primary constructors, collection expressions, records/with-expressions, pattern matching, required members, raw string literals, nullable reference types, file-scoped namespaces, and more.
  • Safer, clearer code patterns: Shows how to structure DTOs and immutable data shapes with records, enforce initialization with required members, and reduce boilerplate with primary constructors.
  • Practical adoption references: Mentions related skill packs that rely on these features for planning and architecture/error-handling conventions.

Quick Start

Use the modern-csharp skill to review a C# class or DTO you want to refactor for .NET 8+ and ask it to rewrite it using the most appropriate C# 12–14 features.

Frequently Asked Questions about modern-csharp

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

FAQPage Schema
How do I refactor a C# class to use modern language features in .NET 8?

To refactor a C# class for .NET 8, apply modern features like primary constructors, collection expressions, and file-scoped namespaces to reduce boilerplate and improve code clarity. This ensures your codebase aligns with current best practices.

When should I use records and with-expressions for DTOs in C#?

Use records and with-expressions for DTOs in C# when you need immutable data shapes and safer, clearer code patterns. They help structure domain models effectively while enforcing initialization with required members.

Does this C# guidance cover pattern matching and nullable reference types?

Yes, this C# guidance covers pattern matching and nullable reference types. It provides best practices for applying these features correctly to ensure your .NET services and domain models use safer, more expressive syntax.

What is the best way to enforce initialization for C# domain models?

The best way to enforce initialization for C# domain models is using required members. This feature ensures that object initialization is enforced at compile time, reducing boilerplate when combined with primary constructors and records.

Can I use raw string literals and collection expressions in C# 12?

Yes, you can use raw string literals and collection expressions in C# 12. These features help reduce boilerplate and improve readability when refactoring services and data transfer objects in modern .NET environments.