cqrs-mediatr

Coordinate CQRS components in .NET apps using MediatR with Autofac and FluentValidation.

Updated Apr 29, 2026
One-click install
npx skills add https://github.com/bbolek-ap/new-ai-native --skill cqrs-mediatr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cqrs-mediatr
Source: https://github.com/bbolek-ap/new-ai-native/tree/main/.claude/skills/cqrs-mediatr
Command: npx skills add https://github.com/bbolek-ap/new-ai-native --skill cqrs-mediatr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Coordinate CQRS components in a .NET app using MediatR to reduce boilerplate and ensure consistent patterns.

Core Features & Use Cases

  • Define Commands and Queries with MediatR using IRequest<T> and one Handler per command or query.
  • Place Validators next to commands and enforce a centralized, FluentValidation-based validation pipeline.
  • Use Autofac assembly scanning to register MediatR handlers and validators, with API endpoints dispatching to the mediator and returning RFC 7807 ProblemDetails on errors.

Quick Start

Create a new endpoint that dispatches a Create{Entity}Command through MediatR to trigger the appropriate handler.

Frequently Asked Questions about cqrs-mediatr

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

FAQPage Schema
How do I coordinate CQRS components in a .NET API using MediatR?

Use MediatR to dispatch commands and queries from minimal API endpoints to dedicated handlers. This enforces one handler per request and standardizes the validation pipeline, keeping business logic out of API endpoints.

How do I register MediatR handlers and validators automatically in .NET?

Register MediatR handlers and validators automatically using Autofac assembly scanning. This discovers and registers handlers across your .NET project, reducing manual boilerplate and ensuring all components are wired up consistently.

What is the best way to validate commands in a CQRS .NET application?

Validate commands in a CQRS .NET application using a centralized FluentValidation pipeline. Place validators next to commands and queries to enforce consistent validation rules before the MediatR handler executes the business logic.

How should a .NET API return validation errors for CQRS requests?

Return validation errors for CQRS requests using RFC 7807 ProblemDetails. When FluentValidation fails, the API pipeline intercepts the request and responds with standardized ProblemDetails error objects instead of executing the handler.

Can I use minimal API endpoints with MediatR without adding business logic?

Yes, use minimal API endpoints with MediatR to dispatch commands and queries without embedding business logic. Endpoints simply send the request to the mediator, which routes it to the appropriate handler for processing.