vertical-slice

Structure .NET API features into slices with endpoints, DTOs, validators, and handlers.

4|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/zdanovichnick/dotnet-pilot --skill vertical-slice-zdanovichnick
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vertical-slice
Source: https://github.com/zdanovichnick/dotnet-pilot/tree/main/skills/vertical-slice
Command: npx skills add https://github.com/zdanovichnick/dotnet-pilot --skill vertical-slice-zdanovichnick

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Vertical slice architecture prevents .NET codebases from collapsing back into layered, hard-to-maintain structures by ensuring each feature owns its endpoints, contracts, validation, and behavior.

Core Features & Use Cases

  • Feature-first folder structure: Organizes code by use-case (slice) instead of technical layer, reducing coupling and making changes localized.
  • IEndpointGroup-based routing: Enables each feature to register its own endpoints cleanly and consistently in Program.cs.
  • Per-feature DTOs and validation: Uses records for request/response types and FluentValidation per request to keep contracts isolated and enforce correctness early.
  • Slice-focused testing guidance: Supports both full-stack slice tests (WebApplicationFactory) and handler-level unit tests without brittle DbContext mocking.

Quick Start

Use the vertical-slice skill to restructure your API by creating one folder per feature (e.g., Orders/CreateOrder), moving the endpoint, request/response DTOs, validator, and handler together, and then registering all IEndpointGroup implementations from Program.cs.

Frequently Asked Questions about vertical-slice

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

FAQPage Schema
How do I structure a .NET API using vertical slice architecture?

Vertical slice architecture organizes .NET APIs by creating one folder per feature, moving endpoints, request/response DTOs, validators, and handlers together to reduce coupling and localize changes.

What is the best way to avoid layered coupling in CRUD-heavy .NET APIs?

Vertical slice architecture prevents .NET codebases from collapsing into layered structures by ensuring each feature owns its endpoints, contracts, validation, and behavior independently.

How do I register endpoints per feature in a .NET Web API?

You register endpoints per feature by implementing an IEndpointGroup pattern for route registration, allowing each feature slice to cleanly and consistently register its own endpoints in Program.cs.

How do you handle validation in a vertical slice .NET API?

Validation in a vertical slice .NET API is handled per request using FluentValidation wiring alongside records-based per-slice DTOs, keeping contracts isolated and enforcing correctness early.

How do I test vertical slices in a .NET Web API without mocking DbContext?

You test vertical slices using slice-oriented testing approaches like full-stack slice tests with WebApplicationFactory and handler-level unit tests, avoiding brittle DbContext mocking.

Does vertical slice architecture work for .NET APIs with many aggregates per feature?

Vertical slice architecture typically applies to CRUD-heavy HTTP APIs where ≤10 aggregates per feature is standard, ensuring feature isolation while maintaining cross-cutting concerns through endpoint filters.