Generate Shiny Mediator handlers, contracts, middleware, and scaffold projects for .NET applications
View on GitHubshinyorg/mediator
shiny-mediator
February 2, 2026
Select agents to install to:
npx add-skill https://github.com/shinyorg/mediator/blob/main/skills/shiny-mediator/SKILL.md -a claude-code --skill shiny-mediatorInstallation paths:
.claude/skills/shiny-mediator/# Shiny Mediator Skill
You are an expert in Shiny Mediator, a mediator pattern library for .NET applications.
## When to Use This Skill
Invoke this skill when the user wants to:
- Create request handlers, command handlers, event handlers, or stream handlers
- Generate contracts (IRequest, ICommand, IEvent, IStreamRequest)
- Add middleware (caching, resilience, validation, offline)
- Scaffold ASP.NET, MAUI, or Blazor projects with Shiny Mediator
- Configure Shiny Mediator in their application
- Migrate from MediatR to Shiny Mediator
## Library Overview
**Documentation**: https://shinylib.net/mediator
Shiny Mediator is AOT & trimming friendly, using source generators for automatic DI registration.
### Core Patterns
| Pattern | Contract | Handler | Usage |
|---------|----------|---------|-------|
| Request | `IRequest<TResult>` | `IRequestHandler<TRequest, TResult>` | Queries returning data |
| Command | `ICommand` | `ICommandHandler<TCommand>` | Void state changes |
| Event | `IEvent` | `IEventHandler<TEvent>` | Pub/sub notifications |
| Stream | `IStreamRequest<TResult>` | `IStreamRequestHandler<TRequest, TResult>` | IAsyncEnumerable |
### Handler Registration
Always use registration attributes:
```csharp
[MediatorSingleton] // Stateless handlers
[MediatorScoped] // Handlers needing per-request services (DbContext)
```
**Critical: Partial Class Requirement**
When using **any middleware attribute** (`[Cache]`, `[OfflineAvailable]`, `[Resilient]`, `[MainThread]`, `[TimerRefresh]`), the handler class **must be declared as `partial`**:
```csharp
[MediatorSingleton]
public partial class MyHandler : IRequestHandler<MyRequest, MyResult> // partial required!
{
[Cache(AbsoluteExpirationSeconds = 60)]
public Task<MyResult> Handle(...) { }
}
```
This enables the source generator to create the `IHandlerAttributeMarker` implementation. Without `partial`, you'll get error `SHINY001`.
### Basic Setup
**ASP.NET:**
```csharp
builder.Services.AddShinyMediat