acc-eda-knowledge

Event-Driven Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for EDA audits including messaging, pub/sub, and saga patterns.

181 stars

Best use case

acc-eda-knowledge is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Event-Driven Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for EDA audits including messaging, pub/sub, and saga patterns.

Teams using acc-eda-knowledge should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/acc-eda-knowledge/SKILL.md --create-dirs "https://raw.githubusercontent.com/majiayu000/claude-skill-registry/main/skills/data/acc-eda-knowledge/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/acc-eda-knowledge/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How acc-eda-knowledge Compares

Feature / Agentacc-eda-knowledgeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Event-Driven Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for EDA audits including messaging, pub/sub, and saga patterns.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Event-Driven Architecture Knowledge Base

Quick reference for Event-Driven Architecture (EDA) patterns and PHP implementation guidelines.

## Core Principles

### Event-Driven Architecture Overview

```
┌─────────────────────────────────────────────────────────────────────────┐
│                     EVENT-DRIVEN ARCHITECTURE                            │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   ┌──────────┐     ┌──────────────────┐     ┌──────────────────┐        │
│   │ Producer │────▶│  Message Broker  │────▶│    Consumer      │        │
│   │          │     │  (RabbitMQ/Kafka)│     │                  │        │
│   └──────────┘     └──────────────────┘     └──────────────────┘        │
│        │                    │                       │                    │
│        │                    │                       │                    │
│   Publishes            Routes/Stores            Subscribes               │
│   Events               Messages                 to Events                │
│                                                                          │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   Event Types:                                                           │
│   • Domain Events    - Business facts (OrderPlaced, PaymentReceived)     │
│   • Integration Events - Cross-boundary communication                    │
│   • System Events    - Infrastructure notifications                      │
│                                                                          │
│   Patterns:                                                              │
│   • Pub/Sub          - Many subscribers per event                        │
│   • Message Queue    - One consumer per message                          │
│   • Event Sourcing   - Store all events as source of truth              │
│   • Saga/Process Manager - Coordinate distributed transactions          │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘
```

### Key Concepts

| Concept | Description |
|---------|-------------|
| Event | Immutable fact that something happened |
| Producer | Publishes events to broker |
| Consumer | Subscribes to and processes events |
| Message Broker | Routes events between producers and consumers |
| Topic/Exchange | Event routing mechanism |
| Queue | Stores messages for consumers |
| Eventual Consistency | System state converges over time |

## Quick Checklists

### Event Design Checklist

- [ ] Events are immutable
- [ ] Events use past tense (OrderPlaced, not PlaceOrder)
- [ ] Events contain necessary data (no fetching needed)
- [ ] Events have unique IDs and timestamps
- [ ] Events include correlation/causation IDs
- [ ] Events are versioned for schema evolution

### Producer Checklist

- [ ] Publishes events after state change
- [ ] Uses transactional outbox for reliability
- [ ] Events are serializable (JSON/Protobuf)
- [ ] Handles publish failures gracefully
- [ ] No business logic dependent on consumers

### Consumer Checklist

- [ ] Idempotent processing
- [ ] Handles out-of-order events
- [ ] Implements retry with backoff
- [ ] Dead letter queue for failures
- [ ] No side effects until processing complete

## PHP 8.5 Event-Driven Patterns

### Domain Event

```php
<?php

declare(strict_types=1);

namespace Domain\Order\Event;

use Domain\Shared\Event\DomainEvent;

final readonly class OrderPlaced implements DomainEvent
{
    public function __construct(
        public string $eventId,
        public string $orderId,
        public string $customerId,
        public int $totalCents,
        public \DateTimeImmutable $occurredAt,
        public ?string $correlationId = null,
        public ?string $causationId = null
    ) {}

    public function eventName(): string
    {
        return 'order.placed';
    }

    public function aggregateId(): string
    {
        return $this->orderId;
    }

    public function toArray(): array
    {
        return [
            'event_id' => $this->eventId,
            'order_id' => $this->orderId,
            'customer_id' => $this->customerId,
            'total_cents' => $this->totalCents,
            'occurred_at' => $this->occurredAt->format('c'),
            'correlation_id' => $this->correlationId,
            'causation_id' => $this->causationId,
        ];
    }
}
```

### Event Publisher Interface

```php
<?php

declare(strict_types=1);

namespace Application\Shared\Port\Output;

use Domain\Shared\Event\DomainEvent;

interface EventPublisherInterface
{
    public function publish(DomainEvent $event): void;

    /** @param array<DomainEvent> $events */
    public function publishAll(array $events): void;
}
```

### Event Consumer/Handler

```php
<?php

declare(strict_types=1);

namespace Application\Order\EventHandler;

use Application\Shared\Port\Output\EventHandlerInterface;
use Domain\Order\Event\OrderPlaced;

final readonly class SendOrderConfirmationEmail implements EventHandlerInterface
{
    public function __construct(
        private EmailServiceInterface $emailService,
        private CustomerRepositoryInterface $customers
    ) {}

    public function __invoke(OrderPlaced $event): void
    {
        $customer = $this->customers->findById($event->customerId);

        $this->emailService->send(
            to: $customer->email(),
            template: 'order-confirmation',
            data: [
                'order_id' => $event->orderId,
                'total' => $event->totalCents / 100,
            ]
        );
    }

    public static function subscribedTo(): string
    {
        return OrderPlaced::class;
    }
}
```

