Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

event-sourcing

БесплатноБез исполняемых скриптовНе проверен

Event sourcing patterns for functional TypeScript — persist state as an append-only log of past events and rebuild it by folding them. Use when implementing a…

citypaulот citypaul★ 764 звезды на GitHub

Об этом скилле

Event Sourcing

Event sourcing stores every change to application state as an immutable, append-only sequence of past-tense domain events. The current state is never stored directly — it is a left fold of the events: state = events.reduce(evolve, initialState). The event log is the source of truth; every other representation (aggregate state, read models, search indexes) is a derived, disposable projection you can rebuild by replaying events.

This skill applies only to projects — or the specific bounded contexts within them — that have deliberately opted in to event sourcing. It is the top of the complexity ladder, not a default. Read "When to Use Event Sourcing" first; most features should stop at explicit returns, an audit table, or the outbox pattern.

This skill builds on three others — load them alongside it:

  • domain-driven-design — the Decider (decide/evolve/initialState) is defined in its resources/domain-events.md. Event sourcing persists and replays that same decider. This skill assumes you have read it.
  • hexagonal-architecture — the event store is a driven port with an adapter; the domain stays pure. Reads use the CQRS-lite split (resources/cqrs-lite.md).
  • typescript-strict — events cross a trust boundary on the way out of and back into storage, so they are schema-first with branded IDs.

Deep-dive resources are in resources/. Load them on demand:

Resource Load when...
when-to-use-event-sourcing.md Deciding whether to adopt it; comparing against CQRS, event-driven architecture, streaming, and audit logs
modelling-events.md Discovering and naming events (EventStorming), event granularity, what data belongs in an event
decider-and-rehydration.md Writing the decide/evolve pair, rehydration, the command handler loop, decider composition
event-store.md Designing the EventStore port, the Postgres schema, optimistic concurrency, the event envelope, the TS/Node tooling landscape
projections-and-read-models.md Building read models, inline vs async projections, rebuilds, checkpoints, eventual consistency
event-versioning.md Evolving event schemas — upcasting, tolerant readers, weak schema, stream copy-transform
testing-event-sourced-systems.md Testing deciders, projections, and upcasters as behaviour, directly or through an existing test DSL
production-concerns.md Snapshots, GDPR/crypto-shredding, idempotent delivery, operability, the anti-patterns catalog
references.md Checking the rationale and primary sources behind this guidance

For the authoritative sources bundled with this skill, see resources/references.md.


When to Use Event Sourcing

Event sourcing earns its considerable complexity only when the history of changes is itself part of the domain. It is not a storage optimisation; it is a modelling decision.

Use event sourcing when:

  • The audit trail is a first-class requirement — finance, healthcare, compliance — and "what did the state look like on this date, and why?" is a real question.
  • You need temporal queries or time-travel — reconstruct past state, replay to reproduce a bug, or answer questions nobody thought to ask when the data was written.
  • The domain is genuinely event-driven — the business talks in events ("the payment was captured", "the policy lapsed") and multiple downstream models react to them.
  • You need multiple, independently-evolving read models over the same facts, and you want to add new ones retroactively by replaying history.

Do NOT use event sourcing when:

  • The domain is CRUD — forms over data with no meaningful history. Store the current state.
  • You only need an audit log — add an append-only history table next to your current-state table. Far cheaper.
  • You only need cross-aggregate side effects — use domain events with the outbox pattern (see domain-driven-design/resources/domain-events.md). That is event-driven, not event-sourced.
  • The team has no experience with it and the domain does not demand it. The failure mode is a half-built event store with no versioning strategy that becomes impossible to change.

The complexity ladder (from the DDD domain-events.md, extended): explicit return values → in-process domain events → outbox pattern → event sourcing. Climb one rung at a time, and only when the current rung cannot express what you need. Event sourcing is the last rung; step onto it deliberately, and usually for one bounded context, not the whole system.

Event sourcing is not CQRS. They are orthogonal. CQRS separates the write model from read models; event sourcing chooses events as the write model's storage. You can do CQRS without event sourcing (that is the hexagonal skill's CQRS-lite) and — rarely — event sourcing without CQRS. In practice event sourcing almost always drives CQRS, because the stored events a

Полный SKILL.md на GitHub

Установить event-sourcing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/decider-and-rehydration.mdresources/event-store.mdresources/event-versioning.mdresources/modelling-events.mdresources/production-concerns.mdresources/projections-and-read-models.mdresources/references.mdresources/testing-event-sourced-systems.mdresources/when-to-use-event-sourcing.md

FAQ

Что делает скилл event-sourcing?

Event sourcing patterns for functional TypeScript — persist state as an append-only log of past events and rebuild it by folding them. Use when implementing a Decider write model, an event store, projections and read models, event versioning, or snapshots. Builds on the Decider from domain-driven-design and the ports/adapters from hexagonal-architecture. Do NOT reach for it on CRUD, or when an audit log or the outbox pattern already suffices.

Как установить скилл event-sourcing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл event-sourcing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить event-sourcing с