From harness-claude
Implements the Strategy Pattern in JavaScript, enabling swapping algorithms at runtime via plain functions or a strategy registry.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-strategy-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Define a family of algorithms and make them interchangeable without altering the client
Define a family of algorithms and make them interchangeable without altering the client
// Strategies as plain functions
const strategies = {
add: (a, b) => a + b,
subtract: (a, b) => a - b,
multiply: (a, b) => a * b,
};
function calculate(strategy, a, b) {
if (!strategies[strategy]) throw new Error(`Unknown strategy: ${strategy}`);
return strategies[strategy](a, b);
}
calculate('add', 5, 3); // 8
calculate('multiply', 5, 3); // 15
The Strategy pattern separates the "what" from the "how." The context knows what operation to perform but delegates the implementation to an interchangeable strategy. In JavaScript, first-class functions make this pattern lightweight — a strategy is just a function.
Trade-offs:
When NOT to use:
https://patterns.dev/javascript/strategy-pattern
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeEncapsulates interchangeable algorithms behind a common interface for runtime selection, eliminating large if/else chains. Provides code examples for both class-based and idiomatic TypeScript function-based strategies.
Encapsulates interchangeable algorithms in separate classes, enabling runtime swapping without conditional logic. Useful when multiple behaviors exist for a task.
Generates PHP 8.4 Strategy pattern with interface, concrete strategies, resolver, optional service, and unit tests for interchangeable algorithm families like pricing or sorting.