skills/design-patterns/behaviorals/pattern-mediator/SKILL.md
Teaches and applies the Mediator behavioral design pattern — reducing direct dependencies between objects by forcing them to communicate only through a mediator. Trigger: When decoupling tightly coupled components or implementing event buses.
npx skillsauth add johnnystefan/test-saas-business pattern-mediatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reduces chaotic dependencies between objects by forcing them to collaborate only through a mediator object.
notify() method that components use to report events.interface Mediator {
notify(sender: object, event: string): void;
}
class Dialog implements Mediator {
constructor(
private button: Button,
private textbox: Textbox,
) {
this.button.setMediator(this);
}
notify(sender: object, event: string) {
if (event === 'click') {
/* Coordination logic here */
}
}
}
class Button {
private mediator!: Mediator;
setMediator(m: Mediator) {
this.mediator = m;
}
click() {
this.mediator.notify(this, 'click');
}
}
tools
Zustand 5 state management patterns. Trigger: When implementing client-side state with Zustand (stores, selectors, persist middleware, slices).
databases
Zod 4 schema validation patterns. Trigger: When creating or updating Zod v4 schemas for validation/parsing (forms, request payloads, adapters), including v3 -> v4 migration patterns.
development
Vitest unit testing patterns with React Testing Library. Trigger: When writing unit tests for React components, hooks, or utilities.
tools
Vite 8 (Rolldown-powered) build tool configuration, plugin API, SSR, and migration guide. Trigger: When working with vite.config.ts, Vite plugins, building libraries, or SSR apps with Vite.