create-event-store
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-event-store":https://skillpi.com/zh/skills/deepskill-c13545dcd9af74dcc32ca6c64fdbe5f25b80989af0db813152742bd907e2e3aa。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成事件存储模式。创建包含事件流、事件存储、乐观锁定与版本跟踪的事件溯源存储基础结构,并包含单元测试以验证基本行为。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: create-event-store
description: Generates Event Store pattern for PHP 8.4. Creates event sourcing storage infrastructure with event streams, stored events, optimistic locking, and version tracking. Includes unit tests.Event Store Generator
Creates Event Store infrastructure for event sourcing with aggregate history and event replay.
When to Use
| Scenario | Example |
|---|---|
| Event sourcing | Aggregate state from events |
| Audit trail | Complete change history |
| Event replay | Rebuild projections from events |
| Temporal queries | Query state at any point in time |
Component Characteristics
StoredEvent
- Immutable event wrapper
- Contains aggregate metadata (id, type, version)
- Serialized payload
- Creation timestamp
EventStream
- Ordered collection of stored events
- Implements IteratorAggregate
- Tracks current version
- Supports appending new events
EventStoreInterface
- Append events with optimistic locking
- Load full event stream for aggregate
- Load events from specific version
- Stream-based reading for large aggregates
Generation Process
Step 1: Generate Domain Components
Path: src/Domain/{BoundedContext}/EventStore/
StoredEvent.php— Immutable stored event value objectEventStreamInterface.php— Event stream contractEventStream.php— Event stream implementationEventStoreInterface.php— Event store contract
Step 2: Generate Infrastructure
Path: src/Infrastructure/{BoundedContext}/EventStore/
DoctrineEventStore.php— Doctrine DBAL implementation with optimistic locking- Database migration SQL
Step 3: Generate Tests
StoredEventTest.php— Stored event immutability testsEventStreamTest.php— Stream operations testsDoctrineEventStoreTest.php— Integration tests
File Placement
| Component | Path |
|---|---|
| StoredEvent | src/Domain/{BoundedContext}/EventStore/ |
| EventStream | src/Domain/{BoundedContext}/EventStore/ |
| EventStoreInterface | src/Domain/{BoundedContext}/EventStore/ |
| DoctrineEventStore | src/Infrastructure/{BoundedContext}/EventStore/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/EventStore/ |
| Integration Tests | tests/Integration/Infrastructure/{BoundedContext}/EventStore/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Stored Event | StoredEvent |
StoredEvent |
| Stream Interface | EventStreamInterface |
EventStreamInterface |
| Stream | EventStream |
EventStream |
| Store Interface | EventStoreInterface |
EventStoreInterface |
| Store Impl | Doctrine{Name}EventStore |
DoctrineEventStore |
| Exception | ConcurrencyException |
ConcurrencyException |
| Test | {ClassName}Test |
StoredEventTest |
Quick Template Reference
StoredEvent
final readonly class StoredEvent
{
public function __construct(
public string $aggregateId,
public string $aggregateType,
public string $eventType,
public string $payload,
public int $version,
public \DateTimeImmutable $createdAt
) {}
public static function fromDomainEvent(string $aggregateId, string $aggregateType, int $version, object $event): self;
public function toArray(): array;
public static function fromArray(array $data): self;
}
EventStoreInterface
interface EventStoreInterface
{
public function append(string $aggregateId, EventStream $events, int $expectedVersion): void;
public function load(string $aggregateId): EventStream;
public function loadFromVersion(string $aggregateId, int $fromVersion): EventStream;
}
EventStream
final class EventStream implements \IteratorAggregate, \Countable
{
public static function empty(): self;
public static function fromEvents(array $events): self;
public function append(StoredEvent $event): self;
public function getVersion(): int;
public function isEmpty(): bool;
public function getIterator(): \ArrayIterator;
public function count(): int;
}
Usage Example
// Append events
$events = EventStream::fromEvents([
StoredEvent::fromDomainEvent($orderId, 'Order', 1, $orderCreated),
StoredEvent::fromDomainEvent($orderId, 'Order', 2, $itemAdded),
]);
$eventStore->append($orderId, $events, expectedVersion: 0);
// Load and replay
$stream = $eventStore->load($orderId);
foreach ($stream as $event) {
$aggregate->apply($event);
}
Database Schema
CREATE TABLE event_store (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
aggregate_id VARCHAR(36) NOT NULL,
aggregate_type VARCHAR(255) NOT NULL,
event_type VARCHAR(255) NOT NULL,
payload JSON NOT NULL,
version INT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX idx_aggregate_version (aggregate_id, version),
INDEX idx_aggregate_type (aggregate_type),
INDEX idx_event_type (event_type),
INDEX idx_created_at (created_at)
);
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| Mutable Events | History changes | Immutable StoredEvent |
| Missing Version | No optimistic locking | Version per aggregate |
| No Idempotency | Duplicate appends | Unique aggregate_id + version |
| Large Payloads | Slow reads | Serialize only essential data |
| No Snapshots | Slow rebuilds for long streams | Use create-snapshot |
| Global Stream Only | Can't load per-aggregate | Per-aggregate stream support |
References
For complete PHP templates and examples, see:
references/templates.md— StoredEvent, EventStream, EventStoreInterface, DoctrineEventStore templatesreferences/examples.md— Order event store usage and tests
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 为 PHP 8.4 生成完整的事件存储模式,包含事件流、存储事件、乐观锁和版本跟踪
- 提供单元测试,确保代码质量与可靠性
- 适用于事件溯源、审计追踪、事件重放等高频刚需场景
亮点
- 触发词精准完整,明确描述生成事件存储模式的核心功能
- 覆盖多种变体,边界清晰,不易误触或漏触
亮点
- Phase/步骤清晰(Step 1/2/3),有出口条件
- 含端到端示例,frontmatter完整,单文件≤500行
- 提供快速模板参考和使用示例,便于理解与执行
待提升项
-
引用文件缺失 原报告严重程度:轻微
SKILL.md 引用了 references/templates.md 和 references/examples.md 文件,但未传入
改进建议:请补充 references 目录下的模板和示例文件,或移除相关引用
亮点
- 工具来源明确(PHP 8.4),参数正确
- 覆盖主要异常(如乐观锁冲突),不可逆操作有确认机制(expectedVersion)
- 提供数据库 schema 和反模式避免指南,提升执行可靠性
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。