cqrs-implementation

Separate command and query paths with event-sourced projections in FastAPI.

1|Updated Apr 27, 2026
One-click install
npx skills add https://github.com/haxlys/skills --skill cqrs-implementation-haxlys
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cqrs-implementation
Source: https://github.com/haxlys/skills/tree/main/vendored/wshobson-agents/plugins/backend-development/skills/cqrs-implementation
Command: npx skills add https://github.com/haxlys/skills --skill cqrs-implementation-haxlys

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Separates command and query responsibilities to improve scalability, performance, and maintainability in complex domains by modeling writes and reads as distinct paths.

Core Features & Use Cases

  • Separation of Command and Query models for clear boundaries and independent evolution.
  • Event-sourced write model with projections that update read models in response to domain events.
  • Read-model synchronization, projection rebuilding, and support for eventual consistency in distributed systems.
  • Concrete templates for commands, queries, buses, and a FastAPI application to demonstrate end-to-end flow.

Quick Start

Create a simple order via the command bus and verify the result by querying the read model.

Frequently Asked Questions about cqrs-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate command and query paths in FastAPI for high-performance data handling?

You separate command and query paths in FastAPI by using distinct command and query buses to route write and read workloads independently. This CQRS pattern improves scalability by modeling writes and reads as separate paths, allowing independent evolution and optimized performance.

What is event-sourced CQRS and when do I need it for microservices?

Event-sourced CQRS is an architectural pattern where state changes are modeled as stored domain events that update read models via projections. You need it in distributed microservices requiring eventual consistency, event-driven state changes, and distinct command and query responsibilities for complex domains.

How do I synchronize read models and rebuild projections in a CQRS architecture?

You synchronize read models by applying domain events from the event-sourced write model to build read-model projections. Projection rebuilding processes versioned events to update read models, ensuring eventual consistency and accurate query results across distributed systems.

Does CQRS with event sourcing work well for domain-driven designs requiring eventual consistency?

CQRS with event sourcing works well for domain-driven designs by separating write and read models to support eventual consistency. It provides clear boundaries, independent model evolution, and event-driven state changes tailored for complex domains across microservices architectures.

What's the best way to structure command and query handlers for scalable systems?

The best way to structure command and query handlers is by using distinct buses to route commands and queries to their respective handlers independently. This separation ensures clear boundaries, allowing command handlers to process writes and query handlers to manage read models separately.

Why use separate command and query models instead of a single data model?

Separate command and query models improve scalability and maintainability by allowing reads and writes to evolve independently. This CQRS approach optimizes performance for complex domains by tailoring write paths for state changes and read paths for optimized queries.