js-gof
Skill61 starsChanged 8 months agoMITView on GitHub
Apply creational and structural design patterns (GoF and related) in JavaScript and TypeScript: abstract factory, builder, factory, factory method, prototype, flyweight, singleton, object pool, adapter, wrapper, boxing / value object, decorator, proxy, bridge, composite, facade, context. Use when implementing, choosing, explaining, or reviewing one of these patterns, or when the user names one.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ytil/skillstheir own version, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ytil/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- data-structuresSkill
- error-handlingSkill
- js-conventionsSkill
- js-data-structuresSkill
- metautil-data-structuresSkill
- npm-publishSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use structural composition over inheritance
- Distinctive: line 9
Use multiparadigm code and contract-programming
- Distinctive: line 10
Use domain-specific languages (DSLs), prefer declarative way
- Distinctive: line 12
Use GRASP and SOLID principles.
- Distinctive: line 16
Use object/Map lookup for Strategy and polymorphic/dynamic dispatch
- Distinctive: line 18
Do not over-engineer for the sake of the pattern name
- Very specific: line 40
Wrapper: Add cross-cutting behavior around a function or interface.
- Very specific: line 45
Composite: Treat leaves and trees through one operation.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GoF Patterns
- Use structural composition over inheritance
- Use multiparadigm code and contract-programming
- Use domain-specific languages (DSLs), prefer declarative way
- Separate and do not mix system and domain code
- Use GRASP and SOLID principles; especially reduce coupling
- Remember about referential transparency
- Prefer platform-agnostic code
- Implement isolation and layer borders with IoC & DI
- Use object/Map lookup for Strategy and polymorphic/dynamic dispatch
- Keep patterns simple
- Do not over-engineer for the sake of the pattern name
How to use
Pick the pattern from the lists, then read its pattern file (intent, problem, applicability, JS implementation, consequences, related patterns) and its example before implementing, explaining, or reviewing it. Follow the example's naming, structure, and idioms; domain names (User, IoTDevice) are placeholders. Read only the patterns the task needs.
Creational patterns
- Abstract factory: Switch a whole family of related objects (storage, UI kit) by one key. Read patterns/abstract-factory.md and examples/abstract-factory.js
- Builder: Assemble a complex product from many optional, order-sensitive steps. Read patterns/builder.md and examples/builder.js
- Factory: Centralize object creation: defaults, validation, and one final object shape. Read patterns/factory.md and examples/factory.js
- Factory Method: Pick the concrete class from input through a registry. Read patterns/factory-method.md and examples/factory-method.js
- Prototype: Clone a prepared instance instead of rebuilding it. Read patterns/prototype.md and examples/prototype.js
- Flyweight: Share immutable intrinsic state among many small objects. Read patterns/flyweight.md and examples/flyweight.js
- Singleton: One shared instance; prefer module state, context, or DI. Read patterns/singleton.md and examples/singleton.js
- Object Pool: Reuse expensive objects under bursty load. Read patterns/object-pool.md and examples/object-pool.js
Structural patterns
- Adapter: Make a foreign interface match the one your code expects. Read patterns/adapter.md and examples/adapter.js
- Wrapper: Add cross-cutting behavior around a function or interface. Read patterns/wrapper.md and examples/wrapper.js
- Boxing: Give a primitive a validated domain type (value object). Read patterns/boxing.md and examples/boxing.js
- Decorator: Layer optional behavior or metadata without subclassing. Read patterns/decorator.md and examples/decorator.js
- Proxy: Control access to an object (stats, cache, policy) without built-in
Proxy. Read patterns/proxy.md and examples/proxy.js - Bridge: Let two hierarchies (features, implementations) vary independently. Read patterns/bridge.md and examples/bridge.js
- Composite: Treat leaves and trees through one operation. Read patterns/composite.md and examples/composite.js
- Facade: One narrow API over a complex subsystem. Read patterns/facade.md and examples/facade.js
- Context: Pass capabilities and request state between layers without globals. Read patterns/context.md and examples/context.js
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

