skills/design-patterns/behaviorals/pattern-state/SKILL.md
Teaches and applies the State behavioral design pattern — allowing an object to alter its behavior when its internal state changes, appearing as if the object changed its class. Trigger: When implementing finite state machines, workflow states, or mode-based behavior.
npx skillsauth add johnnystefan/test-saas-business pattern-stateInstall 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.
Allows an object to alter its behavior when its internal state changes. It appears as if the object changed its class.
interface State {
handle(context: Context): void;
}
class Context {
constructor(private state: State) {}
transitionTo(state: State) {
this.state = state;
}
request() {
this.state.handle(this);
}
}
class ConcreteStateA implements State {
handle(context: Context) {
context.transitionTo(new ConcreteStateB());
}
}
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.