From harness-claude
Implements JavaScript Strategy pattern with plain functions for interchangeable algorithms. Swap at runtime via config to avoid if/else blocks for varying behaviors.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Define a family of algorithms and make them interchangeable without altering the client
Implements GOF Strategy pattern in TypeScript to encapsulate swappable algorithms behind interfaces for runtime selection. Replaces if/else chains in sorting, pricing, routing.
Generates PHP 8.4 Strategy pattern with interface, concrete strategies, resolver, optional service, and unit tests for interchangeable algorithm families like pricing or sorting.
Implements Strategy pattern in Laravel: shared interface, multiple implementations, factory for runtime selection by key/context, bound via service provider.
Share bugs, ideas, or general feedback.
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