agentleFS
troskatertroskater/flowdeck-claude/skills/event-driven-architecture/SKILL.md

event-driven-architecture

Skill0 starsChanged 23 days agoMITView on GitHub

Event-driven architecture patterns for asynchronous workflows and decoupled services.

13 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use correlation IDs to track event chains

    line 53
  2. Distinctive:

    Use persistent message storage (not in-memory)

    line 59

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Event-Driven Architecture

When to Activate

Activate when:

  • Designing or implementing message-based communication between services
  • Building systems that require asynchronous processing
  • Decoupling producers from consumers in distributed systems
  • Implementing event sourcing or audit trails
  • Setting up webhooks, message queues, or pub/sub patterns

Steps

1. Identify Event Boundaries

Define what constitutes an "event" in your system:

  • Events are facts about something that happened (past tense: OrderPlaced, PaymentProcessed)
  • Commands are requests for an action (present tense: PlaceOrder, ProcessPayment)
  • Events should be immutable once emitted

2. Choose the Right Messaging Pattern

PatternUse CaseExamples
Pub/SubOne-to-many notificationNotifications, audit logs
Message QueuePoint-to-point processingOrder processing, email sending
Event StreamingDurable, replayable event logEvent sourcing, analytics
WebhooksExternal system integrationHTTP callbacks

3. Design Event Schema

interface Event<T> {
  id: string;           // Unique event identifier (UUID)
  type: string;         // Event type (e.g., "ORDER_PLACED")
  version: string;      // Schema version for evolution
  timestamp: string;    // ISO 8601 timestamp
  source: string;       // Origin service name
  data: T;             // Event payload
  metadata?: Record<string, unknown>;  // Optional tracing/correlation
}

4. Handle Eventual Consistency

  • Design consumers to be idempotent (safe to process twice)
  • Use correlation IDs to track event chains
  • Implement dead letter queues for failed processing
  • Set retry policies with exponential backoff

5. Ensure Durability

  • Use persistent message storage (not in-memory)
  • Acknowledge messages only after successful processing
  • Implement at-least-once delivery semantics

Examples

TypeScript Event Emitter

interface OrderEvent {
  orderId: string;
  customerId: string;
  total: number;
  items: OrderItem[];
}

class OrderEventPublisher {
  private emitter: EventEmitter;

  async publishOrderPlaced(event: OrderEvent): Promise<void> {
    const message: Event<OrderEvent> = {
      id: crypto.randomUUID(),
      type: 'ORDER_PLACED',
      version: '1.0',
      timestamp: new Date().toISOString(),
      source: 'order-service',
      data: event,
      metadata: {
        correlationId: event.orderId,
        partitionKey: event.customerId
      }
    };

    await this.messageBroker.publish('orders.placed', message);
  }
}

Message Consumer with Retry

class OrderEventConsumer {
  async handleOrderPlaced(event: Event<OrderEvent>): Promise<void> {
    try {
      // Idempotent processing
      const existingOrder = await this.orderRepo.findById(event.data.orderId);
      if (existingOrder) {
        logger.info('Order already processed, skipping', { orderId: event.data.orderId });
        return;
      }

      await this.orderService.processOrder(event.data);
      await this.messageBroker.ack(event.id);
    } catch (error) {
      if (error instanceof TransientError) {
        // Requeue with delay for retry
        await this.messageBroker.requeue(event.id, { delay: 5000 });
      } else {
        // Send to dead letter queue
        await this.messageBroker.sendToDlq(event, error);
      }
    }
  }
}

Event Schema Registry

// contracts/order-events.ts
export const OrderPlacedEventSchema = {
  type: 'object',
  required: ['orderId', 'customerId', 'total', 'items'],
  properties: {
    orderId: { type: 'string', format: 'uuid' },
    customerId: { type: 'string', format: 'uuid' },
    total: { type: 'number', minimum: 0 },
    items: {
      type: 'array',
      items: {
        type: 'object',
        required: ['productId', 'quantity', 'price'],
        properties: {
          productId: { type: 'string' },
          quantity: { type: 'number', minimum: 1 },
          price: { type: 'number', minimum: 0 }
        }
      }
    }
  }
};

Related Skills

  • api-design
  • backend-patterns
  • cqrs
  • event-sourcing
  • message-queues

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.