event-sourcing-knowledge

Event sourcing knowledge base. Provide patterns and anti-patterns for auditing event-sourced architectures, along with PHP-specific guidance to help assess and improve event sourcing implementations.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "event-sourcing-knowledge" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1a55f4cff1088d2bf2e11748f42c1150bb33b5855fc7930089851d63e18ffe47. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Event sourcing knowledge base. Provide patterns and anti-patterns for auditing event-sourced architectures, along with PHP-specific guidance to help assess and improve event sourcing implementations.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Event Sourcing knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Event Sourcing architecture audits.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: event-sourcing-knowledge
description: Event Sourcing knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Event Sourcing architecture audits.

Event Sourcing Knowledge Base

Quick reference for Event Sourcing architecture patterns and PHP implementation guidelines.

Core Principles

Event Sourcing Fundamentals

Traditional Storage:          Event Sourcing:
┌─────────────────┐           ┌─────────────────┐
│  Current State  │           │  Event Stream   │
│  ─────────────  │           │  ─────────────  │
│  Order #123     │           │  1. OrderCreated│
│  Status: Paid   │           │  2. ItemAdded   │
│  Total: $150    │           │  3. ItemAdded   │
└─────────────────┘           │  4. OrderPaid   │
       ↓                      └────────┬────────┘
  Direct update                        │
                                       ▼
                              ┌─────────────────┐
                              │  Current State  │
                              │  (Rebuilt from  │
                              │   events)       │
                              └─────────────────┘

Rule: Store events, derive state. Never modify events.

Key Concepts

Concept Description
Event Immutable record of something that happened
Event Store Append-only storage for events
Event Stream Ordered sequence of events for one aggregate
Aggregate Consistency boundary, rebuilt from events
Projection Read model built by processing events
Snapshot Cached aggregate state for performance

Quick Checklists

Event Checklist

  • [ ] Named in past tense (OrderCreated, ItemAdded)
  • [ ] Immutable (readonly class)
  • [ ] Contains all data needed to apply change
  • [ ] Has metadata (timestamp, causation, correlation IDs)
  • [ ] No business logic
  • [ ] Versioned for schema evolution

Aggregate Checklist

  • [ ] State rebuilt from events only
  • [ ] apply*() methods modify state from events
  • [ ] record*() methods create and apply events
  • [ ] No direct state modification
  • [ ] Returns uncommitted events for persistence

Event Store Checklist

  • [ ] Append-only (no updates, no deletes)
  • [ ] Ordered within stream
  • [ ] Supports optimistic concurrency
  • [ ] Events never modified
  • [ ] Stream position tracking

Projection Checklist

  • [ ] Idempotent event handlers
  • [ ] Can be rebuilt from scratch
  • [ ] Handles event ordering
  • [ ] Tracks processed position

Common Violations Quick Reference

Violation Where to Look Severity
Mutable event Event with setters Critical
Direct state mutation Aggregate bypassing events Critical
Missing event data Event without full state info Critical
Event with logic Event doing calculations Warning
Non-idempotent projection Projection with side effects Warning
Missing metadata Event without timestamp/IDs Warning

PHP 8.4 Event Sourcing Patterns

Domain Event

final readonly class OrderConfirmedEvent
{
    public function __construct(
        public string $orderId,
        public int $totalCents,
        public string $currency,
        public DateTimeImmutable $confirmedAt,
        public EventMetadata $metadata
    ) {}
}

final readonly class EventMetadata
{
    public function __construct(
        public string $eventId,
        public DateTimeImmutable $occurredAt,
        public ?string $causationId = null,
        public ?string $correlationId = null,
        public int $version = 1
    ) {}
}

Event-Sourced Aggregate

final class Order extends EventSourcedAggregate
{
    private OrderStatus $status;
    private Money $total;

    public static function create(OrderId $id, CustomerId $customerId): self
    {
        $order = new self($id);
        $order->recordThat(new OrderCreatedEvent(
            orderId: $id->value,
            customerId: $customerId->value,
            createdAt: new DateTimeImmutable()
        ));
        return $order;
    }

    public function confirm(): void
    {
        if ($this->status !== OrderStatus::Draft) {
            throw new InvalidStateException();
        }
        $this->recordThat(new OrderConfirmedEvent(
            orderId: $this->id->value,
            totalCents: $this->total->cents(),
            currency: $this->total->currency(),
            confirmedAt: new DateTimeImmutable()
        ));
    }

    protected function applyOrderCreatedEvent(OrderCreatedEvent $event): void
    {
        $this->status = OrderStatus::Draft;
        $this->total = Money::zero('USD');
    }

    protected function applyOrderConfirmedEvent(OrderConfirmedEvent $event): void
    {
        $this->status = OrderStatus::Confirmed;
    }
}

Projection

final class OrderListProjection
{
    public function __construct(
        private Connection $connection
    ) {}

    public function applyOrderCreatedEvent(OrderCreatedEvent $event): void
    {
        $this->connection->insert('order_list', [
            'id' => $event->orderId,
            'customer_id' => $event->customerId,
            'status' => 'draft',
            'created_at' => $event->createdAt->format('Y-m-d H:i:s'),
        ]);
    }

    public function applyOrderConfirmedEvent(OrderConfirmedEvent $event): void
    {
        $this->connection->update('order_list', [
            'status' => 'confirmed',
            'total_cents' => $event->totalCents,
            'confirmed_at' => $event->confirmedAt->format('Y-m-d H:i:s'),
        ], ['id' => $event->orderId]);
    }
}

References

For detailed information, load these reference files:

  • references/event-store-patterns.md — Event persistence, streams, concurrency
  • references/projection-patterns.md — Read model projections
  • references/snapshot-patterns.md — Performance optimization with snapshots
  • references/versioning-patterns.md — Event schema evolution
  • references/antipatterns.md — Common violations with detection patterns

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供事件溯源架构审计的模式、反模式及 PHP 特定指南,具有明确的实用价值
  • 内容涵盖核心原则、快速检查清单、常见违规快速参考等,适合广泛受众
Trigger Precision95/100

Highlights

  • description 明确描述了 Skill 的功能和用途,触发词精准完整
  • 覆盖多种变体,边界清晰,用户能准确理解 Skill 的适用范围
Structure and Standards90/100

Highlights

  • 结构清晰,包含多个章节和详细的代码示例
  • frontmatter 完整,单文件未超过 500 行,符合规范要求
Execution Reliability85/100

Highlights

  • 提供了详细的 PHP 代码示例和最佳实践
  • 工具来源明确,参数正确,覆盖主要异常,执行可靠性高
Evidence Verifiability (mean of the first four)89/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.