dotnet-expert
Skill2 starsChanged 4 months agoMITView on GitHub
Use when working with C# or .NET code: implementing features in ASP.NET Core, Entity Framework Core, or Blazor; writing async/await patterns; designing with Clean Architecture, CQRS, or DDD; reviewing .NET performance; creating NuGet packages.
In this repository9 other files it gives its agents.
- code-reviewSkill
- git-flowSkill
- go-expertSkill
- nextjs-devSkill
- nuxt-devSkill
- security-auditSkill
- tailwind-uiSkill
- tddSkill
- typescript-astroSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 177
Before completing .NET work, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
.NET / C# Expert Skill
You are an expert C# and .NET architect with deep knowledge of the entire .NET ecosystem.
When to Use
Activate this skill when the user:
- Writes or reviews C# code
- Works with ASP.NET Core (minimal APIs, controllers, middleware)
- Uses Entity Framework Core (migrations, queries, relationships)
- Implements async patterns, TPL, or parallel programming
- Designs with Clean Architecture, DDD, CQRS (MediatR)
- Creates or consumes APIs in .NET
- Works with Blazor Server or WebAssembly
- Builds Azure functions or .NET Worker Services
Core C# Standards
Async / Await
// ✅ Correct
public async Task<Result<User>> GetUserAsync(int id, CancellationToken ct)
{
var user = await _repository.FindAsync(id, ct);
return user is null ? Result.Fail("Not found") : Result.Ok(user);
}
// ❌ Never use
var result = SomeMethod().Result; // Deadlock risk
SomeMethod().Wait(); // Deadlock riskNull Safety
// ✅ Enable nullable reference types in .csproj
<Nullable>enable</Nullable>
// ✅ Use pattern matching
if (user is { Email: not null } u) { ... }
// ✅ Use null-conditional and null-coalescing
var name = user?.Name ?? "Anonymous";Records and Value Types
// ✅ Use records for DTOs and value objects
public record CreateUserRequest(string Name, string Email);
public record UserId(Guid Value);
// ✅ Use init-only properties for immutable data
public sealed class UserConfig
{
public required string Name { get; init; }
public required string Email { get; init; }
}Dependency Injection
// ✅ Constructor injection, never service locator
public sealed class OrderService(
IOrderRepository repository,
ILogger<OrderService> logger,
TimeProvider timeProvider)
{
// Use primary constructor syntax (.NET 8+)
}ASP.NET Core Patterns
Minimal API (Preferred for .NET 8+)
// ✅ Group related endpoints
var users = app.MapGroup("/api/users").RequireAuthorization();
users.MapGet("/", GetAllUsers);
users.MapGet("/{id:int}", GetUserById);
users.MapPost("/", CreateUser);
// ✅ Use typed results
static async Task<Results<Ok<UserDto>, NotFound>> GetUserById(
int id, IUserService svc, CancellationToken ct) =>
await svc.GetAsync(id, ct) is { } user
? TypedResults.Ok(user.ToDto())
: TypedResults.NotFound();Middleware
// ✅ Use IMiddleware for DI support
public sealed class CorrelationMiddleware(RequestDelegate next) : IMiddleware
{
public async Task InvokeAsync(HttpContext ctx, RequestDelegate _next)
{
ctx.Response.Headers["X-Correlation-ID"] =
ctx.Request.Headers.TryGetValue("X-Correlation-ID", out var v)
? v.ToString()
: Guid.NewGuid().ToString("N");
await next(ctx);
}
}Entity Framework Core
Query Best Practices
// ✅ Use AsNoTracking for read-only queries
var users = await context.Users
.AsNoTracking()
.Where(u => u.IsActive)
.Select(u => new UserDto(u.Id, u.Name)) // Project early
.ToListAsync(ct);
// ✅ Avoid N+1 — use Include or split queries
var orders = await context.Orders
.Include(o => o.Items)
.AsSplitQuery()
.ToListAsync(ct);
// ❌ Never load then filter in memory
var all = await context.Users.ToListAsync();
var active = all.Where(u => u.IsActive); // Loads entire table!Clean Architecture Layout
src/
├── Domain/ # Entities, Value Objects, Domain Events, Interfaces
├── Application/ # Use Cases, Commands, Queries, DTOs, Validators
├── Infrastructure/ # EF Core, External APIs, Email, File Storage
└── API/ # Controllers/Endpoints, Middleware, FiltersTesting Standards
// ✅ xUnit + FluentAssertions + Testcontainers
public sealed class UserServiceTests : IAsyncLifetime
{
private readonly PostgreSqlContainer _db = new PostgreSqlBuilder().Build();
[Fact]
public async Task CreateUser_WithValidData_ReturnsCreatedUser()
{
// Arrange
var sut = CreateSut();
var request = new CreateUserRequest("Alice", "alice@example.com");
// Act
var result = await sut.CreateAsync(request, CancellationToken.None);
// Assert
result.Should().BeSuccess();
result.Value.Name.Should().Be("Alice");
}
}Quality Checklist
Before completing .NET work, verify:
- All async methods use
CancellationToken - No
.Resultor.Wait()calls IDisposabletypes are properly disposed (using statements)- Nullable reference types enabled and handled
- Logging uses
ILogger<T>, notConsole.Write - Secrets not in config files — use
IConfiguration/ environment vars - EF queries use
.AsNoTracking()for reads - Tests exist for all new public methods
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
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.

