skills/design-patterns/creationals/pattern-singleton/SKILL.md
Teaches and applies the Singleton creational design pattern — ensuring a class has only one instance while providing a global access point to it. Trigger: When managing shared resources like database connections, config, or caches.
npx skillsauth add johnnystefan/test-saas-business pattern-singletonInstall 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.
Ensures that a class has only one instance while providing a global access point to that instance. Crucial for shared resources like database connections.
new.class Database {
private static instance: Database;
private constructor() {
// Init logic (e.g., connect to DB)
}
public static getInstance(): Database {
if (!Database.instance) {
Database.instance = new Database();
}
return Database.instance;
}
public query(sql: string) {
/* ... */
}
}
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.