Mediatr command handler

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

Mediatr command handler is an AI agent skill from the GitHub repository IntentArchitect/Intent.Modules.NET. Implements business logic in MediatR command handler Handle methods. MUST load before creating or editing any command handler e.g. *CommandHandler.cs.

How to use this skill

Skill file

MediatR Command Handler

Implement command handler business logic inside an existing handler file. Favor domain intent, existing code patterns, and clean layer boundaries over convenience shortcuts.

Core rules

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.

Command-specific guidance

Commands usually change state. Prefer patterns like these when supported by the surrounding codebase:

Repository extension guidance

When a needed repository capability is missing:

EF Related Data Loading guidance

Unit of Work guidance

Entity Framework repository guidance

Output expectations

Produce a concrete code update that:

Review checklist

Before finishing, check that:

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.