cqrs
Skill106 starsChanged 4 months agoMITView on GitHub
CQRS - Command Query Responsibility Segregation. Use when implementing DDD patterns, separating read/write models, event sourcing, or building scalable architectures with heterogeneous performance requirements.
In this repository60 other files it gives its agents.
- docs/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .claude/references/angular/CLAUDE.mdCLAUDE.md
- .claude/references/flutter/CLAUDE.mdCLAUDE.md
- .claude/references/laravel/CLAUDE.mdCLAUDE.md
- .claude/references/paperclip/CLAUDE.mdCLAUDE.md
- .claude/references/reactnative/CLAUDE.mdCLAUDE.md
- .claude/references/svelte/CLAUDE.mdCLAUDE.md
- .claude/references/symfony/CLAUDE.mdCLAUDE.md
- .claude/references/vite/CLAUDE.mdCLAUDE.md
- .claude/references/vuejs/CLAUDE.mdCLAUDE.md
- aggregatesSkill
- api-gatewaySkill
- architectSkill
- architecture-clean-dddSkill
- architectureSkill
- asyncSkill
- atomic-tasksSkill
- coding-standardsSkill
- ddd-patternsSkill
- debug-methodicalSkill
- design-md-conventionSkill
- docker-hadolintSkill
- doctrine-extensionsSkill
- documentationSkill
- domain-eventsSkill
- dynamic-workflowsSkill
- ecosystem-toolsSkill
- edge-computingSkill
- event-drivenSkill
- git-workflowSkill
- graphqlSkill
- i18nSkill
- kiss-dry-yagniSkill
- monorepoSkill
- multitenantSkill
- navigationSkill
- observabilitySkill
- parallel-worktreesSkill
- performanceSkill
- quality-toolsSkill
- remotionSkill
- security-flutterSkill
- security-reactnativeSkill
- security-reactSkill
- securitySkill
- security-symfonySkill
- socratic-brainstormSkill
- solid-principlesSkill
- state-managementSkill
- testing-flutterSkill
- testing-pythonSkill
- testing-reactnativeSkill
- testing-reactSkill
- testingSkill
- testing-symfonySkill
- toolingSkill
- value-objectsSkill
- wasmSkill
- workflow-analysisSkill
The file
Files
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, EventStoreDB), saga patterns, outbox, exemples concrets, migration progressive d'un CRUD vers CQRS, checklists par phase : voir
@.claude/skills/cqrs/REFERENCE.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

