Skip to content
Skillv1.0.0

cqrs-event-sourcing

CQRS and Event Sourcing patterns for scalable, auditable systems with separated read/write models. Use when building audit-required systems, implementing temporal queries, or designing high-scale appl

by nickcrew(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from nickcrew/claude-cortex (skills/cqrs-event-sourcing/SKILL.md). Install upstream with npx skills add nickcrew/claude-cortex --skill cqrs-event-sourcing. Copyright stays with the author.

CQRS and Event Sourcing Patterns

Expert guidance for implementing Command Query Responsibility Segregation (CQRS) and Event Sourcing patterns to build scalable, auditable systems with complete historical tracking and optimized read/write models.

When to Use This Skill

  • Building systems requiring complete audit trails and compliance
  • Implementing temporal queries ("show me the state at time T")
  • Designing high-scale applications with complex domain logic
  • Creating systems with significantly different read and write patterns
  • Building event-driven architectures with historical replay capability
  • Implementing systems requiring multiple read model projections
  • Designing applications where understanding "what happened" is critical
  • Building collaborative systems with conflict resolution needs

Core Principles

1. Command Query Separation

Separate operations that change state (commands) from operations that read state (queries).

Commands (Write) Queries (Read)
Express intent (CreateOrder, UpdatePrice) Return data, never change state
Can be rejected (validation failures) Can be cached and optimized
Return success/failure, not data Multiple models for different needs
Change system state Eventually consistent with writes

2. Events as Source of Truth

Store state changes as immutable events rather than current state snapshots.

Traditional: Store what IS → UPDATE users SET email = 'new@email.com' Event Sourcing: Store what HAPPENED → APPEND UserEmailChanged event

Result: Complete history, temporal queries, audit trail

3. Eventual Consistency

Accept temporary inconsistency between write and read models for scalability.

4. Domain-Driven Design Integration

  • Aggregates enforce business invariants
  • Events represent domain facts
  • Commands express domain operations
  • Bounded contexts define consistency boundaries

Quick Reference

Task Load reference
CQRS implementation patterns skills/cqrs-event-sourcing/references/cqrs-patterns.md
Event sourcing & snapshots skills/cqrs-event-sourcing/references/event-sourcing.md
EventStoreDB & Axon Framework skills/cqrs-event-sourcing/references/event-store-tech.md
Consistency patterns skills/cqrs-event-sourcing/references/consistency-patterns.md
Best practices checklist skills/cqrs-event-sourcing/references/best-practices.md

Workflow

  1. Identify if CQRS/ES is appropriate (high audit, temporal, or scale needs)
  2. Design commands expressing user intent
  3. Define events as immutable facts (past tense naming)
  4. Implement aggregates as consistency boundaries
  5. Create projections optimized for specific query needs
  6. Handle eventual consistency across bounded contexts

Common Mistakes

  • Using CQRS for simple CRUD applications (overkill)
  • Large aggregates that span multiple consistency boundaries
  • Modifying or deleting events after publication
  • Skipping command validation before aggregate processing
  • Missing idempotency in event handlers
  • No versioning strategy for event schema evolution
  • Tight coupling between aggregates (use ID references only)

Resources

  • Books: "Implementing Domain-Driven Design" (Vernon), "Event Sourcing & CQRS" (Betts et al)
  • Sites: cqrs.wordpress.com, eventstore.com/blog, axoniq.io/resources
  • Tools: EventStoreDB, Axon Framework, Marten, Eventuous
  • Patterns: Event Sourcing, CQRS, Process Manager, Saga, Snapshot

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/nickcrew-claude-cortex-cqrs-event-sourcing/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

nickcrew-claude-cortex-cqrs-event-sourcing.ocm.jsonjson
{
  "ocm": "1",
  "id": "nickcrew-claude-cortex-cqrs-event-sourcing",
  "kind": "skill",
  "name": "cqrs-event-sourcing",
  "description": "CQRS and Event Sourcing patterns for scalable, auditable systems with separated read/write models. Use when building audit-required systems, implementing temporal queries, or designing high-scale applications with complex domain logic.",
  "publisher": "nickcrew",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "cqrs",
      "aggregate-root",
      "command-query",
      "domain-event",
      "event-sourcing",
      "event-store",
      "event-stream",
      "projection",
      "read-model"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "CQRS and Event Sourcing patterns for scalable, auditable systems with separated read/write models. Use when building audit-required systems, implementing temporal queries, or designing high-scale applications with complex domain logic."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/nickcrew/claude-cortex",
      "path": "skills/cqrs-event-sourcing/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/nickcrew/claude-cortex/blob/HEAD/skills/cqrs-event-sourcing/SKILL.md",
      "key": "nickcrew/claude-cortex/skills/cqrs-event-sourcing/SKILL.md"
    }
  },
  "instructions": "# CQRS and Event Sourcing Patterns\n\nExpert guidance for implementing Command Query Responsibility Segregation (CQRS) and Event Sourcing patterns to build scalable, auditable systems with complete historical tracking and optimized read/write models.\n\n## When to Use This Skill\n\n- Building systems requiring complete audit trails and compliance\n- Implementing temporal queries (\"show me the state at time T\")\n- Designing high-scale applications with complex domain logic\n- Creating systems with significantly different read and write patterns\n- Building event-driven architectures with historical repla",
  "cost": {
    "context_tokens": 889
  }
}

Fetch it by URL: GET /api/v1/registry/nickcrew-claude-cortex-cqrs-event-sourcing/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.