vertical-slice

Organize .NET Web API code into self-contained feature slices with MediatR and EF Core.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill vertical-slice-faysilalshareef
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vertical-slice
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/architecture/vertical-slice
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill vertical-slice-faysilalshareef

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Vertical Slice Architecture eliminates the complexity of layered projects by organizing code by feature so each capability is self-contained and easier to implement, test, and evolve. It prevents architecture drift and reduces the friction of AI-generated or human-written code that doesn't match project conventions.

Core Features & Use Cases

  • Organize features into single-file slices that include Request/Response types, Handler, and Validator for each operation to keep feature logic colocated.
  • Prefer direct DbContext usage and MediatR handlers over broad repository abstractions, register endpoint groups per feature, and extract shared code only after proven duplication.
  • Use case: Implement an Orders feature by adding CreateOrder, GetOrder, and ListOrders slices with endpoint group registration for clean routing and authorization.

Quick Start

Add a new feature slice file containing a Command, Handler, and Validator and register its endpoint group in Program.cs.

Frequently Asked Questions about vertical-slice

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

FAQPage Schema
What is vertical slice architecture in .NET Web API projects?

Vertical slice architecture organizes code by feature so each capability is self-contained and easier to implement, test, and evolve. It eliminates the complexity of layered projects by keeping Request/Response types, Handlers, and Validators colocated within single-file slices.

How do I structure a .NET feature slice using MediatR and EF Core?

To structure a feature slice, add a single file containing nested Command/Query, Handler, and Validator types. Use direct DbContext usage via MediatR handlers instead of repository abstractions, and register endpoint groups per feature in Program.cs for clean routing.

Do I need a repository pattern when using EF Core with vertical slices?

No, you should prefer direct DbContext usage with EF Core instead of broad repository abstractions. Vertical slice architecture encourages extracting shared code only after proven duplication, keeping feature logic self-contained without unnecessary wrapper layers.

Can I use endpoint group registration for feature slices in .NET?

Yes, you can register endpoint groups per feature in Program.cs. This approach provides clean routing and authorization boundaries for self-contained feature slices, ensuring each capability manages its own endpoints independently.

Vertical slice architecture vs layered architecture for .NET APIs?

Vertical slice architecture organizes code by feature to reduce coupling and prevent architecture drift, whereas layered projects separate concerns horizontally. Slices keep feature logic colocated, simplifying feature delivery and testing compared to navigating multiple layered folders.

When should I extract shared code in vertical slice architecture?

You should extract shared code only after proven duplication across feature slices. Vertical slice architecture minimizes shared dependencies intentionally, reducing coupling so that individual features like CreateOrder or GetOrder can evolve independently without broad refactoring.