pipeline-behaviors

Automate MediatR pipeline behaviors for logging, validation, and caching in .NET 8+.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/hiiamsky/multi-agent-dev-team --skill pipeline-behaviors-hiiamsky
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pipeline-behaviors
Source: https://github.com/hiiamsky/multi-agent-dev-team/tree/main/.github/skills/dotnet-pipeline-behaviors
Command: npx skills add https://github.com/hiiamsky/multi-agent-dev-team --skill pipeline-behaviors-hiiamsky

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cross-cutting concerns across MediatR handlers are traditionally scattered and error-prone. This skill provides a cohesive, reusable set of behaviors to implement logging, validation, exception handling, transactions, caching, and performance monitoring.

Core Features & Use Cases

  • Logging: Centralized request/response logging with timing.
  • Validation: Request validation before handler execution.
  • Exception Handling: Convert exceptions to consistent results.
  • Transaction: Wrap command handlers in database transactions where applicable.
  • Caching: Cache query results to improve performance.
  • Performance: Detect and log slow operations for observability.

Quick Start

Register the MediatR pipeline behaviors in your DI container to enable logging, validation, exception handling, caching, and performance monitoring across all handlers.

Frequently Asked Questions about pipeline-behaviors

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

FAQPage Schema
How do I handle cross-cutting concerns like logging and validation in MediatR?

Cross-cutting concerns in MediatR are handled using pipeline behaviors. This approach provides ready-to-use behaviors for logging, validation, exception handling, and caching, centralizing these tasks instead of scattering them across individual handlers.

What is the best way to implement caching and performance monitoring for MediatR queries?

The best way to implement caching and performance monitoring for MediatR queries is through pipeline behaviors. They automatically wrap handler execution to cache query results and detect slow operations for observability.

Does the MediatR pipeline behaviors skill support .NET 8 applications?

Yes, the MediatR pipeline behaviors are applicable to .NET 8+ applications. They integrate directly with dependency injection registration to ensure correct outer-to-inner execution order for commands and queries.

How do I ensure correct execution order for MediatR pipeline behaviors?

To ensure correct execution order for MediatR pipeline behaviors, they must be registered correctly in your dependency injection container. This skill implements open generic behaviors and enforces non-modification of requests to maintain proper outer-to-inner execution.

Can I wrap MediatR command handlers in database transactions automatically?

Yes, you can automatically wrap MediatR command handlers in database transactions using pipeline behaviors. This centralizes transaction management across applicable commands without modifying the core handler logic.

Why does my MediatR request validation fail before reaching the handler?

Request validation fails before reaching the handler when a validation pipeline behavior intercepts the execution. This behavior validates requests prior to handler execution, ensuring invalid commands and queries are stopped early in the pipeline.