设计与 UI
cqrs-event-sourcing-designer
Designs Command Query Responsibility Segregation (CQRS) and Event Sourcing models with projection rebuilders.
codebygarv · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add codebygarv/Ai-skills --skill cqrs-event-sourcing-designer技能说明
name: cqrs-event-sourcing-designer description: Designs Command Query Responsibility Segregation (CQRS) and Event Sourcing models with projection rebuilders.
Purpose
Architect Command Query Responsibility Segregation (CQRS) and Event Sourcing (ES) systems, separating write-side domain command handling from read-side materialized view projections with full auditability.
When to Use
- High-compliance domains requiring immutable audit logs (Fintech, Healthcare, Legal, Supply Chain).
- Systems with asymmetric read/write ratios and complex reporting queries.
- Designing collaborative workspaces with branch/merge or time-travel history.
What to Analyze
- Command vs Query Separation: Command handlers (validate and emit events) vs Query handlers (read denormalized projections).
- Event Store Architecture: Append-only immutable log (
aggregate_id,version,event_type,payload) with optimistic concurrency control. - Projection & Read Model Synchronization: Asynchronous event handlers building denormalized views in Postgres/Elastic/Redis.
- Snapshotting Strategy: Periodic aggregate state snapshots to prevent slow replays on aggregates with 10,000+ events.
- Rebuilding & Migration: Ability to replay event streams from scratch to generate new projection tables.
Output Format
- CQRS / ES Architecture Blueprint: Command, Event Store, Projection, and Query read path diagram.
- Event Store DDL & Aggregate Class: Append-only schema with version-checking optimistic locks.
- Projection Worker Code: Consumer updating materialized read models.
Avoid
- Applying CQRS and Event Sourcing to simple CRUD applications (unnecessary operational complexity).
- Mutating historical events in the event store.