一键导入
cqrs-mediatr-guidelines
Apply project CQRS conventions for commands, queries, handlers, validators, caching, and specification-driven reads.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Apply project CQRS conventions for commands, queries, handlers, validators, caching, and specification-driven reads.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run the canonical build plus all nine per-project test commands from docs/TESTING.md. Never uses solution-level dotnet test.
Create or re-baseline lean, repository-grounded implementation plans and persistent dev docs when users ask for an implementation plan, technical plan, feature plan, refactor plan, or dev-docs workstream.
Senior CTO review workflow for repository-grounded implementation-plan workstreams used before coding.
Apply project EF Core conventions for repositories, DbContext setup, query filters, migrations, and seeded lookup data.
Create a self-contained HTML artifact focused on a high-quality SVG architecture or system diagram with minimal supporting prose.
Create a pragmatic self-contained HTML plan that organizes the user's plan content visually without expanding the scope unnecessarily.
| name | cqrs-mediatr-guidelines |
| description | Apply project CQRS conventions for commands, queries, handlers, validators, caching, and specification-driven reads. |
| type | pattern |
| enforcement | suggest |
| priority | high |
Use this skill when shaping Application-layer requests, handlers, validators, and response contracts. It keeps MediatR flows predictable and consistent with repository, caching, and DTO-mapping rules.
**/*Command.cs, **/*Query.cs, **/*Handler.cs, **/*Validator.cs, Explore.Application/**/*.cs.add-cqrs-handler, add-get-endpoint, add-write-endpoint, update-repository-query.BaseCommandResponse<Guid> for create or update work or bool for many deletes, while queries return DTOs or PaginatedResult<TDto>.IValidator<T> through DI.CancellationToken end to end and use HybridCache with GetOrCreateAsync for queries and RemoveAsync for command invalidation.IQuerySpecification<T> and immutable fluent composition via And(...) live in Application, while repositories apply the specification to IQueryable<T>.IValidator<T> through DI breaks the project validation standard and weakens handler-local control.ExploreDbContext directly in handlers bypasses repository abstractions and couples Application to EF Core.IQueryable from repositories leaks EF concerns into Application and lets handlers compose persistence logic ad hoc.public sealed record GetEventByIdQuery(Guid Id);
public sealed class GetEventByIdHandler(IEventRepository repository, HybridCache cache)
{
public async Task<EventDto?> Handle(GetEventByIdQuery request, CancellationToken cancellationToken)
{
var validator = new GetEventByIdQueryValidator();
await validator.ValidateAndThrowAsync(request, cancellationToken);
return await cache.GetOrCreateAsync(
$"events:{request.Id}",
async token =>
{
Event? entity = await repository.GetByIdAsync(request.Id, token);
return entity is null ? null : new EventDto(entity.Id, entity.Title);
},
cancellationToken: cancellationToken);
}
}
IQuerySpecification<Event> spec = EventQuerySpecification.Create()
.WithPublishedOnly()
.And(EventQuerySpecification.Create().WithTenant(tenantId))
.And(EventQuerySpecification.Create().WithSearch(searchTerm));
dotnet test --project Event.Architecture.Tests/Event.Architecture.Tests.csproj --configuration Release --verbosity quiet --filter FullyQualifiedName~Event.Architecture.Tests.CqrsPatternTestsdotnet test --project Event.Application.UnitTests/Event.Application.UnitTests.csproj --configuration Release --verbosity quietdotnet build --configuration Release --verbosity quiet