Event driven

From TheBeardedBearSAS/claude-craft · View interactive version

Event driven is an AI agent skill from the GitHub repository TheBeardedBearSAS/claude-craft. Event Sourcing, CQRS, Saga patterns, event bus (Kafka, RabbitMQ, AWS EventBridge). Use when implementing event-driven architecture, distributed transactions, or event sourcing.

How to use this skill

Skill file

Event-Driven — Event Sourcing, Saga, CQRS

Architecture événementielle pour découplage et scalabilité.

Patterns

Event Sourcing — Stocker events, pas état (audit, replay)

CQRS — Séparer Read/Write models (projections)

Saga — Transaction distribuée (microservices)

Event Bus — Pub/Sub découplé (Kafka, RabbitMQ)

Event Sourcing

events = [OrderCreated(...), OrderPaid(...), OrderShipped(...)]

def rebuild(events):
    state = {}
    for e in events: state = apply(state, e)
    return state

Saga — Choreography vs Orchestration

Choreography — Events chain services (découplé, debug dur)

Orchestration — Central coordinator (visible, couplé)

Choreo: OrderCreated → Payment → Shipping
Orchestrator: ProcessPayment() → ShipOrder()

Kafka Event Bus

// Producer
producer.send({ topic: 'orders', messages: [{ ... }] });

// Consumer
consumer.run({
  eachMessage: async ({ message }) => {
    handleEvent(JSON.parse(message.value));
  }
});

Domain Events (Symfony)

class OrderCreatedEvent {
    public function __construct(public Order $order) {}
}

class SendEmail {
    public function __invoke(OrderCreatedEvent $e) {
        $this->mailer->send($e->order->email, 'Confirmation');
    }
}

Voir @.claude/rules/21-cqrs.md, @.claude/skills/async/SKILL.md

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.