ddd-cqrs-architecture

ddd-cqrs-architecture is a skill for Claude Code from full-stack-skills/ddd-skills. It costs 97 tokens per session (2,705 once invoked), scanned A, original, Apache-2.0.

Guidance for CQRS, a design that separates changing data from reading data, with related patterns such as Event Sourcing and domain events.

In plain words
What is it for?
Use it to plan CQRS at several implementation levels, design idempotency, manage domain-event lifecycles, apply Event Sourcing, and fit CQRS into layered, Onion, Hexagonal, Clean, or COLA architectures.
Why use it?
It helps teams choose how much separation they need and handle issues such as repeated messages, event processing, and different read and write models.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the ddd-skills plugin — 16 skills shipped together

Good fit Use it to plan CQRS at several implementation levels, design idempotency, manage domain-event lifecycles, apply Event Sourcing, and fit CQRS into layered, Onion, Hexagonal, Clean, or COLA architectures.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add full-stack-skills/ddd-skills --skill ddd-cqrs-architecture
Clone the repo
git clone --depth 1 https://github.com/full-stack-skills/ddd-skills

Made for: Claude Code.

Or install ddd-skills, the plugin that ships this one along with the rest of its 16 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ddd-cqrs-architecture

README.md
[![agentmods](https://agentmods.dev/badge/skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture/github.svg)](https://agentmods.dev/skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture)
Your own site
<a href="https://agentmods.dev/skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture"><img src="https://agentmods.dev/badge/skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ddd-cqrs-architecture

Your own site · 80×15
<a href="https://agentmods.dev/skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture"><img src="https://agentmods.dev/badge/skills/full-stack-skills/ddd-skills/ddd-cqrs-architecture.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 97 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,705 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00097 $0.02705
Opus 5 $0.00048 $0.01352
Sonnet 5 $0.00019 $0.00541
Haiku 4.5 $0.00010 $0.00270

Measured today against content hash e3d58e29c1ae, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

ddd-cqrs-architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ddd-cqrs-architecture/SKILL.md · 196 lines

How it starts

The opening of the file, as written. The whole thing — 196 lines — stays where its author put it; the contents beside it link to each section on GitHub.

DDD CQRS Architecture

CQRS (Command Query Responsibility Segregation) — L1/L2/L3 adoption, Event Sourcing, idempotency, integration with 5 DDD architectures.

When to Use This Skill

Trigger keywords: CQRS, 读写分离, Event Sourcing, 事件溯源, Command Bus, Query Model, 领域事件, domain event, 幂等, idempotency, eventual consistency, projection, materialized view

Workflow

Step 1: 判断是否需要 CQRS → 确认读写模式是否显著分化
Step 2: 选择 CQRS 级别 → L1/L2/L3
Step 3: 设计命令模型 → Command → Handler → 领域事件
Step 4: 设计查询模型 → Query → Handler → DTO
Step 5: 实现事件同步(L2/L3)→ Outbox → 发布器 → 投影
Step 6: 按架构集成 → 根据 Layered/Onion/Hexagonal/Clean/COLA

When to Use CQRS

适用场景

  • 读写模式显著分化: 写操作与读操作用不同数据结构和优化策略
  • 高并发写入: 写需 ACID 保证,读可接受最终一致性
  • 多视图需求: 同一数据多种展示形式(列表/详情/统计/搜索)
  • 审计追踪要求: 完整记录所有状态变更历史
  • 团队具备事件驱动能力: 理解最终一致性和事件溯源概念

升级路径

CRUD 够用(读=写)         → 单模型,无需 CQRS
  ↓
L1 模型分离                → CommandService / QueryService 分离,共享 DB
  ↓
L2 数据库分离               → Command DB + Query DB,事件同步
  ↓
L3 Event Sourcing          → EventStore + Projection

不适用场景

场景 替代方案
简单 CRUD,读=写 单模型,不引入 CQRS
原型/一次性项目 跳过 CQRS
团队不熟悉事件驱动 先用 ddd-event-storming 建立事件思维
强一致性要求极高 评估分布式事务成本

CQRS Core Principles

维度 命令侧(Write) 查询侧(Read)
职责 处理状态变更,执行业务规则 返回数据视图,无业务逻辑
模型 Command Model(命令对象+聚合根) Query Model(DTO+物化视图)
存储 Write DB (3NF, ACID) Read DB (反范式, 查询优化)
一致性 强一致性(聚合内) 最终一致性(跨聚合/服务)
输出 领域事件 DTO / View Model

L1/L2/L3 Adoption Strategy

L1 — Model Separation

成本最低:仅代码层分离 Command/Query Service,共享数据库。适用于读写数据结构相同但逻辑分离的场景。 参考示例: examples/06-order-l1-model-separation.md

L2 — Database Separation

中等成本:分离 Command DB 和 Query DB,通过领域事件同步。适用于读负载高、独立优化策略需求的场景。 参考示例: examples/07-order-l2-db-separation.md

L3 — Event Sourcing

最高成本:以事件流作为唯一真相源,通过投影重建读模型。适用于审计追踪、时间旅行查询、事件重放的场景。 参考示例: examples/08-order-l3-event-sourcing.md

Event Lifecycle

领域行为 → 构建 DomainEvent → 持久化 → EventBus 发布
                                        → 本地处理器 (同步)
                                        → MQ 外发 (异步, 跨服务)

Read the full file on GitHub · 196 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed e3d58e29c1ae
  2. 12d ago First seen · 196 lines · 97 tokens per session scan A 1f75a3db3b54

Subscribe to this mod's changes

ddd-cqrs-architecture is a skill published in the GitHub repository full-stack-skills/ddd-skills (5 stars, last pushed yesterday), licensed Apache-2.0. It adds 97 tokens to every session and 2,705 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

mem0-oss-to-platform

Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local Memory class) to the mem0 Platform / hosted / managed SDK (the MemoryClient class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g.…

mem0ai/mem0 · 273 tokens

agui-dotnet-protobuf

Use the protobuf wire transport (instead of the default Server-Sent Events) for an AG-UI connection with the AG-UI .NET SDK — a compact binary event stream negotiated via the Accept header. USE FOR: making an AGUIChatClient prefer protobuf by wiring an AGUIEventStreamHandler with ProtobufEventStreamFormatter (then…

ag-ui-protocol/ag-ui · 162 tokens

azure-mgmt-botservice-dotnet

Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings. Triggers: "Bot Service", "BotResource", "Azure Bot", "DirectLine channel", "Teams channel", "bot management .NET", "create bot".

microsoft/skills · 78 tokens

fastapi-router-py

Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.

microsoft/skills · 46 tokens

aws-sdk-java-v2-core

Provides AWS SDK for Java 2.x client configuration, credential resolution, HTTP client tuning, timeout, retry, and testing patterns. Use when creating or hardening AWS service clients, wiring Spring Boot beans, debugging auth or region issues, or choosing sync vs async SDK usage.

giuseppe-trisciuoglio/developer-kit · 62 tokens

migrate-segw-to-rap

Reverse-engineer a SEGW-built OData V2 service (MPC/DPC/MPCEXT/DPCEXT) into a modern RAP V4 service — tables, CDS views (interface + projection), behavior definitions, draft entities, service definition + binding. Use when asked to "migrate this SEGW service to RAP", "convert OData V2 to V4 RAP", "modernize this…

arc-mcp/arc-1 · 106 tokens