Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

cqrs

FreeNo executable scriptsNot checked

CQRS - Command Query Responsibility Segregation. Use when implementing DDD patterns, separating read/write models, event sourcing, or building scalable…

TheBeardedBearSASby TheBeardedBearSAS★ 109 GitHub stars

About this skill

CQRS — Quick Reference

CQRS (Command Query Responsibility Segregation) sépare les opérations d'écriture et de lecture dans des modèles distincts. N'est pas par défaut — c'est une optimisation à activer quand le coût de la complexité est justifié.

Quand utiliser

Pertinent Pas pertinent
Domaine métier complexe avec règles d'invariants riches CRUD simple, domaine pauvre
Ratio lectures/écritures > 10× Petits projets, équipe junior
Audit / compliance (Event Sourcing naturel) Cohérence immédiate requise
Read models hétérogènes (mobile vs analytics vs back-office) Modèle de données stable et unique
Scale différencié reads vs writes (replicas, cache, search) Charge faible, monolithe modeste

Règle d'or : commencer par une architecture classique. Migrer vers CQRS lorsqu'au moins 2 des cas pertinents sont présents simultanément.

Architecture en 30 secondes

[ User ]
   ↓
[ Command ]──────────▶ [ Write Model (Domain) ]
                              ↓ persist + emit
                       [ Event(s) ]
                              ↓
[ Query ] ◀───── [ Read Model (denormalised) ] ◀── projections
  • Command side : modèle normalisé, focus invariants métier. Écrit, ne lit que ce qui est nécessaire à la validation.
  • Query side : modèle dénormalisé, focus performance lecture. N'a pas de logique métier.
  • Projections : transforment les events en read models. Eventually consistent.

Trade-off central

Bénéfice Coût
Scale indépendant lecture / écriture Eventual consistency (≈ 50-500 ms latency typique)
Read models taillés pour chaque besoin Plus de code à maintenir (2 modèles)
Event Sourcing devient facile à brancher Debugging plus complexe (event flow)
Audit trail naturel Migration tardive très coûteuse

Patterns associés (souvent ensemble)

  • Event Sourcing : stocker la séquence d'events comme source de vérité, le write model est reconstruit en replay.
  • Saga / Process Manager : orchestrer des transactions distribuées via events.
  • Outbox Pattern : garantir l'atomicité publication event + write DB.
  • Materialized Views : projections persistées en table dédiée pour query speed.

Anti-patterns critiques

  • ❌ CQRS sans cas d'usage clair → over-engineering, double charge cognitive.
  • ❌ Read model qui exécute des règles métier → bug d'invariants à chaque projection.
  • ❌ Projections synchrones → on perd le bénéfice scalability.
  • ❌ Event Sourcing sans snapshots → replay de millions d'events au boot.
  • ❌ Command qui retourne data complète → c'est une Query déguisée.

Pour aller plus loin

Implémentations Symfony / Laravel / .NET, Event Sourcing (Prooph, KurrentDB 26.2.3, ex-EventStoreDB), saga patterns, outbox, exemples concrets, migration progressive d'un CRUD vers CQRS, checklists par phase : voir @.claude/skills/cqrs/REFERENCE.md.

Full SKILL.md on GitHub

Install cqrs in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

REFERENCE.md

FAQ

What does the cqrs skill do?

CQRS - Command Query Responsibility Segregation. Use when implementing DDD patterns, separating read/write models, event sourcing, or building scalable architectures with heterogeneous performance requirements.

How do I install the cqrs skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the cqrs skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare cqrs with