Back to Skills

cqrs-event-sourcing

majiayu000
Updated Today
58
9
58
View on GitHub
Metaaidesign

About

This skill provides CQRS and Event Sourcing patterns to build scalable, auditable systems by separating read and write models. It's ideal for applications requiring full audit trails, temporal queries, or handling complex domain logic at high scale. Key capabilities include complete historical tracking, event replay, and optimized independent model projections.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/cqrs-event-sourcing

Copy and paste this command in Claude Code to install this skill

Documentation

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 dataMultiple models for different needs
Change system stateEventually 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

TaskLoad reference
CQRS implementation patternsskills/cqrs-event-sourcing/references/cqrs-patterns.md
Event sourcing & snapshotsskills/cqrs-event-sourcing/references/event-sourcing.md
EventStoreDB & Axon Frameworkskills/cqrs-event-sourcing/references/event-store-tech.md
Consistency patternsskills/cqrs-event-sourcing/references/consistency-patterns.md
Best practices checklistskills/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

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/cqrs-event-sourcing

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

creating-opencode-plugins

Meta

This skill provides the structure and API specifications for creating OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It offers implementation patterns for JavaScript/TypeScript modules that intercept and extend the AI assistant's lifecycle. Use it when you need to build event-driven plugins for monitoring, custom handling, or extending OpenCode's capabilities.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill