ASP.NET Core Web API

Refactor ASP.NET Core Web API projects into Clean Architecture with MediatR CQRS.

1|Updated May 2, 2026
One-click install
npx skills add https://github.com/Levironexe/architect --skill asp-net-core-web-api-levironexe
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ASP.NET Core Web API
Source: https://github.com/Levironexe/architect/tree/main/skills/stacks/aspnetcore-webapi
Command: npx skills add https://github.com/Levironexe/architect --skill asp-net-core-web-api-levironexe

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Vibe-driven refactors in ASP.NET Core projects often blur responsibilities across controllers, persistence, and application logic, making changes risky and hard to test. This Skill helps your coding agent impose a Clean Architecture separation that keeps dependencies flowing inward and preserves behavior while moving toward a maintainable structure.

Core Features & Use Cases

  • Layered Clean Architecture: Establish Domain, Application, Infrastructure, and API layers as distinct projects with a strict dependency rule (Domain has zero framework dependencies).
  • MediatR-based use cases: Implement write/read operations as Commands/Queries with Handlers and co-located validation.
  • Thin controllers: Convert HTTP requests into MediatR sends and return DTOs/results without direct EF Core or business logic.
  • Data access isolation: Keep EF Core DbContext, repository implementations, and entity configurations within Infrastructure, exposed via Domain interfaces.

Use case: you inherit an ASP.NET Core 8+ codebase where controllers directly call DbContext and business logic is scattered, and you need a phased refactor plan that moves toward a testable CQRS + Clean Architecture layout.

Quick Start

Tell your agent: "Using this repository, map the current ASP.NET Core structure to a Clean Architecture (Domain/Application/Infrastructure/API) with MediatR Commands/Queries, then propose and implement a phased refactor plan that keeps controllers thin and moves EF Core code into Infrastructure."

Frequently Asked Questions about ASP.NET Core Web API

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor an ASP.NET Core Web API to clean architecture without breaking existing behavior?

Refactor ASP.NET Core Web API projects into clean architecture by separating Domain, Application, Infrastructure, and API layers. This preserves behavior while moving business logic out of controllers into a maintainable, testable structure.

How do I move EF Core DbContext calls out of my API controllers?

Move EF Core DbContext calls out of controllers by isolating persistence within the Infrastructure layer. Expose data access via Domain interfaces, keeping controllers thin and free from direct database dependencies.

How do I implement CQRS with MediatR in an ASP.NET Core clean architecture project?

Implement CQRS with MediatR by defining Commands and Queries in the Application layer with co-located handlers and validators. Controllers simply send MediatR requests and return DTOs without containing business logic.

What are the dependency rules for clean architecture in ASP.NET Core?

Clean architecture enforces strict dependency-direction rules where dependencies flow inward. The Domain layer has zero framework dependencies, while Infrastructure and API layers depend on Application and Domain.

Can I use this clean architecture refactor for an ASP.NET Core 8 codebase with scattered business logic?

Yes, apply this to ASP.NET Core 8+ codebases where business logic is scattered. It generates a phased refactor plan that establishes clean architecture layers and MediatR use cases for safer evolution.

Why should I keep EF Core configurations inside the Infrastructure layer?

Keep EF Core DbContext, repository implementations, and entity configurations inside Infrastructure to isolate persistence details. This prevents database concerns from leaking into Domain or Application layers.