agentleFS
BenknightdarkBenknightdark/neo-skills/skills/neo-csharp/SKILL.md

neo-csharp

Skill7 starsChanged 6 months agoMITView on GitHub

Use this skill when writing, reviewing, debugging, or modernizing C# code in .NET projects. Trigger for .cs/.csproj files, C# language-version questions, nullable reference types, records, pattern matching, async/cancellation, or version-appropriate syntax from C# 10+.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check .csproj to identify TargetFramework and determine the syntax upper limit:

    line 24
  2. Distinctive:

    Write high-quality code, prioritizing "syntactic sugar" to improve readability.

    line 36
  3. Very specific:

    Check if asynchronous operations correctly handle cancellation tokens (CancellationToken).

    line 41
  4. Distinctive:

    Ensure naming conventions comply with official .NET recommendations.

    line 42
  5. Distinctive:

    Required Members: Ensure required properties during object initialization.

    line 50
  6. Very specific:

    Immutability: Use record for Data Transfer Objects (DTO).

    line 75
  7. Very specific:

    Performance: Use Span<T> and ReadOnlySpan<char> in critical paths.

    line 76
  8. Very specific:

    Async Safety: Always pass CancellationToken, avoid .Result or .Wait().

    line 77
  9. Distinctive:

    Ensure the provided code complies with the syntax specifications of the target C# version.

    line 85

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Modern C# (10+) Expert Skill

Trigger On

  • The user asks to write, debug, refactor, or review C# code.
  • The project directory contains *.cs, *.csproj, or single-file C# scripts.
  • The target framework is .NET 6.0 (LTS) and above.
  • Code modernization is needed (e.g., converting legacy nested namespaces to File-scoped namespaces).

Workflow

  1. Perceive (Version Awareness):
    • Check .csproj to identify TargetFramework and determine the syntax upper limit:
      • net6.0: C# 10 (File-scoped namespaces, Global usings).
      • net7.0: C# 11 (Raw string literals, Required members).
      • net8.0: C# 12 (Primary Constructors, Collection Expressions).
      • net9.0: C# 13 (params collections, Lock object).
      • net10.0: C# 14 (Extension members, field keyword).
      • net11.0: C# 15 (Union types, closed hierarchies, collection-spread arguments, labeled break/continue, extension indexers, inline unsafe expressions).
  2. Reason (Planning Phase):
    • Evaluate the modernization level of the current code to determine the refactoring strategy.
    • In lower version environments (like .NET 6), avoid using higher version syntax (like Primary Constructors), but prioritize using File-scoped namespaces.
    • In higher version environments, actively adopt new features to reduce boilerplate code.
  3. Act (Execution Phase):
    • Write high-quality code, prioritizing "syntactic sugar" to improve readability.
    • Implement strong typing and immutable data structures (record, record struct).
    • Utilize Interpolated string handlers and Span<T> to optimize performance-sensitive paths.
  4. Validate (Standard Validation):
    • Validate the safety of NRT (Nullable Reference Types).
    • Check if asynchronous operations correctly handle cancellation tokens (CancellationToken).
    • Ensure naming conventions comply with official .NET recommendations.

Feature Roadmap (C# 10 - 15)

C# 10 & 11 (Foundation)

  • File-scoped Namespaces: Reduce indentation levels.
  • Global Using Directives: Centralize common namespaces management.
  • Raw String Literals: """...""" easily handle multi-line and special characters.
  • Required Members: Ensure required properties during object initialization.
  • List Patterns: if (list is [1, 2, ..]) powerful collection matching.

C# 12 & 13 (Productivity)

  • Primary Constructors: Simplify class-level dependency injection.
  • Collection Expressions: Uniformly use [1, 2, 3] to initialize collections.
  • params Collections: Method parameters support various collection types.
  • Implicit Span Conversion: Handle memory-safe code more naturally.

C# 14 (Language Extensions)

  • Extension Members: Extension properties, operators, and static members.
  • field Keyword: Directly access backing fields in property logic.
  • Null-conditional Assignment: target?.Property = value;.
  • Scripting: Support dotnet run file.cs for direct execution.

C# 15 (Advanced Types & Productivity)

  • Union Types: public union Pet(Cat, Dog, Bird); with exhaustive compiler-checked switch expressions without discarding _.
  • Closed Hierarchies: public closed record class State; restricts inheritance strictly within the defining project/assembly for domain safety.
  • Collection Expression Arguments: [with(capacity: values.Length * 2), .. values] or [with(StringComparer.OrdinalIgnoreCase), ...] for inline constructor customization.
  • Labeled Break & Continue: Jump out of deeply nested loops directly with break outer; and continue outer;.
  • Extension Indexers: Support this[int index] on extended types.
  • Localized Unsafe Expressions: Fine-grained unsafe(...) expressions for localized pointer operations without marking entire methods unsafe.

Coding Standards

  • Clean Structure: Prioritize using File-scoped namespaces.
  • Immutability: Use record for Data Transfer Objects (DTO).
  • Performance: Use Span<T> and ReadOnlySpan<char> in critical paths.
  • Async Safety: Always pass CancellationToken, avoid .Result or .Wait().

Deliver

  • Version-Optimized Code: Provide the most appropriate modernized syntax code based on the target C# version.
  • Modernization Insights: Provide specific refactoring suggestions for upgrading from older C# syntax to new features (e.g., from nested namespaces to File-scoped namespaces).
  • Syntax Explanations: Clearly explain the design intent and syntax advantages behind the new C# features used.

Validate

  • Ensure the provided code complies with the syntax specifications of the target C# version.
  • Validate whether the code follows C# strong typing and Null safety (NRT) principles.
  • Confirm the code has good readability and best practices at the pure C# language level (e.g., proper use of Span<T>, record, etc.).

Documentation

Official References

Internal References

  • C# Coding Style and Naming Conventions Guide
  • C# Anti-Patterns and Best Practices
  • Modern C# Patterns Guide

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.