From harness-claude
Implements the Chain of Responsibility pattern in JavaScript, passing requests through a chain of handlers until one processes it. Useful for validation chains, auth pipelines, and event bubbling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-chain-of-responsibility-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Pass a request along a chain of handlers until one handles it
Pass a request along a chain of handlers until one handles it
handle(request) method and a setNext(handler) reference.h1.setNext(h2).setNext(h3).class Handler {
setNext(handler) {
this.next = handler;
return handler;
}
handle(request) {
if (this.next) return this.next.handle(request);
return null;
}
}
class AuthHandler extends Handler {
handle(req) {
if (!req.token) return { error: 'Unauthorized' };
return super.handle(req);
}
}
class RateLimitHandler extends Handler {
handle(req) {
if (req.rateLimited) return { error: 'Too many requests' };
return super.handle(req);
}
}
The Chain of Responsibility pattern decouples senders from receivers by giving multiple objects a chance to handle a request. The request travels along the chain until a handler processes it or it reaches the end. Express.js middleware is a functional variant of this pattern.
Trade-offs:
When NOT to use:
https://patterns.dev/javascript/chain-of-responsibility-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeImplements the Chain of Responsibility pattern with linked handler chains and async middleware pipelines. Useful for request routing, validation, and event processing.
Implements Chain of Responsibility pattern to decouple request senders from handlers, passing requests along a chain until handled.
Generates Chain of Responsibility pattern for PHP 8.4, creating handler chains for middleware-style request processing like validation and approvals. Includes unit tests.