From acc
Generates Mediator pattern components for PHP 8.4 including mediator interface, colleagues, events, requests/responses, and unit tests. Use for coordinating complex object interactions and reducing coupling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-mediatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generates Mediator pattern components for PHP 8.4 to coordinate complex interactions between multiple objects without them referencing each other directly.
Generates Mediator pattern components for PHP 8.4 to coordinate complex interactions between multiple objects without them referencing each other directly.
| 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 |
<?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;
}
<?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;
}
<?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);
}
}
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
| 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 |
See references/ for detailed documentation:
templates.md - Full Mediator, Colleague, Command Bus, Event Mediator, Chat Room templatesexamples.md - Real-world examplesnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accCentralizes object communication into a mediator to reduce tangled dependencies. Use when many objects interact and you want loose coupling.
Generates Bridge pattern for PHP 8.4 projects, creating abstraction, refined abstraction, implementor interface, concrete implementors, and unit tests in Domain/Infrastructure structure. For decoupling with multiple variation dimensions or runtime switching.
Decouples components by routing communication through a central mediator or event bus. Provides classic mediator pattern and typed event bus implementations.