net-cqrs
БесплатноБез исполняемых скриптовНе проверенImplement CQRS pattern with MediatR for .NET applications
от mitkox★ 190 звёзд на GitHubОб этом скилле
What I Do
I help you implement CQRS (Command Query Responsibility Segregation):
- Command handlers for mutations
- Query handlers for reads
- MediatR pipeline configuration
- Validation with FluentValidation
- Domain events publishing
- Event sourcing basics
When to Use Me
Use this skill when:
- Implementing CQRS architecture
- Setting up MediatR in a Clean Architecture project
- Creating command and query handlers
- Separating read and write models
- Publishing domain events
Packages Required
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
Command Structure
Base Command
using MediatR;
public interface ICommand<out TResult> : IRequest<TResult>
{
}
public interface ICommandHandler<in TCommand, TResult> : IRequestHandler<TCommand, TResult>
where TCommand : ICommand<TResult>
{
}
Command Example
public record CreateOrderCommand(
Guid CustomerId,
List<OrderItemDto> Items,
string ShippingAddress
) : ICommand<OrderDto>;
public class CreateOrderCommandHandler : ICommandHandler<CreateOrderCommand, OrderDto>
{
private readonly IOrderRepository _orderRepository;
private readonly IMapper _mapper;
private readonly IPublisher _publisher;
public CreateOrderCommandHandler(
IOrderRepository orderRepository,
IMapper mapper,
IPublisher publisher)
{
_orderRepository = orderRepository;
_mapper = mapper;
_publisher = publisher;
}
public async Task<OrderDto> Handle(
CreateOrderCommand request,
CancellationToken cancellationToken)
{
var order = Order.Create(
request.CustomerId,
request.Items.Select(i => new OrderItem(i.ProductId, i.Quantity, i.Price)),
request.ShippingAddress);
await _orderRepository.AddAsync(order, cancellationToken);
// Publish domain events
foreach (var domainEvent in order.DomainEvents)
{
await _publisher.Publish(domainEvent, cancellationToken);
}
order.ClearDomainEvents();
return _mapper.Map<OrderDto>(order);
}
}
Command Validator
public class CreateOrderCommandValidator : AbstractValidator<CreateOrderCommand>
{
public CreateOrderCommandValidator()
{
RuleFor(x => x.CustomerId)
.NotEmpty()
.WithMessage("Customer ID is required");
RuleFor(x => x.Items)
.NotEmpty()
.WithMessage("At least one item is required");
RuleForEach(x => x.Items)
.ChildRules(item =>
{
item.RuleFor(x => x.Quantity)
.GreaterThan(0)
.WithMessage("Quantity must be greater than 0");
item.RuleFor(x => x.Price)
.GreaterThan(0)
.WithMessage("Price must be greater than 0");
});
RuleFor(x => x.ShippingAddress)
.NotEmpty()
.MaximumLength(500)
.WithMessage("Shipping address is required (max 500 characters)");
}
}
Query Structure
Base Query
using MediatR;
public interface IQuery<out TResult> : IRequest<TResult>
{
}
public interface IQueryHandler<in TQuery, TResult> : IRequestHandler<TQuery, TResult>
where TQuery : IQuery<TResult>
{
}
Query Example
public record GetOrderByIdQuery(Guid OrderId) : IQuery<OrderDto?>;
public class GetOrderByIdQueryHandler : IQueryHandler<GetOrderByIdQuery, OrderDto?>
{
private readonly IOrderReadRepository _orderReadRepository;
private readonly IMapper _mapper;
public GetOrderByIdQueryHandler(
IOrderReadRepository orderReadRepository,
IMapper mapper)
{
_orderReadRepository = orderReadRepository;
_mapper = mapper;
}
public async Task<OrderDto?> Handle(
GetOrderByIdQuery request,
CancellationToken cancellationToken)
{
var order = await _orderReadRepository.GetByIdAsync(
request.OrderId,
cancellationToken);
return order is null ? null : _mapper.Map<OrderDto>(order);
}
}
Paginated Query
public record GetOrdersQuery(
Guid? CustomerId,
DateTime? FromDate,
DateTime? ToDate,
int Page = 1,
int PageSize = 10
) : IQuery<PaginatedList<OrderSummaryDto>>;
public class GetOrdersQueryHandler : IQueryHandler<GetOrdersQuery, PaginatedList<OrderSummaryDto>>
{
private readonly IOrderReadRepository _repository;
public GetOrdersQueryHandler(IOrderReadRepository repository)
{
_repository = repository;
}
public async Task<PaginatedList<OrderSummaryDto>> Handle(
GetOrdersQuery request,
CancellationToken cancellationToken)
{
retur
Установить net-cqrs в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл net-cqrs?
Implement CQRS pattern with MediatR for .NET applications
Как установить скилл net-cqrs?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл net-cqrs запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic