Cqrs Implementation cqrs-implementation

Implement Command Query Responsibility Segregation for scalable architectures.

Use it when separating read and write models, optimizing query performance, or building event-sourced systems.

Works in Claude, ChatGPT, Codex and more
Our test
6/10
tested Dec 6, 2026
GitHub stars
43k
wshobson/agents
Added by
0
members
Updated
Dec 2
commit e66c24f
Content
2 files
no scripts · 16 KB
License
MIT
free to use

What our test found

The skill provides useful CQRS concepts and Python scaffolding, but synchronization and error-handling examples have reliability gaps that need correction before production use.

Request we tested it on“I’m building an order service in Python with FastAPI. Show me a practical CQRS structure for creating orders and querying them, including how the read model stays synchronized with events.”

Limits spotted

  • The projector advances checkpoints even when event application fails, which can permanently skip events.
  • Projection changes and checkpoint updates lack transaction or idempotency guarantees.
  • Some code snippets omit imports and definitions, so they are not directly runnable.
  • The guidance does not cover operational concerns such as monitoring, retries, or dead-letter handling.
View on GitHub ↗
name: cqrs-implementation
description: Implement Command Query Responsibility Segregation for scalable architectures. Use when separating read and write models, optimizing query performance, or building event-sourced systems.

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

| Component | Responsibility | | ------------------- | ------------------------------- | | Command | Intent to change state | | Command Handler | Validates and executes commands | | Event | Record of state change | | Query | Request for data | | Query Handler | Retrieves data from read model | | Projector | Updates 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