cqrs-implementation
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.
Skill link
https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/cqrs-implementation/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow can I use CQRS to optimize the speed of complex reports?β
5 new skills a week. 1 minute to read.
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.
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
- #6637
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
screen-reader-testing
41kHas your agent test websites using screen readers to ensure they are accessible.
wcag-audit-patterns
41kHelps your agent audit websites for accessibility and fix issues according to WCAG guidelines.
multi-reviewer-patterns
41kEnables your agent to coordinate parallel code reviews, deduplicating findings and consolidating reports.
parallel-debugging
41kAllows the agent to debug complex issues with parallel investigations and root cause analysis.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.