New advertisers: 50% off your first month with code FIRSTMONTHSee slots

Implementation guide for event sourcing and CQRS with event stores, aggregates, projections, and snapshots.

skills.sh installs
893
GitHub stars
387
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers event store design, read-model projections, PostgreSQL-backed storage, and snapshots for performance
  • Includes a TypeScript quick start with a DomainEvent shape, versioned aggregates, and an EventStore class
  • Enforces optimistic concurrency on appends and keeps reads on projections rather than the event store
  • Designed for systems needing audit trails, temporal queries, or full history, such as financial and compliance workloads

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill event-sourcing -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Event Sourcing

Table of Contents

Overview

Store state changes as a sequence of events rather than the current state, enabling temporal queries, audit trails, and event replay.

When to Use

  • Audit trail requirements
  • Temporal queries (state at any point in time)
  • Event-driven microservices
  • CQRS implementations
  • Financial systems
  • Complex domain models
  • Debugging and analysis
  • Compliance and regulation

Quick Start

Minimal working example:

interface DomainEvent {
  id: string;
  aggregateId: string;
  aggregateType: string;
  eventType: string;
  data: any;
  metadata: {
    userId?: string;
    timestamp: number;
    version: number;
  };
}

interface Aggregate {
  id: string;
  version: number;
}

class EventStore {
  private events: DomainEvent[] = [];

  async appendEvents(
    aggregateId: string,
    expectedVersion: number,
    events: Omit<DomainEvent, "id" | "metadata">[],
// ... (see reference guides for full implementation)

Reference Guides

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Backend & APIs, Databases
First seen
May 16, 2026

More from aj-geddes/useful-ai-prompts

All 258

Similar to Event Sourcing

More Backend & APIs