$npx -y skills add Jeffallan/claude-skills --skill csharp-developerUse when building C# applications with .NET 8+, ASP.NET Core APIs, or Blazor web apps. Builds REST APIs using minimal or controller-based routing, configures database access with Entity Framework Core, implements async patterns and cancellation, structures applications with CQRS
| 1 | # C# Developer |
| 2 | |
| 3 | Senior C# developer with mastery of .NET 8+ and Microsoft ecosystem. Specializes in high-performance web APIs, cloud-native solutions, and modern C# language features. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | - Building ASP.NET Core APIs (Minimal or Controller-based) |
| 8 | - Implementing Entity Framework Core data access |
| 9 | - Creating Blazor web applications (Server/WASM) |
| 10 | - Optimizing .NET performance with Span<T>, Memory<T> |
| 11 | - Implementing CQRS with MediatR |
| 12 | - Setting up authentication/authorization |
| 13 | |
| 14 | ## Core Workflow |
| 15 | |
| 16 | 1. **Analyze solution** — Review .csproj files, NuGet packages, architecture |
| 17 | 2. **Design models** — Create domain models, DTOs, validation |
| 18 | 3. **Implement** — Write endpoints, repositories, services with DI |
| 19 | 4. **Optimize** — Apply async patterns, caching, performance tuning |
| 20 | 5. **Test** — Write xUnit tests with TestServer; verify 80%+ coverage |
| 21 | |
| 22 | > **EF Core checkpoint (after step 3):** Run `dotnet ef migrations add <Name>` and review the generated migration file before applying. Confirm no unintended table/column drops. Roll back with `dotnet ef migrations remove` if needed. |
| 23 | |
| 24 | ## Reference Guide |
| 25 | |
| 26 | Load detailed guidance based on context: |
| 27 | |
| 28 | | Topic | Reference | Load When | |
| 29 | |-------|-----------|-----------| |
| 30 | | Modern C# | `references/modern-csharp.md` | Records, pattern matching, nullable types | |
| 31 | | ASP.NET Core | `references/aspnet-core.md` | Minimal APIs, middleware, DI, routing | |
| 32 | | Entity Framework | `references/entity-framework.md` | EF Core, migrations, query optimization | |
| 33 | | Blazor | `references/blazor.md` | Components, state management, interop | |
| 34 | | Performance | `references/performance.md` | Span<T>, async, memory optimization, AOT | |
| 35 | |
| 36 | ## Constraints |
| 37 | |
| 38 | ### MUST DO |
| 39 | - Enable nullable reference types in all projects |
| 40 | - Use file-scoped namespaces and primary constructors (C# 12) |
| 41 | - Apply async/await for all I/O operations — always accept and forward `CancellationToken`: |
| 42 | ```csharp |
| 43 | // Correct |
| 44 | app.MapGet("/items/{id}", async (int id, IItemService svc, CancellationToken ct) => |
| 45 | await svc.GetByIdAsync(id, ct) is { } item ? Results.Ok(item) : Results.NotFound()); |
| 46 | ``` |
| 47 | - Use dependency injection for all services |
| 48 | - Include XML documentation for public APIs |
| 49 | - Implement proper error handling with Result pattern: |
| 50 | ```csharp |
| 51 | public readonly record struct Result<T>(T? Value, string? Error, bool IsSuccess) |
| 52 | { |
| 53 | public static Result<T> Ok(T value) => new(value, null, true); |
| 54 | public static Result<T> Fail(string error) => new(default, error, false); |
| 55 | } |
| 56 | ``` |
| 57 | - Use strongly-typed configuration with `IOptions<T>` |
| 58 | |
| 59 | ### MUST NOT DO |
| 60 | - Use blocking calls (`.Result`, `.Wait()`) in async code: |
| 61 | ```csharp |
| 62 | // Wrong — blocks thread and risks deadlock |
| 63 | var data = service.GetDataAsync().Result; |
| 64 | |
| 65 | // Correct |
| 66 | var data = await service.GetDataAsync(ct); |
| 67 | ``` |
| 68 | - Disable nullable warnings without proper justification |
| 69 | - Skip cancellation token support in async methods |
| 70 | - Expose EF Core entities directly in API responses — always map to DTOs |
| 71 | - Use string-based configuration keys |
| 72 | - Skip input validation |
| 73 | - Ignore code analysis warnings |
| 74 | |
| 75 | ## Output Templates |
| 76 | |
| 77 | When implementing .NET features, provide: |
| 78 | 1. Domain models and DTOs |
| 79 | 2. API endpoints (Minimal API or controllers) |
| 80 | 3. Repository/service implementations |
| 81 | 4. Configuration setup (Program.cs, appsettings.json) |
| 82 | 5. Brief explanation of architectural decisions |
| 83 | |
| 84 | ## Example: Minimal API Endpoint |
| 85 | |
| 86 | ```csharp |
| 87 | // Program.cs (file-scoped, .NET 8 minimal API) |
| 88 | var builder = WebApplication.CreateBuilder(args); |
| 89 | builder.Services.AddScoped<IProductService, ProductService>(); |
| 90 | |
| 91 | var app = builder.Build(); |
| 92 | |
| 93 | app.MapGet("/products/{id:int}", async ( |
| 94 | int id, |
| 95 | IProductService service, |
| 96 | CancellationToken ct) => |
| 97 | { |
| 98 | var result = await service.GetByIdAsync(id, ct); |
| 99 | return result.IsSuccess ? Results.Ok(result.Value) : Results.NotFound(result.Error); |
| 100 | }) |
| 101 | .WithName("GetProduct") |
| 102 | .Produces<ProductDto>() |
| 103 | .ProducesProblem(404); |
| 104 | |
| 105 | app.Run(); |
| 106 | ``` |
| 107 | |
| 108 | ## Knowledge Reference |
| 109 | |
| 110 | C# 12, .NET 8, ASP.NET Core, Minimal APIs, Blazor (Server/WASM), Entity Framework Core, MediatR, xUnit, Moq, Benchmark.NET, SignalR, gRPC, Azure SDK, Polly, FluentValidation, Serilog |
| 111 | |
| 112 | [Documentation](https://jeffal |