Agent skill

Modern Csharp

by codewithmukesh in codewithmukesh/dotnet-claude-kit

Modern C language features for .NET 10 and C 14. An agent skill from codewithmukesh/dotnet-claude-kit.

MITAuto-check passedDevelopment

Install Modern Csharp

skills CLI
$ npx skills add codewithmukesh/dotnet-claude-kit --skill modern-csharp -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install codewithmukesh/dotnet-claude-kit modern-csharp --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/codewithmukesh/dotnet-claude-kit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/modern-csharp .claude/skills/modern-csharp && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
modern-csharp
GitHub stars
751
Used in
1 other repo
Token cost
~1.7k tokens
SKILL.md length
373 words
Files
1
Skills in repo
47
Repo updated
First seen
Licence
MIT

At a glance

Modern C language features for .NET 10 and C 14. An agent skill from codewithmukesh/dotnet-claude-kit.

  • Works in 4 steps: Use the newest stable features — C# 14… → Readability over cleverness — Pattern… → Value types where possible — Prefer… → …
  • Tasks that involve Legacy modernization
  • SKILL.md covers Core Principles, Patterns, Anti-patterns and Decision Guide
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Modern Csharp is an agent skill from codewithmukesh/dotnet-claude-kit. Modern C language features for .NET 10 and C 14. Covers primary constructors, collection expressions, the field keyword, extension members, records, pattern matching, spans, and raw string literals. Load this skill when writing any new C code, reviewing existing code for modernization, using "modern C", "C 14", "primary constructor", "collection expression", "records", "pattern matching", "span", "field keyword", or "extension members". Always loaded as the baseline for all agents.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Legacy modernization. It works with C# and .NET. The repository describes itself as: Make Claude Code a .NET 10 Expert. The licence is MIT.

When your agent uses it

  • Tasks that involve Legacy modernization

Example prompts

  • “modern C”
  • “primary constructor”
  • “collection expression”
  • “/modern-csharp”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Use the newest stable features — C# 14 is the target. Prefer language-level constructs over library workarounds.
  2. Readability over cleverness — Pattern matching and expression-bodied members improve readability when used appropriately; deeply nested…
  3. Value types where possible — Prefer record struct, Span, and stack allocation to reduce GC pressure.
  4. Immutability by default — Use record, readonly, init, and required to make illegal states unrepresentable.

What it can do on your machine

Read from SKILL.md and the folder at commit 2330089. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Modern Csharp loads about 1.7k tokens when it runs. Until then it costs about 126 tokens; SKILL.md has 373 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~126
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from codewithmukesh/dotnet-claude-kit at commit 2330089, republished under its MIT licence (© codewithmukesh). 373 words, ~1,726 tokens.

