event-store-design
它能做什么
这个工具可以帮你规划和创建“事件存储”(event store),适用于需要记录系统中发生的每件事的系统。它能帮助你安全、有条理地存储信息。
适用场景
- ✓为记录事件的系统搭建基础时。
- ✓选择用哪种技术来存储这些事件时。
- ✓规划事件如何存储和检索时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/event-store-design/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想记录应用中的用户操作,怎样设计一个事件存储?”
每周 5 个新技能,1 分钟读完。
工作原理
它会引导你设计事件存储的结构:规定事件只能追加到末尾,按序列进行组织,并确保不会出现重复或丢失。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Event Store Design
Comprehensive guide to designing event stores for event-sourced applications.
When to Use This Skill
- Designing event sourcing infrastructure
- Choosing between event store technologies
- Implementing custom event stores
- Optimizing event storage and retrieval
- Setting up event store schemas
- Planning for event store scaling
Core Concepts
1. Event Store Architecture
┌─────────────────────────────────────────────────────┐
│ Event Store │
├─────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Stream 1 │ │ Stream 2 │ │ Stream 3 │ │
│ │ (Aggregate) │ │ (Aggregate) │ │ (Aggregate) │ │
│ ├─────────────┤ ├─────────────┤ ├─────────────┤ │
│ │ Event 1 │ │ Event 1 │ │ Event 1 │ │
│ │ Event 2 │ │ Event 2 │ │ Event 2 │ │
│ │ Event 3 │ │ ... │ │ Event 3 │ │
│ │ ... │ │ │ │ Event 4 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────┤
│ Global Position: 1 → 2 → 3 → 4 → 5 → 6 → ... │
└─────────────────────────────────────────────────────┘
2. Event Store Requirements
| Requirement | Description |
|---|---|
| Append-only | Events are immutable, only appends |
| Ordered | Per-stream and global ordering |
| Versioned | Optimistic concurrency control |
| Subscriptions | Real-time event notifications |
| Idempotent | Handle duplicate writes safely |
Technology Comparison
| Technology | Best For | Limitations |
|---|---|---|
| EventStoreDB | Pure event sourcing | Single-purpose |
| PostgreSQL | Existing Postgres stack | Manual implementation |
| Kafka | High-throughput streaming | Not ideal for per-stream queries |
| DynamoDB | Serverless, AWS-native | Query limitations |
| Marten | .NET ecosystems | .NET specific |
Templates and detailed worked examples
Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Best Practices
Do's
- Use stream IDs that include aggregate type -
Order-{uuid} - Include correlation/causation IDs - For tracing
- Version events from day one - Plan for schema evolution
- Implement idempotency - Use event IDs for deduplication
- Index appropriately - For your query patterns
Don'ts
- Don't update or delete events - They're immutable facts
- Don't store large payloads - Keep events small
- Don't skip optimistic concurrency - Prevents data corruption
- Don't ignore backpressure - Handle slow consumers
常见问题
什么是“事件溯源”(event sourcing)?
这是一种构建系统的方式,所有状态变化都以一连串事件的形式保存。你保存的不只是当前状态,还有它是如何一步步变成这样的历史记录。
为什么事件不能修改或删除?
事件记录的是已经发生的事实。修改它们就像重写历史,可能导致数据不一致。更好的做法是追加新的事件,来纠正或取消之前的操作。
什么是 'correlation IDs' 和 'causation IDs'?
它们是用来追踪事件在系统不同部分之间的来源和流转路径的标识符,有助于排查问题,理解到底发生了什么。
详情
作者的原始描述
Design and implement event stores for event-sourced systems. Use when building event sourcing infrastructure, choosing event store technologies, or implementing event persistence patterns.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6638
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …