use-case-organization

Standardize use case folder and file organization in CQRS/MediatR .NET projects.

Updated Nov 2, 2025
One-click install
npx skills add https://github.com/YuriGarciaRibeiro/API-notifications --skill use-case-organization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: use-case-organization
Source: https://github.com/YuriGarciaRibeiro/API-notifications/tree/main/.codex/skills/use-case-organization
Command: npx skills add https://github.com/YuriGarciaRibeiro/API-notifications --skill use-case-organization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Standardizes the organization of use cases in application-layer CQRS/MediatR projects. It helps teams create, refactor, or review UseCases, Commands, Queries, Handlers, and Validators in .NET/C# projects.

Core Features & Use Cases

  • Standardized layout: UseCases/<CaseName>/ with Command.cs, Query.cs, Handler.cs, Validator.cs, and Response.cs following a consistent naming scheme.
  • Consistent naming and structure: Ensures folder and file names share prefixes for easy discovery and alignment across the codebase.
  • Guardrails and validation: Provides a concise checklist to verify structure, responsibilities, and separation of concerns.

Quick Start

Create a new UseCase folder under UseCases/<Name> and add the corresponding <Name>Command.cs, <Name>Query.cs, <Name>Handler.cs, <Name>Validator.cs, and <Name>Response.cs following the standard naming conventions.

Frequently Asked Questions about use-case-organization

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

FAQPage Schema
How do I organize use cases in a CQRS MediatR project?

Standardize CQRS use case organization by grouping Command.cs, Query.cs, Handler.cs, Validator.cs, and Response.cs files under a UseCases/<CaseName>/ directory. This enforces consistent naming prefixes and uniform separation of concerns across the .NET application layer.

What is the standard folder structure for CQRS commands and queries in .NET?

The standard CQRS folder structure uses UseCases/<CaseName>/ to group Command.cs, Query.cs, Handler.cs, Validator.cs, and Response.cs. This layout ensures shared naming prefixes for easy discovery and maintains uniform separation of concerns across the codebase.

How do I separate concerns when refactoring handlers and validators in clean architecture?

Separate concerns in clean architecture by isolating responsibilities: Handler.cs executes business logic, Validator.cs enforces rules, and Command.cs or Query.cs defines inputs. A consistency checklist verifies this structural separation and uniform responsibilities across files.

Does this CQRS use case structure work with existing .NET C# projects?

Yes, this CQRS use case structure works with existing .NET C# projects by guiding the refactoring of current UseCases, Handlers, and Validators. It applies standardized folder layouts and naming conventions without requiring external dependencies.

What is the best way to name files in a MediatR use case folder?

The best way to name files in a MediatR use case folder is to use shared prefixes matching the parent case name, producing files like <Name>Command.cs, <Name>Query.cs, and <Name>Handler.cs. This ensures alignment and easy discovery across the codebase.

Why does my CQRS use case structure lack consistency across the codebase?

CQRS use case structure lacks consistency due to mismatched folder and file names or unclear separation of concerns. Applying a standardized layout with a verification checklist for UseCases, Handlers, and Validators eliminates structural misalignment.