Download SKILL.mdSave it as .claude/skills/modern-csharp/SKILL.md (or your agent's skills folder).
name
modern-csharp
description
Modern C# language features for .NET 10 and C# 14. Covers primary constructors, collection expressions, the field keyword, extension members, records, pattern matching, spans, and raw string literals. Load this skill when writing any new C# code, reviewing existing code for modernization, using "modern C#", "C# 14", "primary constructor", "collection expression", "records", "pattern matching", "span", "field keyword", or "extension members". Always loaded as the baseline for all agents.

Modern C# (C# 14 / .NET 10)

Core Principles

  1. Use the newest stable features — C# 14 is the target. Prefer language-level constructs over library workarounds.
  2. Readability over cleverness — Pattern matching and expression-bodied members improve readability when used appropriately; deeply nested patterns do not.
  3. Value types where possible — Prefer record struct, Span<T>, and stack allocation to reduce GC pressure.
  4. Immutability by default — Use record, readonly, init, and required to make illegal states unrepresentable.

Patterns

Well-Known Features Quick Reference
FeatureUsageExample
Primary constructorsDI injection, eliminate field assignmentspublic class OrderService(IOrderRepo repo, TimeProvider clock) { }
Collection expressions[] for all collection types + spreadList<string> names = ["Alice", "Bob"]; / int[] all = [..a, ..b, 99];
RecordsDTOs, value objects, immutable datapublic record CreateOrderRequest(string CustomerId, List<OrderItem> Items);
readonly record structSmall stack-allocated value typespublic readonly record struct Money(decimal Amount, string Currency);
Pattern matchingSwitch expressions, list/property patternsorder switch { { Total: > 1000 } => "Premium", _ => "Standard" };
List patternsDeconstruct arrays/listsitems switch { [] => "Empty", [var x] => $"One: {x}", [var f, .., var l] => $"{f}..{l}" };
Span<T>Zero-allocation slicingReadOnlySpan<char> trimmed = input.Trim(); int.TryParse(trimmed[4..], out id);
Raw string literalsMulti-line SQL, JSON, XMLvar sql = """ SELECT ... """; / interpolated: $$""" {"id": "{{id}}"} """;
required membersEnforce initializationpublic required string ConnectionString { get; init; }
is pattern + extractionNull/type/property checkif (result is { IsSuccess: true, Value: var order }) { ... }
The field Keyword (C# 14)

Access the auto-generated backing field in property accessors without declaring it manually.

csharp
// GOOD — field keyword for validation in auto-property
public class Product
{
    public string Name
    {
        get => field;
        set => field = value?.Trim() ?? throw new ArgumentNullException(nameof(value));
    }

    public decimal Price
    {
        get => field;
        set => field = value >= 0 ? value : throw new ArgumentOutOfRangeException(nameof(value));
    }
}
Show full SKILL.md (144 more words)Show less
Lazy Initialization with field
csharp
public class ProductCatalog
{
    // Lazy-load on first access — no manual Lazy<T> or backing field
    public IReadOnlyList<Product> Products
    {
        get => field ??= LoadProducts();
    }

    private static List<Product> LoadProducts() => /* expensive load */;
}
Change Notification with field
csharp
// INotifyPropertyChanged without manual backing fields
public class OrderViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler? PropertyChanged;

    public string CustomerName
    {
        get => field;
        set
        {
            if (field == value) return;
            field = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CustomerName)));
        }
    } = "";

    public decimal Total
    {
        get => field;
        set
        {
            if (field == value) return;
            field = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Total)));
        }
    }
}
Extension Members (C# 14)

C# 14 adds extension blocks inside static classes. Unlike classic extension methods, they support extension properties and static extension members — the receiver is declared once for the whole block.

csharp
// GOOD — extension block (shipped C# 14 syntax)
public static class OrderExtensions
{
    extension(Order order)
    {
        public decimal TotalWithTax => order.Total * 1.2m;

        public bool IsHighValue => order.Total > 1000m;

        public string ToSummary() =>
            $"Order #{order.Id}: {order.Total:C} ({order.Items.Count} items)";
    }

    // Static extension members use the type (no receiver instance)
    extension(Order)
    {
        public static Order Empty => Order.Create("none", [], DateTimeOffset.MinValue);
    }
}

// Callers see them as if declared on Order
if (order.IsHighValue) { /* ... */ }

Classic this-parameter extension methods still work and coexist — use extension blocks when you need properties or several members on the same receiver.

Anti-patterns

Don't Use Obsolete Patterns When Modern Alternatives Exist
csharp
// BAD — manual backing field when field keyword works
private string _name;
public string Name
{
    get => _name;
    set => _name = value ?? throw new ArgumentNullException();
}

// BAD — old-style collection initialization
var list = new List<int>() { 1, 2, 3 };

// BAD — Tuple instead of record for domain types
(string Name, decimal Price) product = ("Widget", 9.99m);
// GOOD — record
public record Product(string Name, decimal Price);
Don't Over-pattern-match
csharp
// BAD — deeply nested pattern that's hard to read
if (order is { Customer: { Address: { Country: { Code: "US" } } } })

// GOOD — extract to a clear method or use sequential checks
if (order.Customer.Address.Country.Code == "US")
Don't Use var When the Type Is Not Obvious
csharp
// BAD — what type is this?
var result = Process(order);

// GOOD — explicit type when not obvious
Result<Order> result = Process(order);
// Also GOOD — var is fine when type is apparent
var orders = new List<Order>();

Decision Guide

ScenarioRecommendation
DTO / API contractrecord (reference type)
Small value object (2-3 fields)readonly record struct
Service with DIPrimary constructor
Collection creationCollection expression []
Property with validationfield keyword
Multi-line string (SQL, JSON)Raw string literal """
Slicing strings/arraysSpan<T>
Type checking + extractionPattern matching with is / switch
Enforced initializationrequired modifier
Adding methods to external typesExtension members

© codewithmukesh, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/modern-csharp of codewithmukesh/dotnet-claude-kit.

Open the folder on GitHubat commit 2330089

Used in 1 other repository

We found 4 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in codewithmukesh/dotnet-claude-kit, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Modern Csharp next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Modern Csharp compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Modern Csharp this skillcodewithmukesh/dotnet-claude-kit7511 repos~1.7kAutomated safety check: PassMIT
Migrate Dotnet8 To Dotnet9dotnet/skills5.6k2 repos~3.9kAutomated safety check: PassMIT
Aspire Project V2 MigrationCommunityToolkit/Aspire629—~3.4kAutomated safety check: PassMIT
Dynamo Dotnet JanitorDynamoDS/Dynamo2k—~682Automated safety check: PassApache-2.0
Fsharpmanagedcode/dotnet-skills486—~1.9kAutomated safety check: PassMIT
Migrate Dotnet9 To Dotnet10dotnet/skills5.6k2 repos~4.8kAutomated safety check: PassMIT

Similar skills

  • Official

    Migrate a .NET 8 project to .NET 9 and resolve all breaking changes.

    5.6k GitHub starsUsed in 2 repos~3.9k tokens
    DevelopmentAuto-check passed
  • Aspire Project V2 Migration

    CommunityToolkit/Aspire

    WORKFLOW SKILL - Safely migrates eligible Aspire 13.6+ AppHosts from legacy ProjectResource APIs to experimental DotnetProjectResource APIs after a per-resource assessment and explicit approval of…

    629 GitHub stars~3.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Dynamo Dotnet Janitor

    DynamoDS/Dynamo

    Perform janitorial tasks on C/.NET code including cleanup, modernization, and tech debt remediation.

    2k GitHub stars~682 tokensUpdated today
    DevelopmentAuto-check passed
  • Fsharp

    managedcode/dotnet-skills

    Write, review, or modernize F code in .NET repositories with functional-first design, algebraic data types, pattern matching, pipelines, async workflows, project ordering, and C interop.

    486 GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Official

    Migrate a .NET 9 project or solution to .NET 10 and resolve all breaking changes.

    5.6k GitHub starsUsed in 2 repos~4.8k tokens
    DevOps & CloudAuto-check passed
  • Official

    Migrate a .NET 10 project or solution to .NET 11 and resolve all breaking changes.

    5.6k GitHub starsUsed in 1 repo~3.6k tokens
    DevOps & CloudAuto-check passed

More from codewithmukesh/dotnet-claude-kit

All 47 skills in this repo
  • API Versioning

    codewithmukesh/dotnet-claude-kit

    API versioning strategies for ASP.NET Core. An agent skill from codewithmukesh/dotnet-claude-kit.

    751 GitHub starsUsed in 1 repo~1.2k tokens
    Auto-check passed
  • Scaffold

    codewithmukesh/dotnet-claude-kit

    Architecture-aware feature scaffolding for .NET 10 projects.

    751 GitHub stars~1.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Architecture Advisor

    codewithmukesh/dotnet-claude-kit

    Architecture selection advisor for .NET applications. An agent skill from codewithmukesh/dotnet-claude-kit.

    751 GitHub starsUsed in 1 repo~2.9k tokens
    Auto-check passed
  • Aspire

    codewithmukesh/dotnet-claude-kit

    .NET Aspire for cloud-native orchestration. An agent skill from codewithmukesh/dotnet-claude-kit.

    751 GitHub starsUsed in 1 repo~1.5k tokens
    Auto-check passed
  • Authentication

    codewithmukesh/dotnet-claude-kit

    Authentication and authorization for ASP.NET Core. An agent skill from codewithmukesh/dotnet-claude-kit.

    751 GitHub starsUsed in 1 repo~1.9k tokens
    Auto-check passed
  • Caching

    codewithmukesh/dotnet-claude-kit

    Caching strategies for .NET 10 applications. An agent skill from codewithmukesh/dotnet-claude-kit.

    751 GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check passed

Works with

Categories

Questions about Modern Csharp

What does Modern Csharp do?

Modern C language features for .NET 10 and C 14. An agent skill from codewithmukesh/dotnet-claude-kit. Modern Csharp is an agent skill from codewithmukesh/dotnet-claude-kit.NET 10 and C 14.

When should I use Modern Csharp?

Modern Csharp fits situations like: tasks that involve Legacy modernization.

How do I install Modern Csharp in Claude Code?

Run `npx skills add codewithmukesh/dotnet-claude-kit --skill modern-csharp -a claude-code`. Or copy the skill folder (skills/modern-csharp in codewithmukesh/dotnet-claude-kit) into .claude/skills/modern-csharp in your project. Claude Code loads it when a task matches its description.

How do I install Modern Csharp in Codex?

Run `npx skills add codewithmukesh/dotnet-claude-kit --skill modern-csharp -a codex`. Or copy the skill folder (skills/modern-csharp in codewithmukesh/dotnet-claude-kit) into .agents/skills/modern-csharp in your project. Codex loads it when a task matches its description.

Can I use Modern Csharp in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add codewithmukesh/dotnet-claude-kit --skill modern-csharp -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/modern-csharp, .gemini/skills/modern-csharp, .github/skills/modern-csharp and .opencode/skills/modern-csharp in your project.

What does Modern Csharp need to run?

SKILL.md names no scripts, command-line tools or credentials: Modern Csharp is instructions for the agent only.

Does Modern Csharp access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Modern Csharp safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Modern Csharp use?

Modern Csharp is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Modern Csharp use?

About 1.7k tokens (SKILL.md is roughly 6.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Modern Csharp?

Skills that share tags, products or a category with Modern Csharp: Migrate Dotnet8 To Dotnet9 (dotnet/skills, 5.6k stars), Aspire Project V2 Migration (CommunityToolkit/Aspire, 629 stars), Dynamo Dotnet Janitor (DynamoDS/Dynamo, 2k stars) and Fsharp (managedcode/dotnet-skills, 486 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Modern Csharp?

codewithmukesh (a GitHub organization) maintains it in codewithmukesh/dotnet-claude-kit, which has 751 GitHub stars. The repository holds 47 skills in this directory. The repository was last updated on August 7, 2026.

Source: codewithmukesh/dotnet-claude-kit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.