Help us improve
Share bugs, ideas, or general feedback.
From system-design
Separate command (write) and query (read) models for complex domains. Use when read/write patterns diverge significantly or when audit/consistency requirements demand immutability.
npx claudepluginhub sethdford/claude-skills --plugin architect-system-designHow this skill is triggered — by the user, by Claude, or both
Slash command
/system-design:cqrs-designThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implement Command Query Responsibility Segregation (CQRS) to align data models with actual usage patterns and enable independent scaling of reads and writes.
Implements CQRS (Command Query Responsibility Segregation) for scalable architectures. Use when separating read/write models, optimizing query performance, or building event-sourced systems.
Guides implementing CQRS to separate read and write models, optimize query performance, and build event-sourced systems.
Share bugs, ideas, or general feedback.
Implement Command Query Responsibility Segregation (CQRS) to align data models with actual usage patterns and enable independent scaling of reads and writes.
You are designing or refactoring a system with complex read and write patterns. The user faces performance issues, audit requirements, or divergent read/write needs. Read their current data access patterns.
Based on Greg Young's CQRS work and Fowler's research:
Analyze Read vs Write: List all queries used; identify divergences from write model. Example: commands work with Orders (with line items), but queries need denormalized OrderSummary (customer name, total, status).
Design Command Model: Optimize for consistency and rule enforcement. Aggregate should protect invariants. Example: Order aggregate ensures total ≥ sum of items.
Design Read Models: For each query pattern, denormalize to minimize joins. Example: OrderSummary includes customer name (copied from command), total (calculated), status (current).
Define Synchronization: How does read model stay updated? Options:
Handle Eventual Consistency: Users must accept slight staleness. Define lag threshold (e.g., reads lag writes by max 2 seconds). Show stale data indicator if lag exceeds threshold.