skills/dotnet-backend-clean-architecture/SKILL.md
Clean Architecture + CQRS (MediatR) for .NET 10 backend APIs. Builds and maintains APIs with vertical slice (Features), Commands/Queries, handlers, validators, repositories, FluentMigrator, Refit integrations. Use when creating or refactoring .NET APIs, adding endpoints, commands, queries, entities, or when the user mentions Clean Architecture, CQRS, or MediatR.
npx skillsauth add luismpenholato/maurao-skills dotnet-backend-clean-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide for creating and maintaining .NET 10 backends with Clean Architecture, CQRS (MediatR), and Features organization (vertical slice).
| Technology | Usage |
|---|---|
| .NET 10 | Runtime and SDK (net10.0, SDK 10.0.301+) |
| MediatR 14 | CQRS |
| FluentValidation 12 | Validation in handler |
| EF Core 10 | ORM (InMemory / SQL Server) |
| FluentMigrator 8 | SQL schema (not EF Migrations) |
| Refit 11 + Http.Resilience 10 | HTTP integrations |
| xUnit + NSubstitute + FluentAssertions | Unit tests |
Solution at backend root: {Solution}.sln and .editorconfig (adjust names to your project).
{solution-root}/
├── {Solution}.sln
├── .editorconfig
├── CleanStack.Interface/ # API (Controllers, Program, Middlewares)
├── CleanStack.Application/ # Features/ → Commands and Queries
├── CleanStack.Domain/ # Entities, Interfaces, Services
├── CleanStack.Infrastructure/ # EF Core, Repositories, UnitOfWork
├── CleanStack.CrossCutting/ # DTOs, Options, Helpers
├── CleanStack.CrossCutting.IOC/ # ConfigureBindings* (DI)
├── CleanStack.Migration/ # FluentMigrator (console)
└── CleanStack.Tests/ # Features/ mirroring Application
Dependency rule: Interface → Application, CrossCutting, CrossCutting.IOC. Application and Infrastructure reference Domain. Application does not reference Infrastructure.
Domain
Entities/Order.cs implementing IEntity<TKey> (e.g., long).Interfaces/Repositories/IOrderRepository.cs extending ICrudRepository<Order, long>.Interfaces/UnitOfWork/IOrderUnitOfWork.cs with repository + SaveChangesAsync.CrossCutting
Dto/Orders/OrderDto.cs (and other API DTOs if needed).Infrastructure
Persistence/Map/OrderEntityConfig.cs (EF Fluent API).DbSet<Order> in AppDbContext.Repositories/OrderRepository.cs extending RepositoryBase<Order, long>.UnitOfWork/OrderUnitOfWork.cs implementing IOrderUnitOfWork.ConfigureBindingsRepository and ConfigureBindingsUnitOfWork.Application – Commands
Features/Orders/Commands/CreateOrder/.CreateOrderCommand.cs: record with : IRequest<OrderDto>.CreateOrderHandler.cs: inject IOrderUnitOfWork and IValidator<T>; ValidateAndThrowAsync at the start; return DTO.CreateOrderValidator.cs: AbstractValidator<CreateOrderCommand> when validation is needed.Application – Queries
Features/Orders/Queries/ListOrders/.ListOrdersQuery.cs + ListOrdersHandler.cs.Interface
Controllers/OrdersController.cs: [ApiController], IMediator, HTTP returns (Ok, CreatedAtAction, NotFound, NoContent).Tests
CleanStack.Tests/Features/Orders/ mirroring Application:
{Command}HandlerTests.cs / {Query}HandlerTests.cs — NSubstitute; mock IValidator<T> in handlers.{Command}ValidatorTests.cs — real validator + Validate().[Trait("Category", "Orders")].Migration
CleanStack.Migration/Migrations/ (e.g., Mig_YYYYMMDDHHMMSS_CreateOrders.cs).Persistence/Map/.When a feature consumes an external API:
ExternalProductDto), Options/ExternalProductApiOptions.cs.Interfaces/Integration/IExternalProductIntegration.cs (Refit) and Interfaces/Services/IExternalProductService.cs.ConfigureBindingsIntegration — AddRefitClient<T>() + AddStandardResilienceHandler().IExternalProductService.Config: ExternalProductApi:BaseUrl in appsettings.
Command (record)
public sealed record CreateProductCommand(
string? Name,
string? Description,
decimal? Price,
bool IsActive = true,
int? ImportFromExternalId = null) : IRequest<ProductDto>;
Handler (explicit validation — no global ValidationBehavior)
public async Task<ProductDto> Handle(CreateProductCommand request, CancellationToken cancellationToken)
{
await _validator.ValidateAndThrowAsync(request, cancellationToken);
// logic + repository via UoW
}
Validator registration (IOC)
services.AddValidatorsFromAssemblyContaining<CreateProductValidator>();
Controller
CancellationToken; only Mediator.Send.ValidationException → global middleware → 400 ProblemDetails.InvalidOperationException → 400.GlobalExceptionMiddleware in Interface.CleanStack.Application.Features.{Feature}.Commands.{CommandName} and ...Queries.{QueryName}.ConfigureBindings*.cs).Application/Common/Behaviors/ValidationBehavior in this pattern — validation stays in the handler.dotnet format {Solution}.sln (.editorconfig).development
React 19 + Next.js 16 App Router, TypeScript, Ant Design, TanStack Query, Axios, React Hook Form, Zod — Clean Architecture frontend with vertical slice by feature. Use when creating or refactoring Next.js apps, admin panels, SaaS frontends, CRUDs, forms, layouts and frontend architecture.
development
Angular 21 standalone frontend with Clean Architecture, vertical slice (pages by feature), signals, OnPush, and ng-zorro. Use when creating or refactoring Angular apps, adding pages, components, services, directives, pipes, or when the user mentions Angular frontend, standalone components, or signals.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.