Cqrs Implementation

by wshobson46891e7e60daNo licenseListed Oct 8, 2026Updated Oct 8, 2026

Implement Command Query Responsibility Segregation for scalable architectures. Use when separating read and write models, optimizing query performance, or building event-sourced systems.

Instructions onlySoftware Development
AI-generated overview

Guides implementing CQRS by separating command and query models, with templates in a reference file.

What it does
This skill provides guidance for implementing Command Query Responsibility Segregation (CQRS) architectures. It explains core concepts such as commands, command handlers, events, queries, query handlers, and projectors, and lists best practices and pitfalls. It points to a reference file containing a template library and detailed worked examples.
When to use it
Use it when separating read and write models, scaling reads independently from writes, building event-sourced systems, or optimizing complex query and reporting scenarios. It is intended for design and implementation guidance rather than producing code artifacts directly.
Requirements
No scripts or tools are required; it is instructions only. Reading the bundled reference file references/details.md is suggested for concrete templates.

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

Source and attribution

Source:wshobson/agentsinplugins/backend-development/skills/cqrs-implementationat commit46891e7

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal