一键导入
planforge-new-event-handler
Scaffold domain event types, handlers, and a MediatR-based publish/subscribe pipeline.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold domain event types, handlers, and a MediatR-based publish/subscribe pipeline.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run a comprehensive code review across architecture, security, testing, naming, and patterns. Invokes relevant reviewer agents in sequence. Use before merging features or at the end of a phase. With --quorum, dispatches multi-model analysis for higher confidence.
Audit UI components for WCAG 2.2 compliance, semantic HTML, ARIA labels, keyboard navigation, color contrast, and responsive design.
Audit API endpoints for backward compatibility, versioning, OpenAPI compliance, pagination, rate limiting, and RFC 9457 error responses.
Review code for architecture violations: layer separation, sync-over-async, missing CancellationToken, improper DI. Use for PR reviews or code audits.
Fix a bug using TDD: reproduce with a failing test first, then implement the fix, then verify. Prevents regressions.
Review CI/CD pipelines for best practices: environment promotion, secrets management, rollback strategies, build caching, and deployment safety.
| name | planforge-new-event-handler |
| description | Scaffold domain event types, handlers, and a MediatR-based publish/subscribe pipeline. |
| metadata | {"author":"plan-forge","source":".github/prompts/new-event-handler.prompt.md"} |
Scaffold domain events with typed handlers using MediatR notifications.
// Marker interface for domain events
public interface IDomainEvent : INotification
{
Guid EventId { get; }
DateTime OccurredAt { get; }
}
// Base record for convenience
public abstract record DomainEvent : IDomainEvent
{
public Guid EventId { get; } = Guid.NewGuid();
public DateTime OccurredAt { get; } = DateTime.UtcNow;
}
// Concrete event
public record OrderPlacedEvent(
Guid OrderId,
Guid CustomerId,
decimal TotalAmount) : DomainEvent;
public class OrderPlacedHandler : INotificationHandler<OrderPlacedEvent>
{
private readonly IEmailService _emailService;
private readonly ILogger<OrderPlacedHandler> _logger;
public OrderPlacedHandler(IEmailService emailService, ILogger<OrderPlacedHandler> logger)
{
_emailService = emailService;
_logger = logger;
}
public async Task Handle(OrderPlacedEvent notification, CancellationToken ct)
{
_logger.LogInformation("Handling OrderPlaced: {OrderId}", notification.OrderId);
await _emailService.SendOrderConfirmationAsync(notification.OrderId, ct);
}
}
public class OrderService
{
private readonly IMediator _mediator;
public async Task<Order> PlaceOrderAsync(CreateOrderRequest request, CancellationToken ct)
{
var order = new Order(request.CustomerId, request.Items);
await _repository.AddAsync(order, ct);
await _mediator.Publish(new OrderPlacedEvent(
order.Id, order.CustomerId, order.TotalAmount), ct);
return order;
}
}
// MediatR publishes to ALL registered handlers for an event
public class OrderPlacedAuditHandler : INotificationHandler<OrderPlacedEvent>
{
public async Task Handle(OrderPlacedEvent notification, CancellationToken ct)
{
// Write to audit log — runs independently of email handler
}
}
builder.Services.AddMediatR(cfg =>
cfg.RegisterServicesFromAssemblyContaining<Program>());
Events/ folder, handlers in EventHandlers/CancellationToken in all async handler methods