dotnet-mediatr

Implement the MediatR mediator pattern in .NET for decoupled request handling.

4|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/Heldinhow/awesome-opencode-dev-skills --skill dotnet-mediatr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-mediatr
Source: https://github.com/Heldinhow/awesome-opencode-dev-skills/tree/main/dotnet-mediatr
Command: npx skills add https://github.com/Heldinhow/awesome-opencode-dev-skills --skill dotnet-mediatr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the complexity of managing direct method calls and tightly coupled components in .NET applications by implementing the MediatR mediator pattern for decoupled request handling.

Core Features & Use Cases

  • Decoupled Request Handling: Enables communication between components without direct dependencies.
  • CQRS Implementation: Facilitates the separation of command and query responsibilities.
  • Pipeline Behaviors: Allows for the implementation of cross-cutting concerns like logging, validation, and authorization in a centralized manner.
  • Use Case: When building a new feature that requires validating user input before processing a command, you can use MediatR's pipeline behaviors to add a validation step that runs automatically before the command handler is invoked.

Quick Start

Add the MediatR packages to your .NET project using the dotnet add package command.

Frequently Asked Questions about dotnet-mediatr

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

FAQPage Schema
How do I decouple request handling in .NET applications?

To decouple request handling in .NET, you implement the MediatR mediator pattern, which separates request senders from receivers. This eliminates direct method calls and tightly coupled components by routing requests through a centralized mediator.

What is the best way to implement CQRS in .NET?

The best way to implement CQRS in .NET is using the MediatR pattern to separate command and query responsibilities. This architecture divides data mutation operations from data retrieval operations, allowing distinct handlers for each request type without direct coupling.

How do I add cross-cutting concerns like validation to .NET request handling?

You add cross-cutting concerns like validation to .NET request handling by implementing MediatR pipeline behaviors. Pipeline behaviors automatically execute logging, validation, or authorization steps before the target command handler processes the request.

Do I need to install additional packages to use MediatR in .NET?

Yes, you need to install MediatR and its dependency injection extensions to use MediatR in .NET. These packages are required to integrate the mediator pattern into your application's dependency injection container using the dotnet add package command.

When should I use the mediator pattern in .NET?

You should use the mediator pattern in .NET when you need to manage complex component interactions and decouple request senders from receivers. It is particularly useful for CQRS architectures and centralizing cross-cutting concerns like logging and validation.

How does MediatR pipeline behavior work for automatic validation?

MediatR pipeline behaviors work by wrapping command handlers in a sequence of actions that execute before the main handler. When building a feature, you add a validation step to the pipeline that automatically runs and validates user input before the command handler is invoked.