dotnet-create-command-query
Skill1 starsChanged todayMITView on GitHub
Create a CQRS command (with handler and validator) or query (with handler and response) in a .NET module, returning Result, named <Verb><Entity>Command/Query, plus the endpoint that sends it. Use when adding a use case, an endpoint or a read model to a module's Application layer.
In this repository84 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/angular-coding-style.mdcCursor rule
- .cursor/rules/angular-patterns.mdcCursor rule
- .cursor/rules/angular-security.mdcCursor rule
- .cursor/rules/angular-testing.mdcCursor rule
- .cursor/rules/common-code-review.mdcCursor rule
- .cursor/rules/common-coding-style.mdcCursor rule
- .cursor/rules/common-development-workflow.mdcCursor rule
- .cursor/rules/common-security.mdcCursor rule
- .cursor/rules/common-testing.mdcCursor rule
- .cursor/rules/csharp-coding-style.mdcCursor rule
- .cursor/rules/csharp-data-access.mdcCursor rule
- .cursor/rules/csharp-patterns.mdcCursor rule
- .cursor/rules/csharp-security.mdcCursor rule
- .cursor/rules/csharp-testing.mdcCursor rule
- .cursor/rules/design-design-system.mdcCursor rule
- .cursor/rules/project-backend.mdcCursor rule
- .cursor/rules/project-security.mdcCursor rule
- .cursor/rules/project-testing.mdcCursor rule
- .cursor/rules/project-web.mdcCursor rule
- .cursor/rules/typescript-coding-style.mdcCursor rule
- .cursor/rules/typescript-patterns.mdcCursor rule
- .cursor/rules/typescript-security.mdcCursor rule
- .cursor/rules/typescript-testing.mdcCursor rule
- angular-guideSkill
- break-uiSkill
- dotnet-create-entitySkill
- dotnet-create-moduleSkill
- dotnet-ef-migrationSkill
- emil-design-engSkill
- frontend-designSkill
- impeccableSkill
- review-animationsSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- ui-ux-pro-maxSkill
- angular-guideSkill
- break-uiSkill
- dotnet-create-command-querySkill
- dotnet-create-entitySkill
- dotnet-create-moduleSkill
- dotnet-ef-migrationSkill
- emil-design-engSkill
- frontend-designSkill
- impeccableSkill
- review-animationsSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-implementSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Test first: the handler test (success and each Error) and, for a new endpoint, an HTTP test through WebApplicationFactory.
- Very specific: line 65
Update: load by id (tenant-filtered), NotFound error when missing, call entity methods, save.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a command or a query
Inputs: command or query, verb (Create, Update, Archive, Get, List, Search...), entity, module.
First read one existing command and one query in the same module and copy their shape: mediator interfaces
(ICommand<T>/IQuery<T>/ISender, or MediatR's), Result type, how handlers reach data (repository + unit of
work, or the module's DbContext for reads), how endpoints map a Result to HTTP.
Test first: the handler test (success and each Error) and, for a new endpoint, an HTTP test through
WebApplicationFactory.
Layout
src/Modules/<Module>/<Module>.Application/<Entity>/<Verb>/
<Verb><Entity>Command.cs or <Verb><Entity>Query.cs
<Verb><Entity>CommandHandler.cs <Verb><Entity>QueryHandler.cs
<Verb><Entity>CommandValidator.cs <Entity>Response.cs (sealed record), if not sharedCommand
namespace <Module>.Application.<Entity>.Create;
public sealed record Create<Entity>Command(string Name) : ICommand<Guid>; // ICommand (no value) for Update/Delete
internal sealed class Create<Entity>CommandHandler(
I<Entity>Repository repository,
IUnitOfWork unitOfWork) : ICommandHandler<Create<Entity>Command, Guid>
{
public async Task<Result<Guid>> Handle(Create<Entity>Command command, CancellationToken cancellationToken)
{
bool exists = await repository.ExistsByNameAsync(command.Name, cancellationToken);
if (exists)
{
return Result.Failure<Guid>(<Entity>Errors.DuplicateName(command.Name));
}
Result<<Entity>> created = <Entity>.Create(command.Name);
if (created.IsFailure)
{
return Result.Failure<Guid>(created.Error);
}
repository.Add(created.Value);
await unitOfWork.SaveChangesAsync(cancellationToken);
return created.Value.Id; // the repo's public id if it has one
}
}
internal sealed class Create<Entity>CommandValidator : AbstractValidator<Create<Entity>Command>
{
public Create<Entity>CommandValidator()
{
RuleFor(c => c.Name).NotEmpty().MaximumLength(<Entity>.MaxNameLength);
}
}Update: load by id (tenant-filtered), NotFound error when missing, call entity methods, save. Delete or archive:
the same, with the entity's method. Validators check shape; the domain checks business rules.
Query
namespace <Module>.Application.<Entity>.List;
public sealed record List<Entity>Query(int Page = 1, int PageSize = 20) : IQuery<PagedResult<<Entity>Response>>;
internal sealed class List<Entity>QueryHandler(<Module>DbContext db)
: IQueryHandler<List<Entity>Query, PagedResult<<Entity>Response>>
{
public async Task<Result<PagedResult<<Entity>Response>>> Handle(List<Entity>Query query, CancellationToken cancellationToken)
{
IQueryable<<Entity>> source = db.<Entity>s.AsNoTracking(); // tenant filter is global
int total = await source.CountAsync(cancellationToken);
List<<Entity>Response> items = await source
.OrderBy(e => e.Name)
.Skip((query.Page - 1) * query.PageSize)
.Take(query.PageSize)
.Select(e => new <Entity>Response(e.Id, e.Name, e.Status.ToString()))
.ToListAsync(cancellationToken);
return new PagedResult<<Entity>Response>(items, total, query.Page, query.PageSize);
}
}
public sealed record <Entity>Response(Guid Id, string Name, string Status);Queries: AsNoTracking, projection, pagination, sort fields from an allow-list, NotFound for a missing single
item. A query never changes state.
Endpoint
[HttpPost]
public async Task<IActionResult> Create(Create<Entity>Command command, CancellationToken cancellationToken)
{
Result<Guid> result = await sender.Send(command, cancellationToken);
return result.Match(Ok, CustomResults.Problem); // the repo's Result-to-HTTP mapping
}Inject ISender. Prefer the repo's existing Match/Problem mapping; avoid CreatedAtAction link generation if
the repo's versioned routes break it (return Ok with the id instead).
Checklist
- Names
<Verb><Entity>Command|Queryand...Handler/...Validator - Returns
Result/Result<T>; failures are typedErrors - Handler uses only its own module's data access
- Tests first; gate passes
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

