cqrs-command

Implements CQRS commands and handlers for state-mutating operations in .NET microservices.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Backend developers repeatedly write Create, Update, Delete, and Restore operations across microservices, and inconsistent implementations lead to missing validation, broken transactions, and soft-delete bugs. This Skill enforces one strict, proven pattern for every mutating operation. ## Core Features & Use Cases - Standardized Command Structure: Generates {Entity}{Action}Command and {Entity}{Action}CommandHandler files in the correct folder layout with exact naming conventions. - Built-in Validation & Transactions: Implements IValidatable for field-level error collection and IUnitOfWork transaction handling with commit/rollback logic. - Soft Delete & Restore Patterns: Encodes the project's interceptor-based soft delete, cascade delete ordering, and the mandatory !x.IsDeleted query filter. - Use Case: When asked to add a "create battery" endpoint to BatteryService, the Skill produces a validated command, a transactional handler checking for duplicates, and a CommonResponse<BatteryDTO> result — all matching the codebase conventions. ## Quick Start Ask the AI to create a CQRS command and handler for a new mutating operation, such as adding an Update command for the Battery entity in the backend service.

Frequently Asked Questions about cqrs-command

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

FAQPage Schema
How do I create a CQRS command and handler in a .NET microservice?▼

Create a folder Application/Commands/{Entity}{Action}/ containing a Command class implementing IRequest and IValidatable, plus a Handler class implementing IRequestHandler. The handler uses IUnitOfWork for repository access and transaction management, returning a CommonResponse-wrapped result.

How to implement soft delete and restore in Entity Framework repositories?▼

Call DeleteAsync on the repository without await; an interceptor automatically sets IsDeleted=true and DeletedAt to the current UTC time. To restore, set IsDeleted=false and DeletedAt=null, then call UpdateAsync. Always filter queries with Where(x => !x.IsDeleted) since no global query filter exists.

Why should I not await UpdateAsync or DeleteAsync repository methods?▼

In this pattern, UpdateAsync and DeleteAsync return void and only mark the entity state in the change tracker, so awaiting them causes compile errors. Only AddAsync and CommitTransactionAsync are truly asynchronous and require await.

How do I handle validation in CQRS commands without FluentValidation?▼

Implement IValidatable<TResponse> on the command and write a ValidateAsync method that adds field-level errors to response.ListErrors. If any errors exist, set IsSuccess to false and return the response before the handler executes.

When should I use transactions in a command handler?▼

Use BeginTransactionAsync and CommitTransactionAsync whenever the handler writes to the database, wrapping the operations in try/catch. On exception, call RollbackTransactionAsync and return a failed CommonResponse with the error message.