Skip to content
Skillpedia
APIs & servers (backend)41k · #4804

cqrs-implementation

Lets your agent separate the tasks of giving commands and asking questions in complex systems. This helps create faster and more efficient systems.

What it does

This guide teaches how to separate data writing and reading tasks in a system. This helps make the system faster and more organized, especially when a lot of information is being accessed or modified.

When to use it

  • ✓When you need data writing and reading to work in different ways.
  • ✓To make the reading part of the system run faster without affecting writing.
  • ✓When building systems that record all changes as events.

Example of what to ask your AI

“How can I use CQRS to optimize the speed of complex reports?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/cqrs-implementation/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/cqrs-implementation/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It works by dividing operations into two parts: commands (to change data) and queries (to read data). Each part can be optimized separately, using different data models and focusing on performance.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add wshobson/agents --skill cqrs-implementation

Or download just the file:

curl -L https://raw.githubusercontent.com/wshobson/agents/main/plugins/backend-development/skills/cqrs-implementation/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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
FAQ

What is 'eventual consistency'?

It means that data might take a little while to update across all parts of the system, but it will eventually be correct.

Why separate read and write models?

Because they have different needs. The write model needs to ensure data integrity, while the read model needs to be fast in answering questions.

Can I start with a simple implementation?

Yes, the recommendation is to start simple and add complexity only when truly necessary.

Details

Original description by the author

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

repo: wshobson/agents

Popularity

GitHub stars
41k
Ranking position
#4804
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills