cqrs
Use when separating read and write models in a distributed or high-scale system, or when event sourcing is under consideration. Do not use when simple CRUD or single-model consistency is sufficient.
- License 许可
- MIT
- 最近更新
- 2026-10-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- cqrs
- license
- MIT
- metadata
- { "owner": "Harley Bartles", "status": "active", "use_when": [ "separating read and write models in a distributed or high-scale system, or when event sourcing is under consideration." ], "source-id": "cqrs", "source-path": "skills/cqrs/SKILL.md", "related_skills": [ "event-sourcing" ], "do_not_use_when": [ "simple CRUD or single-model consistency is sufficient." ], "provenance-name": "Cqrs first-party skill", "source-category": "first_party" }
- description
- Use when separating read and write models in a distributed or high-scale system, or when event sourcing is under consideration. Do not use when simple CRUD or single-model consistency is sufficient.
02 资源文件 5
- 参考文档agents/openai.yaml444 B
- 资产文件assets/authority/authority.yaml878 B
- 资产文件assets/authority/CITATIONS.md1.1 KB
- 资产文件assets/authority/source-map.yaml363 B
- 参考文档references/operational-guidance.md833 B
03 SKILL.md 正文
CQRS
Overview
CQRS separates read and write models so each side can evolve, scale, and be optimized independently. Commands mutate state; queries return shaped views.
When to Use
- Use when read and write workloads differ in volume, shape, or scale.
- Use when multiple query models need different projections of the same data.
- Use when event sourcing is being considered as a companion persistence strategy.
- Do not use when a single consistent model and simple CRUD are sufficient.
Core Pattern
- Split commands (intent + validation) from queries (read-optimized DTOs/views).
- Design separate models: a write model for business rules, read models for consumers.
- Choose a synchronization strategy: same database with separate schemas, materialized views, or event-driven projections.
- Decide consistency boundaries: eventual consistency is acceptable for most reads; strong consistency only where required.
Common Mistakes
- Leaking the write model into read APIs or vice versa.
- Using CQRS for a simple domain to justify unnecessary architecture.
- Treating event sourcing as mandatory instead of optional.
04 同仓库更多 Skills
writing
Use when drafting, revising, or reviewing prose for human readers and clarity, an authorised voice, or reader-fatigue concerns may interact.
writing-with-clarity
Use when drafting, revising, or reviewing prose intended for human readers, including documentation, README files, reports, explanations, UI copy, errors, comments, commit messages, and pull request text.
writing-style
Use when revising or reviewing human-facing prose against an authorised voice card or a contextual reader-fatigue profile.
skill
暂无简介
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment.
writing-roadmaps
Use when a goal is too large for one writing-plans plan and requires a sequenced roadmap of consecutive plans.