modern-csharp-coding-standards — for Claude Code modern-csharp-coding-standards, claude-template, community, for Claude Code, ide skills, Modern, Coding, Standards, Writing, refactoring

v1.0.0

Sobre este Skill

Perfeito para Agentes focados em C# que necessitam de padrões de codificação avançados e melhores práticas para o desenvolvimento moderno de C#. Resumo localizado: Write modern, high-performance C# code using records, pattern matching, value objects, async/await, Span<T /Memory<T , and best-practice API design patterns. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

Recursos

Modern C# Coding Standards
When to Use This Skill
Use this skill when:
Writing new C# code or refactoring existing code
Designing public APIs for libraries or services

# Tópicos principais

Thorstensen Thorstensen
[0]
[1]
Atualizado: 3/4/2026

Skill Overview

Start with fit, limitations, and setup before diving into the repository.

Perfeito para Agentes focados em C# que necessitam de padrões de codificação avançados e melhores práticas para o desenvolvimento moderno de C#. Resumo localizado: Write modern, high-performance C# code using records, pattern matching, value objects, async/await, Span<T /Memory<T , and best-practice API design patterns. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

Por que usar essa habilidade

Habilita os agentes a implementar modelos de domínio com tipagem forte, otimizar caminhos de código críticos de desempenho e projetar APIs públicas para bibliotecas ou serviços usando async/await e manipulação de dados binários.

Melhor para

Perfeito para Agentes focados em C# que necessitam de padrões de codificação avançados e melhores práticas para o desenvolvimento moderno de C#.

Casos de Uso Práticos for modern-csharp-coding-standards

Reestruturação de código C# existente para atender aos padrões de codificação modernos
Implementação de objetos de valor e padrões para modelagem de dados robusta
Otimização de aplicações que utilizam async/await para melhorar o desempenho

! Segurança e Limitações

  • Exige conhecimento de programação em C#
  • Focado em padrões de codificação C#, não se aplica a outras linguagens de programação

About The Source

The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.

Demo Labs

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

FAQ e etapas de instalação

These questions and steps mirror the structured data on this page for better search understanding.

? Perguntas frequentes

O que é modern-csharp-coding-standards?

Perfeito para Agentes focados em C# que necessitam de padrões de codificação avançados e melhores práticas para o desenvolvimento moderno de C#. Resumo localizado: Write modern, high-performance C# code using records, pattern matching, value objects, async/await, Span<T /Memory<T , and best-practice API design patterns. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

Como instalar modern-csharp-coding-standards?

Execute o comando: npx killer-skills add Thorstensen/claude-template. Ele funciona com Cursor, Windsurf, VS Code, Claude Code e mais de 19 outros IDEs.

Quais são os casos de uso de modern-csharp-coding-standards?

Os principais casos de uso incluem: Reestruturação de código C# existente para atender aos padrões de codificação modernos, Implementação de objetos de valor e padrões para modelagem de dados robusta, Otimização de aplicações que utilizam async/await para melhorar o desempenho.

Quais IDEs são compatíveis com modern-csharp-coding-standards?

Esta skill é compatível com Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use a CLI do Killer-Skills para uma instalação unificada.

modern-csharp-coding-standards tem limitações?

Exige conhecimento de programação em C#. Focado em padrões de codificação C#, não se aplica a outras linguagens de programação.

Como instalar este skill

  1. 1. Abra o terminal

    Abra o terminal ou linha de comando no diretório do projeto.

  2. 2. Execute o comando de instalação

    Execute: npx killer-skills add Thorstensen/claude-template. A CLI detectará sua IDE ou agente automaticamente e configurará a skill.

  3. 3. Comece a usar o skill

    O skill já está ativo. Seu agente de IA pode usar modern-csharp-coding-standards imediatamente no projeto atual.

! Source Notes

This page is still useful for installation and source reference. Before using it, compare the fit, limitations, and upstream repository notes above.

Upstream Repository Material

The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.

Upstream Source

modern-csharp-coding-standards

Install modern-csharp-coding-standards, an AI agent skill for AI agent workflows and automation. Explore features, use cases, limitations, and setup guidance.

SKILL.md
Readonly
Upstream Repository Material
The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.
Upstream Source

Modern C# Coding Standards

When to Use This Skill

Use this skill when:

  • Writing new C# code or refactoring existing code
  • Designing public APIs for libraries or services
  • Optimizing performance-critical code paths
  • Implementing domain models with strong typing
  • Building async/await-heavy applications
  • Working with binary data, buffers, or high-throughput scenarios

Reference Files

Core Principles

  1. Immutability by Default - Use record types and init-only properties
  2. Type Safety - Leverage nullable reference types and value objects
  3. Modern Pattern Matching - Use switch expressions and patterns extensively
  4. Async Everywhere - Prefer async APIs with proper cancellation support
  5. Zero-Allocation Patterns - Use Span<T> and Memory<T> for performance-critical code
  6. API Design - Accept abstractions, return appropriately specific types
  7. Composition Over Inheritance - Avoid abstract base classes, prefer composition
  8. Value Objects as Structs - Use readonly record struct for value objects

Language Patterns

Records for Immutable Data (C# 9+)

Use record types for DTOs, messages, events, and domain entities.

csharp
1// Simple immutable DTO 2public record CustomerDto(string Id, string Name, string Email); 3 4// Record with validation in constructor 5public record EmailAddress 6{ 7 public string Value { get; init; } 8 9 public EmailAddress(string value) 10 { 11 if (string.IsNullOrWhiteSpace(value) || !value.Contains('@')) 12 throw new ArgumentException("Invalid email address", nameof(value)); 13 14 Value = value; 15 } 16} 17 18// Records with collections - use IReadOnlyList 19public record ShoppingCart( 20 string CartId, 21 string CustomerId, 22 IReadOnlyList<CartItem> Items 23) 24{ 25 public decimal Total => Items.Sum(item => item.Price * item.Quantity); 26}

When to use record class vs record struct:

  • record class (default): Reference types, use for entities, aggregates, DTOs with multiple properties
  • record struct: Value types, use for value objects (see next section)

Value Objects as readonly record struct

Value objects should always be readonly record struct for performance and value semantics. Use explicit conversions, never implicit operators.

csharp
1public readonly record struct OrderId(string Value) 2{ 3 public OrderId(string value) : this( 4 !string.IsNullOrWhiteSpace(value) 5 ? value 6 : throw new ArgumentException("OrderId cannot be empty", nameof(value))) 7 { } 8 public override string ToString() => Value; 9} 10 11public readonly record struct Money(decimal Amount, string Currency); 12public readonly record struct CustomerId(Guid Value) 13{ 14 public static CustomerId New() => new(Guid.NewGuid()); 15}

See value-objects-and-patterns.md for complete examples including multi-value objects, factory patterns, and the no-implicit-conversion rule.

Pattern Matching (C# 8-12)

Use switch expressions, property patterns, relational patterns, and list patterns for cleaner code.

csharp
1public decimal CalculateDiscount(Order order) => order switch 2{ 3 { Total: > 1000m } => order.Total * 0.15m, 4 { Total: > 500m } => order.Total * 0.10m, 5 { Total: > 100m } => order.Total * 0.05m, 6 _ => 0m 7};

See value-objects-and-patterns.md for full pattern matching examples.


Nullable Reference Types (C# 8+)

Enable nullable reference types in your project and handle nulls explicitly.

csharp
1// In .csproj 2<PropertyGroup> 3 <Nullable>enable</Nullable> 4</PropertyGroup> 5 6// Explicit nullability 7public string? FindUserName(string userId) 8{ 9 var user = _repository.Find(userId); 10 return user?.Name; 11} 12 13// Pattern matching with null checks 14public decimal GetDiscount(Customer? customer) => customer switch 15{ 16 null => 0m, 17 { IsVip: true } => 0.20m, 18 { OrderCount: > 10 } => 0.10m, 19 _ => 0.05m 20}; 21 22// Guard clauses with ArgumentNullException.ThrowIfNull (C# 11+) 23public void ProcessOrder(Order? order) 24{ 25 ArgumentNullException.ThrowIfNull(order); 26 // order is now non-nullable in this scope 27 Console.WriteLine(order.Id); 28}

Composition Over Inheritance

Avoid abstract base classes. Use interfaces + composition. Use static helpers for shared logic. Use records with factory methods for variants.

See composition-and-error-handling.md for full examples.


Performance Patterns

Async/Await Best Practices

csharp
1// Async all the way - always accept CancellationToken 2public async Task<Order> GetOrderAsync(string orderId, CancellationToken cancellationToken) 3{ 4 var order = await _repository.GetAsync(orderId, cancellationToken); 5 return order; 6} 7 8// ValueTask for frequently-called, often-synchronous methods 9public ValueTask<Order?> GetCachedOrderAsync(string orderId, CancellationToken cancellationToken) 10{ 11 if (_cache.TryGetValue(orderId, out var order)) 12 return ValueTask.FromResult<Order?>(order); 13 return GetFromDatabaseAsync(orderId, cancellationToken); 14} 15 16// IAsyncEnumerable for streaming 17public async IAsyncEnumerable<Order> StreamOrdersAsync( 18 string customerId, 19 [EnumeratorCancellation] CancellationToken cancellationToken = default) 20{ 21 await foreach (var order in _repository.StreamAllAsync(cancellationToken)) 22 { 23 if (order.CustomerId == customerId) 24 yield return order; 25 } 26}

Key rules:

  • Always accept CancellationToken with = default
  • Use ConfigureAwait(false) in library code
  • Never block on async code (no .Result or .Wait())
  • Use linked CancellationTokenSource for timeouts

Span<T> and Memory<T>

Use Span<T> for synchronous zero-allocation operations, Memory<T> for async, and ArrayPool<T> for large temporary buffers.

See performance-and-api-design.md for complete Span/Memory examples and the API design section.


Error Handling: Result Type

For expected errors, use Result<T, TError> instead of exceptions. Use exceptions only for unexpected/system errors.

See composition-and-error-handling.md for the full Result type implementation and usage examples.


Avoid Reflection-Based Metaprogramming

Banned: AutoMapper, Mapster, ExpressMapper. Use explicit mapping extension methods instead. Use UnsafeAccessorAttribute (.NET 8+) when you genuinely need private member access.

See anti-patterns-and-reflection.md for full guidance.


Code Organization

csharp
1// File: Domain/Orders/Order.cs 2 3namespace MyApp.Domain.Orders; 4 5// 1. Primary domain type 6public record Order( 7 OrderId Id, 8 CustomerId CustomerId, 9 Money Total, 10 OrderStatus Status, 11 IReadOnlyList<OrderItem> Items 12) 13{ 14 public bool IsCompleted => Status is OrderStatus.Completed; 15 16 public Result<Order, OrderError> AddItem(OrderItem item) 17 { 18 if (Status is not OrderStatus.Draft) 19 return Result<Order, OrderError>.Failure( 20 new OrderError("ORDER_NOT_DRAFT", "Can only add items to draft orders")); 21 22 var newItems = Items.Append(item).ToList(); 23 var newTotal = new Money( 24 Items.Sum(i => i.Total.Amount) + item.Total.Amount, 25 Total.Currency); 26 27 return Result<Order, OrderError>.Success( 28 this with { Items = newItems, Total = newTotal }); 29 } 30} 31 32// 2. Enums for state 33public enum OrderStatus { Draft, Submitted, Processing, Completed, Cancelled } 34 35// 3. Related types 36public record OrderItem(ProductId ProductId, Quantity Quantity, Money UnitPrice) 37{ 38 public Money Total => new(UnitPrice.Amount * Quantity.Value, UnitPrice.Currency); 39} 40 41// 4. Value objects 42public readonly record struct OrderId(Guid Value) 43{ 44 public static OrderId New() => new(Guid.NewGuid()); 45} 46 47// 5. Errors 48public readonly record struct OrderError(string Code, string Message);

Best Practices Summary

DO's

  • Use record for DTOs, messages, and domain entities
  • Use readonly record struct for value objects
  • Leverage pattern matching with switch expressions
  • Enable and respect nullable reference types
  • Use async/await for all I/O operations
  • Accept CancellationToken in all async methods
  • Use Span<T> and Memory<T> for high-performance scenarios
  • Accept abstractions (IEnumerable<T>, IReadOnlyList<T>)
  • Use Result<T, TError> for expected errors
  • Pool buffers with ArrayPool<T> for large allocations
  • Prefer composition over inheritance

DON'Ts

  • Don't use mutable classes when records work
  • Don't use classes for value objects (use readonly record struct)
  • Don't create deep inheritance hierarchies
  • Don't ignore nullable reference type warnings
  • Don't block on async code (.Result, .Wait())
  • Don't use byte[] when Span<byte> suffices
  • Don't forget CancellationToken parameters
  • Don't return mutable collections from APIs
  • Don't throw exceptions for expected business errors
  • Don't allocate large arrays repeatedly (use ArrayPool)

See anti-patterns-and-reflection.md for detailed anti-pattern examples.


Additional Resources

Habilidades Relacionadas

Looking for an alternative to modern-csharp-coding-standards or another community skill for your workflow? Explore these related open-source skills.

Ver tudo

openclaw-release-maintainer

Logo of openclaw
openclaw

Resumo localizado: 🦞 # OpenClaw Release Maintainer Use this skill for release and publish-time workflow. It covers ai, assistant, crustacean workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

widget-generator

Logo of f
f

Resumo localizado: Generate customizable widget plugins for the prompts.chat feed system # Widget Generator Skill This skill guides creation of widget plugins for prompts.chat . It covers ai, artificial-intelligence, awesome-list workflows. This AI agent skill supports Claude Code, Cursor, and

flags

Logo of vercel
vercel

Resumo localizado: The React Framework # Feature Flags Use this skill when adding or changing framework feature flags in Next.js internals. It covers blog, browser, compiler workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

138.4k
0
Navegador

pr-review

Logo of pytorch
pytorch

Resumo localizado: Usage Modes No Argument If the user invokes /pr-review with no arguments, do not perform a review . It covers autograd, deep-learning, gpu workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

98.6k
0
Desenvolvedor