scaffold-cqrs-command

Generates CQRS command and handler classes with MediatR, UnitOfWork, and transaction handling.

1|Updated Apr 27, 2026
One-click install
npx skills add https://github.com/GSU26SE55/backend --skill scaffold-cqrs-command-gsu26se55
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: scaffold-cqrs-command
Source: https://github.com/GSU26SE55/backend/tree/main/.claude/skills/dev/be/scaffold-cqrs-command
Command: npx skills add https://github.com/GSU26SE55/backend --skill scaffold-cqrs-command-gsu26se55

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing CQRS command and handler boilerplate for Create, Update, Delete, and Restore operations is repetitive and error-prone, especially around transaction boundaries, soft-delete rules, and async/await conventions in a .NET microservice codebase. ## Core Features & Use Cases - Command Scaffolding: Generates a MediatR command class implementing IValidatable with error-collection validation that gathers all field errors instead of failing early. - Handler Templates for Four Actions: Produces Create, Update, Delete (soft delete with cascade to children), and Restore handlers using IServiceUnitOfWork with explicit BeginTransaction/Commit/Rollback patterns. - Convention Enforcement: Encodes critical rules such as UpdateAsync/DeleteAsync being void (no await), AddAsync requiring await, and publishing events only after CommitTransactionAsync. - Use Case: When adding a new Battery entity to BatteryService, run the scaffold to instantly get a compliant Create command and handler wired to the UnitOfWork transaction pattern. ## Quick Start Ask the AI to scaffold a CQRS Create command and handler for the Battery entity in BatteryService using the scaffold-cqrs-command skill.

Frequently Asked Questions about scaffold-cqrs-command

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

FAQPage Schema
How do I scaffold a CQRS command and handler with MediatR?▼

Invoke the skill with the service name, entity name, and action (Create, Update, Delete, or Restore). It generates a command class implementing IRequest and IValidatable, plus a handler using IServiceUnitOfWork with transaction management.

How to implement soft delete with cascade in a CQRS handler?▼

Load the entity with its children via Include, delete each child first, then call DeleteAsync on the parent inside a transaction. An interceptor sets IsDeleted to true, and CommitTransactionAsync persists all changes atomically.

Why should I not await UpdateAsync or DeleteAsync in this pattern?▼

UpdateAsync and DeleteAsync are void methods in this UnitOfWork design, so awaiting them causes compile errors. Only AddAsync is asynchronous and requires await; changes are persisted when CommitTransactionAsync calls SaveChangesAsync internally.

When should domain events be published in a MediatR handler?▼

Publish events after CommitTransactionAsync succeeds, unless the service implements the Outbox pattern. Publishing before commit risks emitting events for transactions that later roll back.

How does validation work in the generated command class?▼

The command implements IValidatable with a ValidateAsync method that collects all field errors into a ListErrors collection rather than failing on the first error. If any errors exist, IsSuccess is set to false and the full error list is returned.