event-sourcing

aj-geddes/useful-ai-prompts · updated Apr 8, 2026

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill event-sourcing
0 commentsdiscussion
summary

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

skill.md

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

Detailed implementations in the references/ directory:

Guide Contents
Event Store (TypeScript) Event Store (TypeScript)
Projections (Read Models) Projections (Read Models)
Event Store with PostgreSQL Event Store with PostgreSQL
Snapshots for Performance Snapshots for Performance

Best Practices

✅ DO

  • Store events immutably
  • Version your events
  • Use optimistic concurrency
  • Create snapshots for performance
  • Use projections for queries
  • Keep events small and focused
  • Include metadata (timestamp, user, etc.)
  • Handle event versioning/migration

❌ DON'T

  • Mutate past events
  • Store current state only
  • Skip concurrency checks
  • Query event store for reads
  • Make events too large
  • Forget about event schema evolution

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.568 reviews
  • Li Srinivasan· Dec 28, 2024

    Registry listing for event-sourcing matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Mateo Wang· Dec 24, 2024

    We added event-sourcing from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Ganesh Mohane· Dec 8, 2024

    Solid pick for teams standardizing on skills: event-sourcing is focused, and the summary matches what you get after install.

  • Carlos Kim· Dec 8, 2024

    Keeps context tight: event-sourcing is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Ava Khanna· Nov 27, 2024

    We added event-sourcing from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Kwame Smith· Nov 19, 2024

    Useful defaults in event-sourcing — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Sofia Smith· Nov 15, 2024

    Keeps context tight: event-sourcing is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Ama Taylor· Oct 18, 2024

    event-sourcing fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Kwame Anderson· Oct 10, 2024

    I recommend event-sourcing for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Ira Johnson· Oct 6, 2024

    event-sourcing is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 68

1 / 7