cqrs-design
Separate command (write) and query (read) models for complex domains. Use when read/write patterns diverge significantly or when audit/consistency…
от sethdford★ 51 звезда на GitHub
Установить cqrs-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
CQRS Design
Implement Command Query Responsibility Segregation (CQRS) to align data models with actual usage patterns and enable independent scaling of reads and writes.
Context
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.
Domain Context
Based on Greg Young's CQRS work and Fowler's research:
- Command Side: Optimized for writes; enforces business rules; maintains single source of truth
- Query Side: Optimized for reads; denormalized for performance; eventual consistency acceptable
- Event Sourcing: Often paired with CQRS; commands generate events, events drive queries
- Read Models: Projections built from events; can be recreated from command side state
- Consistency Boundary: Commands are strongly consistent within aggregate; queries lag slightly
Instructions
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:
- Event-Driven: Commands emit events; readers consume and project
- Change Data Capture: Trigger-based updates from command database
- Polling: Periodically sync from command to read schema
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.
Anti-Patterns
- CQRS Without Event Sourcing: Creates two databases that drift out of sync. Result: questions about truth. Guard: Pair CQRS with event sourcing or CDC to keep models synchronized.
- Premature CQRS: Added complexity without read/write divergence. Result: boilerplate with no benefit. Guard: Only apply CQRS when read and write models naturally differ.
- Ignoring Consistency Window: Treats read model as synchronous. Result: users see stale data and complain. Guard: Define maximum staleness; make it visible in UI (e.g., "Last updated 2 seconds ago").
- Over-Denormalization: Read model includes every possible field. Result: maintenance nightmare and slow projections. Guard: Design read models per query; allow multiple read models.
Further Reading
- Exploring CQRS and Event Sourcing by Greg Young — foundational concepts
- Microservices Patterns by Chris Richardson — CQRS in microservices context
- Enterprise Integration Patterns — event-driven projections and synchronization
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cqrs-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.
Как установить скилл cqrs-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cqrs-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…