skills/design-patterns/structurals/pattern-composite/SKILL.md
Teaches and applies the Composite structural design pattern — composing objects into tree structures to represent part-whole hierarchies, treating individual and composite objects uniformly. Trigger: When working with tree hierarchies, nested components, or recursive structures.
npx skillsauth add johnnystefan/test-saas-business pattern-compositeInstall 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.
Composes objects into tree structures to represent part-whole hierarchies. It lets clients treat individual objects and compositions of objects uniformly.
interface Component {
execute(): string;
}
class Leaf implements Component {
execute() {
return 'Leaf';
}
}
class Composite implements Component {
private children: Component[] = [];
add(c: Component) {
this.children.push(c);
}
execute(): string {
const results = this.children.map((child) => child.execute());
return `Branch(${results.join('+')})`;
}
}
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.