All skills
wshobson avatar

/cqrs-implementation

@be57c0b
by Seth Hobsonwshobson/agents40k stars
4,281

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

Use this Skill: https://skilld.dev/gh/wshobson/agents/cqrs-implementation

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ52 tokens always: the name and description. β‰ˆ803 when used: this file. β‰ˆ3.2k more on demand in 1 file.

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

Source: SKILL.md on GitHub

No alerts16d5 checks Β· Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides architectural templates for implementing the Command Query Responsibility Segregation (CQRS) pattern. The code samples follow security best practices, including the use of parameterized SQL queries to prevent injection attacks.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW Β· No issues

  • Runlayer6mo

    1 file scanned Β· No issues

  • ZeroLeaks5mo

    Score: 93/100 Β· 2 sections analyzed

Signed by skilld at be57c0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
  • cqrs
  • event-sourcing
  • architecture
  • design-patterns
  • scalability
  • read-write-separation
  • domain-driven-design

README badge

README badge for wshobson/agents/cqrs-implementation

Implements Command Query Responsibility Segregation to separate read and write models, enabling independent scaling and optimized query performance. Use this skill when building event-sourced systems, scaling reads separately from writes, or designing systems with different read/write data schemas.

Generated from the current SKILL.md.

What programming language or framework does this skill target?
The SKILL.md does not specify a particular language or framework. It provides general CQRS pattern guidance applicable across architectures.
Does this skill include code templates?
Yes. Detailed templates and worked examples are provided in `references/details.md`.
When should I use CQRS instead of a simpler architecture?
Use CQRS when separating read and write concerns, scaling reads independently, building event-sourced systems, or optimizing complex queries with different read/write data models.
Does this skill address eventual consistency?
Yes. The skill recommends using eventual consistency and accepting propagation delay between write and read models as a core practice.

Generated from the current SKILL.md. These answers refresh after source changes.