CQRS pattern implementation and query optimization
View on GitHubmelodic-software/claude-code-plugins
event-modeling
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/melodic-software/claude-code-plugins/blob/main/plugins/event-modeling/skills/cqrs-architecture/SKILL.md -a claude-code --skill cqrs-architectureInstallation paths:
.claude/skills/cqrs-architecture/# CQRS Architecture Skill Design and implement Command Query Responsibility Segregation patterns for scalable systems. ## MANDATORY: Documentation-First Approach Before implementing CQRS: 1. **Invoke `docs-management` skill** for CQRS patterns 2. **Verify patterns** via MCP servers (perplexity, context7) 3. **Base guidance on established CQRS literature** ## CQRS Fundamentals ```text Traditional vs CQRS: TRADITIONAL (Single Model): ┌─────────────────────────────────┐ │ Application │ ├─────────────────────────────────┤ │ Domain Model │ │ (Reads + Writes) │ ├─────────────────────────────────┤ │ Database │ └─────────────────────────────────┘ CQRS (Separated Models): ┌───────────────┐ ┌───────────────┐ │ Command Side │ │ Query Side │ │ (Write Model) │ │ (Read Model) │ ├───────────────┤ ├───────────────┤ │ Domain Logic │ │ DTO/Views │ │ Aggregates │ │ Projections │ ├───────────────┤ ├───────────────┤ │ Write DB │───►│ Read DB │ └───────────────┘ └───────────────┘ ``` ## CQRS Levels ### Level 1: Logical Separation ```text Same database, separate code paths: ┌─────────────────────────────────────┐ │ Application │ ├──────────────────┬──────────────────┤ │ Command Handlers │ Query Handlers │ │ - Validation │ - Direct SQL │ │ - Domain Logic │ - Projections │ │ - Events │ - DTOs │ ├──────────────────┴──────────────────┤ │ Single Database │ └─────────────────────────────────────┘ Benefits: ✓ Clean separation in code ✓ Simple deployment ✓ Single source of truth ✓ Good starting point ``` ### Level 2: Separate Read Models ```text Same write DB, separate read DB: ┌─────────────────┐ ┌─────────────────┐ │ Command Side │ │ Query Side │ ├─────────────────┤ ├─────────────────┤ │ Command Handler │ │ Query Handler │ │ Domain Model │ │ DTOs