Mediatr domain event handler

From IntentArchitect/Intent.Modules.NET · View interactive version

Mediatr domain event handler is an AI agent skill from the GitHub repository IntentArchitect/Intent.Modules.NET. implement or revise jimmy bogard-style mediatr domain event handlers in clean architecture c# solutions. use when a domain event notification handler, outbox/integration-event reaction, projection update, notification side effect, audit side effect, or cross-aggregate follow-up is incomplete or inco

How to use this skill

Skill file

MediatR Domain Event Handler

Implement Jimmy Bogard-style domain event handlers in Clean Architecture. Favor existing patterns, domain language, and allowed abstractions over convenience shortcuts.

Core rules

Event-handler intent

Assume the common Bogard pattern:

  1. A command handler changes aggregate state.
  2. The aggregate raises a past-tense domain event.
  3. The unit of work or DbContext dispatches the event through MediatR.
  4. INotificationHandler<TEvent> reacts with follow-up work.

Do not move the original command decision into the event handler. The handler reacts to something that already happened.

Workflow

  1. Inspect the existing handler, request, response, validator, repository interfaces, and related domain types.
  2. Search for code usages of:
  1. Infer the intended business flow from the request shape, naming, surrounding domain model, and nearby feature implementations.
  2. Implement the Handle method using existing patterns first.
  3. If the handler needs missing DAL capabilities, extend the relevant repository abstraction in an allowed layer instead of pulling infrastructure into the handler.
  4. Add focused private helper methods when the flow becomes easier to read or test.
  5. Ensure cancellation tokens are threaded through async calls where applicable.
  6. Verify the final code preserves layer boundaries and does not introduce infrastructure leakage.

Side-effect guidance

Idempotency and data access

Error handling

Follow nearby handlers for stale events or missing data:

Do not invent a new result type for MediatR notification handlers.

Output expectations

Produce a concrete code update that completes or corrects the domain event handler, preserves the handler signature, extends allowed-layer abstractions only when needed, keeps infrastructure out of Application handlers, follows local patterns, and avoids unrelated changes.

Review checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.