From aj-geddes-useful-ai-prompts-4
Implements event sourcing and CQRS patterns with event stores, aggregates, projections, and snapshots. Use for audit trails, temporal queries, and systems requiring full history.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:event-sourcingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Store state changes as a sequence of events rather than the current state, enabling temporal queries, audit trails, and event replay.
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)
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 |
npx claudepluginhub aj-geddes/useful-ai-promptsDesigns event-sourced systems using CQRS, event stores, projections, sagas, and eventual consistency patterns. Useful for audit trails, temporal queries, and complex workflows.
Guides event sourcing, CQRS, and event-driven architecture design including event stores, projections, sagas, and eventual consistency. Use for audit trails, temporal queries, or complex domain modeling.
Store state as immutable event log instead of current values. Build auditable, event-driven systems with full history. Use when auditability, temporal queries, or event-driven processing matters.