acc-create-mediator
Generates Mediator pattern for PHP 8.5. Creates coordination layer for complex component interactions with event dispatching, request/response handling, and colleague classes. Reduces coupling between interacting objects. Includes unit tests.
Best use case
acc-create-mediator is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates Mediator pattern for PHP 8.5. Creates coordination layer for complex component interactions with event dispatching, request/response handling, and colleague classes. Reduces coupling between interacting objects. Includes unit tests.
Teams using acc-create-mediator should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-create-mediator/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-create-mediator Compares
| Feature / Agent | acc-create-mediator | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates Mediator pattern for PHP 8.5. Creates coordination layer for complex component interactions with event dispatching, request/response handling, and colleague classes. Reduces coupling between interacting objects. Includes unit tests.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Mediator Pattern Generator
## Overview
Generates Mediator pattern components for PHP 8.5 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
<?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
<?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
<?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 examplesRelated Skills
acc-create-value-object
Generates DDD Value Objects for PHP 8.5. Creates immutable, self-validating objects with equality comparison. Includes unit tests.
acc-create-use-case
Generates Application Use Cases for PHP 8.5. Creates orchestration services that coordinate domain objects, handle transactions, and dispatch events. Includes unit tests.
acc-create-unit-test
Generates PHPUnit unit tests for PHP 8.5. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.
acc-create-test-double
Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.5. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.
acc-create-test-builder
Generates Test Data Builder and Object Mother patterns for PHP 8.5. Creates fluent builders with sensible defaults and factory methods for test data creation.
acc-create-strategy
Generates Strategy pattern for PHP 8.5. Creates interchangeable algorithm families with context class, strategy interface, and concrete implementations. Includes unit tests.
acc-create-state
Generates State pattern for PHP 8.5. Creates state machines with context, state interface, and concrete states for behavior changes. Includes unit tests.
acc-create-specification
Generates DDD Specification for PHP 8.5. Creates reusable business rule objects for validation, filtering, and querying with composite pattern support. Includes unit tests.
acc-create-saga-pattern
Generates Saga pattern components for PHP 8.5. Creates Saga interfaces, steps, orchestrator, state management, and compensation logic with unit tests.
acc-create-retry-pattern
Generates Retry pattern for PHP 8.5. Creates resilience component with exponential backoff, jitter, and configurable retry strategies. Includes unit tests.
acc-create-responder
Generates ADR Responder classes for PHP 8.5. Creates HTTP response builders with PSR-7/PSR-17 support. Includes unit tests.
acc-create-repository
Generates DDD Repository interfaces and implementation stubs for PHP 8.5. Creates domain interfaces in Domain layer, implementation in Infrastructure.