agentleFS
metarhiametarhia/metaskills/skills/js-gof/SKILL.md

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

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    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.

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
  1. Distinctive:

    Use structural composition over inheritance

    line 8
  2. Distinctive:

    Use multiparadigm code and contract-programming

    line 9
  3. Distinctive:

    Use domain-specific languages (DSLs), prefer declarative way

    line 10
  4. Distinctive:

    Use GRASP and SOLID principles.

    line 12
  5. Distinctive:

    Use object/Map lookup for Strategy and polymorphic/dynamic dispatch

    line 16
  6. Distinctive:

    Do not over-engineer for the sake of the pattern name

    line 18
  7. Very specific:

    Wrapper: Add cross-cutting behavior around a function or interface.

    line 40
  8. Very specific:

    Composite: Treat leaves and trees through one operation.

    line 45

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.