skills/design-patterns/behaviorals/pattern-strategy/SKILL.md
Teaches and applies the Strategy behavioral design pattern — defining a family of algorithms, encapsulating each one, and making them interchangeable at runtime. Trigger: When implementing interchangeable algorithms, sorting strategies, or payment methods.
npx skillsauth add johnnystefan/test-saas-business pattern-strategyInstall 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.
Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
interface RouteStrategy {
buildRoute(a: string, b: string): void;
}
class WalkingStrategy implements RouteStrategy {
buildRoute(a: string, b: string) {
console.log('Walking route...');
}
}
class Navigator {
// Context
private strategy!: RouteStrategy;
setStrategy(s: RouteStrategy) {
this.strategy = s;
}
calculate(a: string, b: string) {
this.strategy.buildRoute(a, b);
}
}
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.