Singleton Pattern
Teaches the singleton pattern for managing a single shared instance. Use when exactly one instance of a class or object is needed to coordinate actions across your application.
Install
npx skills add PatternsDev/skills --skill singleton-patterngit clone --depth 1 https://github.com/PatternsDev/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/javascript/singleton-pattern ~/.claude/skills/singleton-patternPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Singleton Pattern ## Table of Contents - [When to Use](#when-to-use) - [When NOT to Use](#when-not-to-use) - [Instructions](#instructions) - [Details](#details) - [Source](#source) Singletons are classes which can be instantiated once, and can be accessed globally. This _single instance_ can be shared throughout our application, which makes Singletons great for managing global state in an application. ## When to Use - Use this when you need exactly one instance of a class shared across the entire application - This is helpful for managing global state, configuration, or shared resources ## When NOT to Use - When you need multiple instances of a class — singletons enforce a single shared instance by design - When it introduces hidden global state coupling that makes testing and reasoning about code harder - When dependency injection or module-scoped variables achieve the same result with better testability ## Instructions - Ensure only one instance can be created by checking for an existing instance in the constructor - Use `Object.freeze()` on the exported instance to prevent accidental modifications - In JavaScript, prefer simple object literals or modules over class-based singletons when possible - In React, prefer state management tools (Redux, Context) over Singletons for global state - Be aware that Singletons can make testing more difficult due to shared mutable state ## Details
Details
- Skill name
singleton-pattern- Repository
- PatternsDev/skills
- Path
javascript/singleton-pattern/SKILL.md- Repo updated
- 15 April 2026
FAQ
What does the Singleton Pattern skill do?
Teaches the singleton pattern for managing a single shared instance. Use when exactly one instance of a class or object is needed to coordinate actions across your application.
How do I install the Singleton Pattern skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add PatternsDev/skills --skill singleton-pattern. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Singleton Pattern popular?
It lives in PatternsDev/skills, which has 259 GitHub stars and 28 forks.
Related skills
AI UI Patterns
259PatternsDev/skills
Teaches design patterns for building AI-powered React interfaces. Use when creating chatbots, intelligent assistants, streaming UIs, or any AI-driven user experience in React.
Async Components
259PatternsDev/skills
Teaches async component loading in Vue for performance optimization. Use when you have heavy components that aren't needed on initial render and can be loaded on demand.
Bundle Splitting
259PatternsDev/skills
Teaches bundle splitting techniques for web performance. Use when your application has a large JavaScript bundle that affects load times or when you need to reduce FCP/LCP.
Static Import
259PatternsDev/skills
Teaches static ES2015 import syntax for module dependencies. Use when you need to import code that is required at load time and benefits from static analysis and tree shaking.
Route Based
259PatternsDev/skills
Teaches route-based code splitting for single-page applications. Use when different routes load distinct feature sets and you want to avoid loading all route code upfront.
Third Party
259PatternsDev/skills
Teaches strategies for mitigating third-party script performance impact. Use when third-party scripts like analytics, ads, or widgets are degrading your page load times or Core Web Vitals.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.