mcpField
C
cqrs-implementation

cqrs-implementation

github.com/wshobsonDevelopment41.9k11.1k installsUpdated 2w ago
Repository

About cqrs-implementation

cqrs-implementation is a CQRS implementation guide for developers. It explains separation of command and query models, core components, and practices; detailed templates and examples are in references/details.md.

Key features

  1. 01Separate command and query models
  2. 02Explain command, event, and query components
  3. 03Cover read-model projection
  4. 04Address event versioning
  5. 05Provide detailed templates and examples

Use cases

  1. 01Scale read and write loads independently
  2. 02Build event-sourced systems
  3. 03Optimize complex queries and reporting
  4. 04Design distinct read and write data models

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/wshobson/agents --skill cqrs-implementation

After installing, type/cqrs-implementationin Claude Code to confirm it loaded.

Bundled filesreferences/details.md

Details

From the project README

CQRS Implementation

Comprehensive guide to implementing CQRS (Command Query Responsibility Segregation) patterns.

When to Use This Skill

  • Separating read and write concerns
  • Scaling reads independently from writes
  • Building event-sourced systems
  • Optimizing complex query scenarios
  • Different read/write data models needed
  • High-performance reporting requirements

Core Concepts

1. CQRS Architecture
                    ┌─────────────┐
                    │   Client    │
                    └──────┬──────┘
                           │
              ┌────────────┴────────────┐
              │                         │
              ▼                         ▼
       ┌─────────────┐          ┌─────────────┐
       │  Commands   │          │   Queries   │
       │    API      │          │    API      │
       └──────┬──────┘          └──────┬──────┘
              │                         │
              ▼                         ▼
       ┌─────────────┐          ┌─────────────┐
       │  Command    │          │   Query     │
       │  Handlers   │          │  Handlers   │
       └──────┬──────┘          └──────┬──────┘
              │                         │
              ▼                         ▼
       ┌─────────────┐          ┌─────────────┐
       │   Write     │─────────►│    Read     │
       │   Model     │  Events  │   Model     │
       └─────────────┘          └─────────────┘
2. Key Components
ComponentResponsibility
CommandIntent to change state
Command HandlerValidates and executes commands
EventRecord of state change
QueryRequest for data
Query HandlerRetrieves data from read model
ProjectorUpdates read model from events

Templates and detailed worked examples

Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.

Best Practices

Do's
  • Separate command and query models - Different needs
  • Use eventual consistency - Accept propagation delay
  • Validate in command handlers - Before state change
  • Denormalize read models - Optimize for queries
  • Version your events - For schema evolution
Don'ts
  • Don't query in commands - Use only for writes
  • Don't couple read/write schemas - Independent evolution
  • Don't over-engineer - Start simple
  • Don't ignore consistency SLAs - Define acceptable lag

Comments

Markdown supported