cqrs-aggregate-modeling

Redefines aggregate boundaries by separating command validation state from query data under CQRS.

Updated Jun 23, 2026
One-click install
npx skills add https://github.com/j5ik2o/marp-ai-base --skill cqrs-aggregate-modeling-j5ik2o
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cqrs-aggregate-modeling
Source: https://github.com/j5ik2o/marp-ai-base/tree/main/.agents/skills/cqrs-aggregate-modeling
Command: npx skills add https://github.com/j5ik2o/marp-ai-base --skill cqrs-aggregate-modeling-j5ik2o

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Aggregates often grow bloated because they hold both command-validation data and query-only data, causing slow loads, full-row updates, and tangled pagination logic. This Skill explains how CQRS and Event Sourcing let you shrink aggregates to the minimal state needed for command validation while delegating read responsibilities to a read model. ## Core Features & Use Cases - Aggregate boundary redefinition: Classify each aggregate field by whether command validation requires it, and move query-only data to the read model. - Lightweight aggregate design: Keep only ID lists and state flags in the aggregate, record changes as events, and build query-optimized read models from those events. - Use Case: A Thread aggregate holding 1000 full messages forces a 1001-row update for every new message. Applying this Skill, the aggregate keeps only member IDs and message IDs, appends a single MessageAdded event, and a read model serves paginated message queries. ## Quick Start Ask the AI to review an oversized aggregate and redesign it using CQRS so it keeps only the state needed for command validation.

Frequently Asked Questions about cqrs-aggregate-modeling

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

FAQPage Schema
How does CQRS change aggregate design?

CQRS lets an aggregate keep only the minimal state needed to validate commands, since read responsibilities move to a separate read model. Fields used only for display or querying are removed from the aggregate, making it smaller and faster to load and update.

How do I decide what data belongs in an aggregate?

Classify each field by asking whether command validation requires it. Data needed for invariants, such as member IDs for permission checks, stays in the aggregate, while display-only data like message text moves to the read model.

Why is my aggregate slow to load and update?

Aggregates become slow when they hold large collections of query-only data, forcing full reads and full-row updates for small changes. Splitting query data into a read model and appending events instead of rewriting state resolves this.

Should events contain full data or only IDs?

Events should contain the full data needed to build the read model, such as message text and sender, even if the aggregate itself only tracks IDs. The aggregate restores minimal state from events while the read model consumes the complete payload.

When should strong consistency inside an aggregate be reconsidered?

Reconsider strong consistency when introducing CQRS, since not all related data needs immediate consistency. Keep strong consistency only where behavior requires it, such as membership validation, and let eventually consistent read models handle the rest.