skills/design-patterns/behaviorals/pattern-visitor/SKILL.md
Teaches and applies the Visitor behavioral design pattern — separating an algorithm from the object structure it operates on, enabling new operations without modifying existing classes. Trigger: When adding operations to a stable class hierarchy without modifying those classes.
npx skillsauth add johnnystefan/test-saas-business pattern-visitorInstall 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.
Separates an algorithm from the object structure on which it operates, allowing you to add new operations to existing object structures without modifying them.
accept(visitor) method to the base of the object structure.Double Dispatch).interface Shape {
accept(v: Visitor): void;
}
class Circle implements Shape {
accept(v: Visitor) {
v.visitCircle(this);
}
}
interface Visitor {
visitCircle(c: Circle): void;
visitRectangle(r: Rectangle): void;
}
class XMLExportVisitor implements Visitor {
visitCircle(c: Circle) {
console.log('Exporting Circle to XML...');
}
visitRectangle(r: Rectangle) {
/* ... */
}
}
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.