mediator-pattern

Route component interactions through a centralized mediator for decoupled communication.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/BrunoAMSilva/my-config --skill mediator-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mediator-pattern
Source: https://github.com/BrunoAMSilva/my-config/tree/main/coding/skills/mediator-pattern
Command: npx skills add https://github.com/BrunoAMSilva/my-config --skill mediator-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Centralizes communication between components to eliminate tight coupling, making systems easier to test, reuse, and evolve by routing interactions through a mediator rather than direct references.

Core Features & Use Cases

  • Decoupling components: Components send events or commands to a mediator instead of calling each other, improving reuse and testability.
  • Event bus / publish-subscribe: Support for typed event handlers so multiple services can react to the same event without mutual awareness.
  • CQRS command/query routing: Register command and query handlers with a mediator to enforce single responsibility and clear routing in complex workflows.
  • Use Cases: UI coordination (forms, inputs, buttons), backend order processing (inventory, shipping, email), analytics middleware, and domain-specific mediators to avoid God Objects.

Quick Start

Use the mediator-pattern guidance to replace direct component references with a mediator and register handlers to route commands, queries, or events across your domain.

Frequently Asked Questions about mediator-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decouple components in TypeScript to reduce tight coupling?

Decouple TypeScript components by routing their interactions through a centralized mediator, removing direct references so they communicate via events and commands without mutual awareness. This improves reuse and testability.

What is the mediator pattern and when should I use it for event-driven services?

The mediator pattern centralizes communication by routing interactions through a mediator object. Use it for event-driven services, UI coordination, or backend workflows to eliminate tight coupling and manage multi-step processes cleanly.

How do I implement CQRS command and query routing with a mediator?

Implement CQRS routing by registering distinct command and query handlers with a mediator. The mediator routes requests to the correct handlers, enforcing single responsibility and clear routing for complex workflows.

Can I use a mediator pattern for both frontend UI coordination and backend order processing?

Yes, applying the mediator pattern works for both frontend UI coordination, like synchronizing forms and buttons, and backend order processing, like managing inventory and shipping, by routing all interactions centrally.

How does typed event publish-subscribe work with a mediator?

Typed event publish-subscribe works by registering typed event handlers with a mediator. When an event is published, the mediator routes it to all matching handlers, allowing multiple services to react without direct references.

When should I avoid using a mediator pattern in my architecture?

Avoid the mediator pattern when component interactions are simple and direct, as introducing a mediator adds unnecessary routing overhead. It is best suited for complex systems requiring decoupled, multi-step workflows and traceability.