Event sourcing — state as an append-only event log, event design and versioning (upcasting), snapshots, projections, replay and rebuild, GDPR and deletion concerns, operational costs. Use when audit history or temporal queries are core requirements (event sourcing, event store, upcasting, snapshots, replay).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Event Sourcing?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-event-sourcing)
---
name: event-sourcing
description: Event sourcing — state as an append-only event log, event design and versioning (upcasting), snapshots, projections, replay and rebuild, GDPR and deletion concerns, operational costs. Use when audit history or temporal queries are core requirements (event sourcing, event store, upcasting, snapshots, replay).
metadata:
category: design-patterns
---
# Event sourcing
## Purpose
Persist every state change as an immutable event when history itself is a requirement.
**Use when:** full audit trails, temporal queries or complex state reconstruction are required.
**Not for:** when a simple audit table suffices.
## Inputs
- Domain events, audit and temporal requirements.
## Outputs
- Event schemas, versioning strategy, snapshot and projection design.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "event sourcing"` for prior decisions, patterns and anti-patterns.
## Steps
1. **Justify.** Confirm history is a requirement, not a nice-to-have; compare with an audit log.
Done when decision is recorded via `decision-analysis`.
2. **Events.** Design fine-grained, business-meaningful, past-tense events with schemas.
Done when each event has a versioned schema.
3. **Evolution.** Plan upcasting and never rewrite stored events.
Done when old events remain readable.
4. **Operations.** Design snapshots, projection rebuild time, and personal data handling (crypto-shredding).
Done when rebuild time is measured; deletion path exists.
## Best practices
- Events describe business facts, not CRUD diffs.
- Keep personal data out of events or encrypt per subject.
- Measure replay time early.
## Common mistakes
- Using event sourcing for every entity.
- Breaking event schemas.
- No plan for right-to-erasure.
## Example
Ledger: `FundsDeposited`, `FundsWithdrawn` events; snapshot every 500 events; balances projection rebuild 4 min for 10M events.
## Reusable prompt
```text
Apply the Event sourcing skill (.agents/skills/event-sourcing/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Assess whether event sourcing is justified, then design events, versioning, snapshots, projections and the personal-data strategy.
Return: Event schemas, versioning strategy, snapshot and projection design..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```