create-mediator

Generate a Mediator pattern implementation for PHP 8.4. Create a coordination layer for complex component interactions that supports event dispatching, request/response handling, and colleague classes to reduce coupling between interacting objects. Includes unit tests.

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 "create-mediator" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-05abc6d171ebafd89e9da9316ff90e471d346e6dfb5e12dbd8fb5f0358c932fb. 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

Generate a Mediator pattern implementation for PHP 8.4. Create a coordination layer for complex component interactions that supports event dispatching, request/response handling, and colleague classes to reduce coupling between interacting objects. Includes unit tests.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Mediator pattern for PHP 8.4. Creates coordination layer for complex component interactions with event dispatching, request/response handling, and colleague classes. Reduces coupling between interacting objects. Includes unit tests.
Audience
Complex communication between multiple objects Reducing coupling in event-driven systems Coordinating UI components or form elements Command bus / Query bus implementation Chat room / notification hub scenarios Workflow coordination
Inputs and outputs
1. **Name** - Mediator name (e.g., "OrderWorkflow", "ChatRoom") 2. **Context** - Bounded context (e.g., "Order", "Notification") 3. **Colleagues** - List of participating components 4. **Events** - Events to coordinate (optional)
Software, accounts and paid services
1. **Name** - Mediator name (e.g., "OrderWorkflow", "ChatRoom") 2. **Context** - Bounded context (e.g., "Order", "Notification") 3. **Colleagues** - List of participating components 4. **Events** - Events to coordinate (optional)
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: create-mediator
description: Generates Mediator pattern for PHP 8.4. Creates coordination layer for complex component interactions with event dispatching, request/response handling, and colleague classes. Reduces coupling between interacting objects. Includes unit tests.

Mediator Pattern Generator

Overview

Generates Mediator pattern components for PHP 8.4 to coordinate complex interactions between multiple objects without them referencing each other directly.

When to Use

  • Complex communication between multiple objects
  • Reducing coupling in event-driven systems
  • Coordinating UI components or form elements
  • Command bus / Query bus implementation
  • Chat room / notification hub scenarios
  • Workflow coordination

Generated Components

Component Location Purpose
MediatorInterface src/Application/{Context}/Mediator/ Defines mediation contract
ConcreteMediator src/Application/{Context}/Mediator/ Implements coordination logic
ColleagueInterface src/Application/{Context}/Mediator/Colleague/ Participant contract
AbstractColleague src/Application/{Context}/Mediator/Colleague/ Base with mediator access
ConcreteColleagues src/Application/{Context}/Mediator/Colleague/ Participating components
Tests tests/{Context}/Application/Mediator/ Unit tests

Input Requirements

  1. Name - Mediator name (e.g., "OrderWorkflow", "ChatRoom")
  2. Context - Bounded context (e.g., "Order", "Notification")
  3. Colleagues - List of participating components
  4. Events - Events to coordinate (optional)

Template: Mediator Interface

<?php

declare(strict_types=1);

namespace App\{Context}\Application\Mediator;

use App\{Context}\Application\Mediator\Colleague\ColleagueInterface;

interface {Name}Mediator
{
    public function notify(ColleagueInterface $sender, string $event, mixed $data = null): void;
    public function register(ColleagueInterface $colleague): void;
    public function send(string $request, mixed $data = null): mixed;
}

Template: Colleague Interface

<?php

declare(strict_types=1);

namespace App\{Context}\Application\Mediator\Colleague;

use App\{Context}\Application\Mediator\{Name}Mediator;

interface ColleagueInterface
{
    public function getName(): string;
    public function setMediator({Name}Mediator $mediator): void;
    public function handle(mixed $data): mixed;
}

Template: Abstract Colleague

<?php

declare(strict_types=1);

namespace App\{Context}\Application\Mediator\Colleague;

use App\{Context}\Application\Mediator\{Name}Mediator;

abstract class AbstractColleague implements ColleagueInterface
{
    protected ?{Name}Mediator $mediator = null;

    public function setMediator({Name}Mediator $mediator): void
    {
        $this->mediator = $mediator;
    }

    protected function notify(string $event, mixed $data = null): void
    {
        if ($this->mediator === null) {
            throw new MediatorNotSetException();
        }
        $this->mediator->notify($this, $event, $data);
    }

    protected function send(string $request, mixed $data = null): mixed
    {
        if ($this->mediator === null) {
            throw new MediatorNotSetException();
        }
        return $this->mediator->send($request, $data);
    }
}

File Placement

src/
└── {Context}/
    └── Application/
        └── Mediator/
            ├── {Name}Mediator.php           # Interface
            ├── {Name}MediatorImpl.php       # Implementation
            └── Colleague/
                ├── ColleagueInterface.php   # Base interface
                ├── AbstractColleague.php    # Base class
                └── {Colleague}.php          # Participants

tests/
└── {Context}/
    └── Application/
        └── Mediator/
            └── {Name}MediatorTest.php       # Tests

GRASP Compliance

Principle Implementation
Low Coupling Colleagues don't know each other
Indirection Mediator provides indirection layer
Controller Mediator coordinates use case flow
Pure Fabrication Mediator is artificial coordinating class

References

See references/ for detailed documentation:

  • templates.md - Full Mediator, Colleague, Command Bus, Event Mediator, Chat Room templates
  • examples.md - Real-world examples

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 Precision90/100

Highlights

  • 触发描述精准完整,涵盖多种变体和使用边界,用户可清晰识别适用场景
Structure and Standards90/100

Highlights

  • 结构清晰,分阶段说明,提供完整模板与文件布局,符合最佳实践
Execution Reliability85/100

Highlights

  • 模板代码规范,包含异常处理与单元测试,执行可靠性高
Evidence Verifiability (mean of the first four)88/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.

1. **Name** - Mediator name (e.g., "OrderWorkflow", "ChatRoom") 2. **Context** - Bounded context (e.g., "Order", "Notification") 3. **Colleagues** - List of participating components 4. **Events** - Events to coordinate (optional)

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