.NET Core Expert
Core Workflow
- Analyze requirements — Identify architecture pattern, data models, API design
- Design solution — Create clean architecture layers with proper separation
- Implement — Write high-performance code with modern C# features; run
dotnet build to verify compilation — if build fails, review errors, fix issues, and rebuild before proceeding
- Secure — Add authentication, authorization, and security best practices
- Test — Write comprehensive tests with xUnit and integration testing; run
dotnet test to confirm all tests pass — if tests fail, diagnose failures, fix the implementation, and re-run before continuing; verify endpoints with curl or a REST client
Reference Guide
Load detailed guidance based on context:
| Topic |
Reference |
Load When |
| Minimal APIs |
references/minimal-apis.md |
Creating endpoints, routing, middleware |
| Clean Architecture |
references/clean-architecture.md |
CQRS, MediatR, layers, DI patterns |
| Entity Framework |
references/entity-framework.md |
DbContext, migrations, relationships |
| Authentication |
references/authentication.md |
JWT, Identity, authorization policies |
| Cloud-Native |
references/cloud-native.md |
Docker, health checks, configuration |
Constraints
MUST DO
- Use .NET 8 and C# 12 features
- Enable nullable reference types:
<Nullable>enable</Nullable> in the .csproj
- Use async/await for all I/O operations — e.g.,
await dbContext.Users.ToListAsync()
- Implement proper dependency injection
- Use record types for DTOs — e.g.,
public record UserDto(int Id, string Name);
- Follow clean architecture principles
- Write integration tests with
WebApplicationFactory<Program>
- Configure OpenAPI/Swagger documentation
MUST NOT DO
- Use synchronous I/O operations
- Expose entities directly in API responses
- Skip input validation
- Use legacy .NET Framework patterns
- Mix concerns across architectural layers
- Use deprecated EF Core patterns
Code Examples
Minimal API Endpoint
// Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.MapGet("/users/{id}", async (int id, ISender sender, CancellationToken ct) =>
{
var result = await sender.Send(new GetUserQuery(id), ct);
return result is null ? Results.NotFound() : Results.Ok(result);
})
.WithName("GetUser")
.Produces<UserDto>()
.ProducesProblem(404);
app.Run();
MediatR Query Handler
// Application/Users/GetUserQuery.cs
public record GetUserQuery(int Id) : IRequest<UserDto?>;
public sealed class GetUserQueryHandler : IRequestHandler<GetUserQuery, UserDto?>
{
private readonly AppDbContext _db;
public GetUserQueryHandler(AppDbContext db) => _db = db;
public async Task<UserDto?> Handle(GetUserQuery request, CancellationToken ct) =>
await _db.Users
.AsNoTracking()
.Where(u => u.Id == request.Id)
.Select(u => new UserDto(u.Id, u.Name))
.FirstOrDefaultAsync(ct);
}
EF Core DbContext with Async Query
// Infrastructure/AppDbContext.cs
public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<User> Users => Set<User>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
}
}
// Usage in a service
public async Task<IReadOnlyList<UserDto>> GetAllAsync(CancellationToken ct) =>
await _db.Users
.AsNoTracking()
.Select(u => new UserDto(u.Id, u.Name))
.ToListAsync(ct);
DTO with Record Type
public record UserDto(int Id, string Name);
public record CreateUserRequest(string Name, string Email);
Output Templates
When implementing .NET features, provide:
- Project structure (solution/project files)
- Domain models and DTOs
- API endpoints or service implementations
- Database context and migrations if applicable
- Brief explanation of architectural decisions
Documentation
1---2name: dotnet-core-expert3description: Use when building .NET 8 applications with minimal APIs, clean architecture, or cloud-native microservices. Invoke for Entity Framework Core, CQRS with MediatR, JWT authentication, AOT compilation.4license: MIT5compatibility: opencode6metadata:7 source: https://skillmd.com/skills/farmage/dotnet-core-expert8 author: https://github.com/Jeffallan9 version: "1.1.0"10 domain: backend11 triggers: .NET Core, .NET 8, ASP.NET Core, C# 12, minimal API, Entity Framework Core, microservices .NET, CQRS, MediatR12 role: specialist13 scope: implementation14 output-format: code15 related-skills: fullstack-guardian, microservices-architect, cloud-architect, test-master16---1718# .NET Core Expert1920## Core Workflow21221. **Analyze requirements** — Identify architecture pattern, data models, API design232. **Design solution** — Create clean architecture layers with proper separation243. **Implement** — Write high-performance code with modern C# features; run `dotnet build` to verify compilation — if build fails, review errors, fix issues, and rebuild before proceeding254. **Secure** — Add authentication, authorization, and security best practices265. **Test** — Write comprehensive tests with xUnit and integration testing; run `dotnet test` to confirm all tests pass — if tests fail, diagnose failures, fix the implementation, and re-run before continuing; verify endpoints with `curl` or a REST client2728## Reference Guide2930Load detailed guidance based on context:3132| Topic | Reference | Load When |33|-------|-----------|-----------|34| Minimal APIs | `references/minimal-apis.md` | Creating endpoints, routing, middleware |35| Clean Architecture | `references/clean-architecture.md` | CQRS, MediatR, layers, DI patterns |36| Entity Framework | `references/entity-framework.md` | DbContext, migrations, relationships |37| Authentication | `references/authentication.md` | JWT, Identity, authorization policies |38| Cloud-Native | `references/cloud-native.md` | Docker, health checks, configuration |3940## Constraints4142### MUST DO43- Use .NET 8 and C# 12 features44- Enable nullable reference types: `<Nullable>enable</Nullable>` in the `.csproj`45- Use async/await for all I/O operations — e.g., `await dbContext.Users.ToListAsync()`46- Implement proper dependency injection47- Use record types for DTOs — e.g., `public record UserDto(int Id, string Name);`48- Follow clean architecture principles49- Write integration tests with `WebApplicationFactory<Program>`50- Configure OpenAPI/Swagger documentation5152### MUST NOT DO53- Use synchronous I/O operations54- Expose entities directly in API responses55- Skip input validation56- Use legacy .NET Framework patterns57- Mix concerns across architectural layers58- Use deprecated EF Core patterns5960## Code Examples6162### Minimal API Endpoint63```csharp64// Program.cs65var builder = WebApplication.CreateBuilder(args);66builder.Services.AddEndpointsApiExplorer();67builder.Services.AddSwaggerGen();68builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));6970var app = builder.Build();71app.UseSwagger();72app.UseSwaggerUI();7374app.MapGet("/users/{id}", async (int id, ISender sender, CancellationToken ct) =>75{76 var result = await sender.Send(new GetUserQuery(id), ct);77 return result is null ? Results.NotFound() : Results.Ok(result);78})79.WithName("GetUser")80.Produces<UserDto>()81.ProducesProblem(404);8283app.Run();84```8586### MediatR Query Handler87```csharp88// Application/Users/GetUserQuery.cs89public record GetUserQuery(int Id) : IRequest<UserDto?>;9091public sealed class GetUserQueryHandler : IRequestHandler<GetUserQuery, UserDto?>92{93 private readonly AppDbContext _db;9495 public GetUserQueryHandler(AppDbContext db) => _db = db;9697 public async Task<UserDto?> Handle(GetUserQuery request, CancellationToken ct) =>98 await _db.Users99 .AsNoTracking()100 .Where(u => u.Id == request.Id)101 .Select(u => new UserDto(u.Id, u.Name))102 .FirstOrDefaultAsync(ct);103}104```105106### EF Core DbContext with Async Query107```csharp108// Infrastructure/AppDbContext.cs109public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)110{111 public DbSet<User> Users => Set<User>();112113 protected override void OnModelCreating(ModelBuilder modelBuilder)114 {115 modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);116 }117}118119// Usage in a service120public async Task<IReadOnlyList<UserDto>> GetAllAsync(CancellationToken ct) =>121 await _db.Users122 .AsNoTracking()123 .Select(u => new UserDto(u.Id, u.Name))124 .ToListAsync(ct);125```126127### DTO with Record Type128```csharp129public record UserDto(int Id, string Name);130public record CreateUserRequest(string Name, string Email);131```132133## Output Templates134135When implementing .NET features, provide:1361. Project structure (solution/project files)1372. Domain models and DTOs1383. API endpoints or service implementations1394. Database context and migrations if applicable1405. Brief explanation of architectural decisions141142[Documentation](https://jeffallan.github.io/claude-skills/skills/backend/dotnet-core-expert/)