From harness-claude
Routes component interactions through a central mediator or middleware pipeline to reduce direct coupling. Useful for cross-cutting concerns like logging, auth, and validation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-mediator-middleware-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Route component interactions through a central mediator to reduce direct coupling
Route component interactions through a central mediator to reduce direct coupling
next() pipelines)(req, res, next) (or equivalent) and call next() to pass control.next('skip') or returning early).// Middleware pipeline
class Pipeline {
constructor() {
this.middlewares = [];
}
use(fn) {
this.middlewares.push(fn);
return this;
}
execute(context) {
let index = 0;
const next = () => {
const fn = this.middlewares[index++];
if (fn) fn(context, next);
};
next();
}
}
const pipeline = new Pipeline();
pipeline
.use((ctx, next) => {
ctx.log = [];
next();
})
.use((ctx, next) => {
ctx.log.push('step1');
next();
})
.use((ctx) => {
ctx.log.push('step2');
});
const ctx = {};
pipeline.execute(ctx);
console.log(ctx.log); // ['step1', 'step2']
The Mediator pattern (GoF) centralizes communication. The Middleware pattern (popularized by Express.js) is a sequential pipeline variant. Both reduce point-to-point coupling by routing interactions through a shared hub or chain.
Trade-offs:
When NOT to use:
https://patterns.dev/javascript/mediator-middleware-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeDecouples components by routing communication through a central mediator or event bus. Provides classic mediator pattern and typed event bus implementations.
Centralizes object communication into a mediator to reduce tangled dependencies. Use when many objects interact and you want loose coupling.
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.