jeffreytse/grimoire-core/apply-abstract-factory-pattern
Claude Code and agent skill by jeffreytse/grimoire-core
- community
Checking that the SKILL.md file is still in the repository.
Use when a system must create families of related objects and must remain independent of how those objects are created — so that swapping one product family for another requires no changes to client code.
Install
npx vskill@latest install jeffreytse/grimoire-core/apply-abstract-factory-patternSKILL.md
The same SKILL.md was published earlier as jeffreytse/grimoire-core/apply-abstract-factory-pattern.
Apply Abstract Factory Pattern
Provide an interface for creating families of related objects without specifying their concrete classes.
Why This Is Best Practice
Adopted by: Java AWT/Swing (the LookAndFeel system is an abstract factory for UI components), .NET WPF theme factories, Apple AppKit (NSWindow/NSView factory hierarchy), and Google Guice/Spring (module-level provider factories) — among the most downloaded frameworks in each ecosystem. Impact: GoF documents that Abstract Factory eliminates conditional logic that otherwise appears at every object-creation site when switching product families. In practice, adding a new UI theme in Java Swing requires implementing one factory class — not editing every component constructor. The pattern makes "swap the whole family" a one-class change. Why best: The alternative — instantiating concrete classes directly — scatters product-family selection across the codebase. Every new WindowsButton() is a site that must be updated when switching to MacButton. Abstract Factory centralizes that decision in one place and enforces consistency: you cannot accidentally mix products from different families (a Windows button with a Mac checkbox).
Sources: Gamma et al. (1994) pp. 87–95; Freeman & Freeman, "Head First Design Patterns" (2004) ch. 4; Java AWT documentation
Steps
Step 1: Define the abstract factory interface
Declare a creation method for each product type in the family:
Step 2: Define abstract product interfaces
Step 3: Implement concrete factories and products per family
Step 4: Write client code against the abstract factory only
Step 5: Select the concrete factory at the entry point (not inside components)
Decide which family to use once — at startup, from config, or from environment — then pass the factory down. Components never call WindowsFactory() directly.
When NOT to Use
- Single-product systems — if only one type of object is being created,
apply-factory-method-patternis simpler. - Rarely-changing product families — if there's only ever one family and no plans to add another, the interface adds indirection with no payoff.
- When products in a family don't need to be consistent — if mixing products across families is acceptable, the constraint enforced by Abstract Factory is unnecessary.
Common Mistakes
Adding new product types to an existing factory. Adding create_tooltip() to UIFactory requires changing every concrete factory. This violates OCP. Prefer extending via composition rather than widening the factory interface.
Using Abstract Factory for a single product. If you only have one kind of product, Factory Method is the right pattern — Abstract Factory is for families.
Putting factory selection logic inside a component. if os == "windows": factory = WindowsFactory() inside a render() method defeats the point. Selection belongs at the composition root.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/engineering/architecture/skills/apply-abstract-factory-pattern/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jeffreytse/grimoire-core/apply-abstract-factory-pattern)