### RabbitMQ Publisher (Infrastructure)

```php
<?php

declare(strict_types=1);

namespace Infrastructure\Messaging\RabbitMQ;

use Application\Shared\Port\Output\EventPublisherInterface;
use Domain\Shared\Event\DomainEvent;
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Message\AMQPMessage;

final readonly class RabbitMQEventPublisher implements EventPublisherInterface
{
    public function __construct(
        private AMQPChannel $channel,
        private string $exchangeName
    ) {}

    public function publish(DomainEvent $event): void
    {
        $message = new AMQPMessage(
            json_encode($event->toArray()),
            [
                'content_type' => 'application/json',
                'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT,
                'message_id' => $event->eventId,
                'timestamp' => $event->occurredAt->getTimestamp(),
            ]
        );

        $this->channel->basic_publish(
            $message,
            $this->exchangeName,
            $event->eventName()
        );
    }

    public function publishAll(array $events): void
    {
        foreach ($events as $event) {
            $this->publish($event);
        }
    }
}
```

## Common Violations Quick Reference

| Violation | Where to Look | Severity |
|-----------|---------------|----------|
| Synchronous calls disguised as events | Consumer calls HTTP API | Critical |
| Missing idempotency | No deduplication check | Critical |
| Tight coupling via events | Event contains entity references | Warning |
| Fire and forget | No error handling on publish | Warning |
| Blocking consumer | Slow processing without async | Warning |

## Detection Patterns

```bash
# Find event classes
Glob: **/Event/**/*Event.php
Glob: **/Events/**/*.php

# Check for event publishers
Grep: "EventPublisher|EventDispatcher|publish\(" --glob "**/*.php"

# Find event handlers/consumers
Grep: "implements.*EventHandler|implements.*Consumer" --glob "**/*.php"

# Check for message broker usage
Grep: "AMQPChannel|RabbitMQ|Kafka" --glob "**/Infrastructure/**/*.php"

# Find potential issues
Grep: "new.*Event\(" --glob "**/Controller/**/*.php"  # Events in controllers
Grep: "->findById|->save" --glob "**/EventHandler/**/*.php"  # Sync calls in handlers
```

## References

For detailed information, load these reference files:

- `references/event-patterns.md` — Event types, structure, publishing patterns
- `references/messaging-patterns.md` — Message broker patterns, queues, topics
- `references/saga-patterns.md` — Distributed transactions, choreography, orchestration
- `references/antipatterns.md` — Common violations with detection patterns

Related Skills

adr-knowledge-base

181
from majiayu000/claude-skill-registry

ADR知見の体系的参照・適用。主要ADR抜粋(ADR_010, 013, 016, 019, 020, 021)・ADR検索・参照方法・技術決定パターン集・ADR作成判断基準。Phase C以降の技術決定時に使用。

add-knowledge

181
from majiayu000/claude-skill-registry

Add notes and learnings to Tim's work knowledge base at Spotify from any Claude Code session

acc-testing-knowledge

181
from majiayu000/claude-skill-registry

Testing knowledge base for PHP 8.5 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

acc-stability-patterns-knowledge

181
from majiayu000/claude-skill-registry

Stability Patterns knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Circuit Breaker, Retry, Rate Limiter, Bulkhead, and resilience audits.

acc-solid-knowledge

181
from majiayu000/claude-skill-registry

SOLID principles knowledge base for PHP 8.5 projects. Provides quick reference for SRP, OCP, LSP, ISP, DIP with detection patterns, PHP examples, and antipattern identification. Use for architecture audits and code quality reviews.

acc-saga-pattern-knowledge

181
from majiayu000/claude-skill-registry

Saga Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for saga orchestration, choreography, and distributed transaction audits.

acc-psr-overview-knowledge

181
from majiayu000/claude-skill-registry

PHP Standards Recommendations (PSR) overview knowledge base. Provides comprehensive reference for all accepted PSRs including PSR-1,3,4,6,7,11,12,13,14,15,16,17,18,20. Use for PSR selection decisions and compliance audits.

acc-psr-coding-style-knowledge

181
from majiayu000/claude-skill-registry

PSR-1 and PSR-12 coding standards knowledge base for PHP 8.5 projects. Provides quick reference for basic coding standard and extended coding style with detection patterns, examples, and antipattern identification. Use for code style audits and compliance reviews.

acc-psr-autoloading-knowledge

181
from majiayu000/claude-skill-registry

PSR-4 autoloading standard knowledge base for PHP 8.5 projects. Provides quick reference for namespace-to-path mapping, composer.json configuration, directory structure, and common mistakes. Use for autoloading audits and project structure reviews.

acc-outbox-pattern-knowledge

181
from majiayu000/claude-skill-registry

Outbox Pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for transactional outbox, polling publisher, and reliable messaging audits.

acc-layer-arch-knowledge

181
from majiayu000/claude-skill-registry

Layered Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for traditional N-tier/Layered Architecture audits.

acc-hexagonal-knowledge

181
from majiayu000/claude-skill-registry

Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture audits.