dotnet-cqrs-api

Standardize CQRS-based .NET APIs with MediatR, FluentValidation, and Carter.

Updated Jan 8, 2026
One-click install
npx skills add https://github.com/alanben/ClaudeSkills --skill dotnet-cqrs-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-cqrs-api
Source: https://github.com/alanben/ClaudeSkills/tree/main/dotnet-cqrs-api
Command: npx skills add https://github.com/alanben/ClaudeSkills --skill dotnet-cqrs-api

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Solve complex API design by standardizing CQRS-based .NET APIs.

Core Features & Use Cases

  • Architecture guidance for vertical slice APIs using CQRS with MediatR, FluentValidation, and Carter.
  • Clear command/query patterns with Add, Update, Get, and List operations.
  • Validation, error handling via Result<T>, and OpenAPI metadata integration.
  • Real-world guidance on testing, DI, and platform-agnostic API design.

Quick Start

  • Load the SKILL.md into Claude as a new dotnet-cqrs-api skill.
  • Use it to design, implement, and review CQRS-based.NET APIs in your projects.
  • Example prompt: "Show me how to implement a Get feature for a Customer using CQRS with MediatR and Carter."

Frequently Asked Questions about dotnet-cqrs-api

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

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

Structure .NET CQRS APIs by organizing code into feature-based vertical slices using MediatR for command and query dispatch, Carter for endpoint routing, and FluentValidation for handler-level validation. This approach standardizes Add, Get, List, and Update operations across features.

What is the best way to handle errors in a MediatR-based .NET API?

Handle errors in MediatR-based .NET APIs by enforcing a Result<T> error model throughout your handlers. This pattern standardizes validation failures and domain errors, returning consistent typed results instead of throwing exceptions across your CQRS operations.

Does Carter work with MediatR and FluentValidation for building minimal APIs?

Carter works with MediatR and FluentValidation to build minimal APIs by handling endpoint routing while MediatR manages command and query dispatch, and FluentValidation executes validation logic directly inside handlers for each vertical slice.

How do I implement dependency injection in a vertical slice .NET API?

Implement dependency injection in vertical slice .NET APIs using constructor-based injection within your MediatR handlers. This approach keeps each feature slice self-contained while maintaining testability and platform-agnostic API design across your CQRS architecture.

How do I add OpenAPI metadata to endpoints in a Carter-based .NET API?

Add OpenAPI metadata to Carter-based .NET API endpoints by defining documentation directly within your endpoint definitions. This ensures each vertical slice exposes its own API contracts, covering all Add, Get, List, and Update operations consistently.

When should I use vertical slice architecture instead of traditional layered architecture for .NET CQRS APIs?

Use vertical slice architecture for .NET CQRS APIs when you want to group related commands, queries, and handlers by feature rather than technical concern. This reduces cross-cutting dependencies and simplifies testing compared to traditional layered designs.