design-patterns-ruby

design-patterns-ruby is a skill for Claude Code from el-feo/ai-context. It costs 60 tokens per session (1,872 once invoked), scanned A, original, MIT.

A guide to the Gang of Four design patterns implemented in Ruby. Design patterns are reusable approaches to common software design problems, such as creating objects or reducing dependencies.

In plain words
What is it for?
Use it when applying patterns such as Factory, Adapter, Observer, Strategy, or Singleton, or when refactoring Ruby object-oriented code.
Why use it?
It helps choose a suitable structure when Ruby code is tightly coupled, difficult to extend, or has recurring architecture problems.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is ruby Ruby/src/singleton/conceptual/thread_safe/main.rb.

Part of the ruby-rails plugin — 13 skills, 3 commands shipped together

Good fit Use it when applying patterns such as Factory, Adapter, Observer, Strategy, or Singleton, or when refactoring Ruby object-oriented code.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/el-feo/ai-context
agentmods
npx agentmods add skills/el-feo/ai-context/design-patterns-ruby

Made for: Claude Code.

Or install ruby-rails, the plugin that ships this one along with the rest of its 13 skills, 3 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for design-patterns-ruby

README.md
[![agentmods](https://agentmods.dev/badge/skills/el-feo/ai-context/design-patterns-ruby/github.svg)](https://agentmods.dev/skills/el-feo/ai-context/design-patterns-ruby)
Your own site
<a href="https://agentmods.dev/skills/el-feo/ai-context/design-patterns-ruby"><img src="https://agentmods.dev/badge/skills/el-feo/ai-context/design-patterns-ruby/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for design-patterns-ruby

Your own site · 80×15
<a href="https://agentmods.dev/skills/el-feo/ai-context/design-patterns-ruby"><img src="https://agentmods.dev/badge/skills/el-feo/ai-context/design-patterns-ruby.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 60 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,872 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00060 $0.01872
Opus 5.5 $0.00024 $0.00749
Sonnet 5.5 $0.00012 $0.00374
Haiku 4.5 $0.00006 $0.00187

Measured 3mo ago against content hash 8fde6c0272ba, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

design-patterns-ruby scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/ruby-rails/skills/design-patterns-ruby/SKILL.md · 317 lines

How it starts

The opening of the file, as written. The whole thing — 317 lines — stays where its author put it; the contents beside it link to each section on GitHub.

<quick_start> <pattern_selection> Object Creation Problems → Creational Patterns

  • Decouple creation from usage → Factory Method
  • Families of related objects → Abstract Factory
  • Complex objects with many params → Builder
  • Clone without concrete class dependency → Prototype
  • Single shared instance → Singleton

Structural Problems → Structural Patterns

  • Incompatible interfaces → Adapter
  • Multiple independent dimensions → Bridge
  • Tree structures treated uniformly → Composite
  • Add behavior dynamically → Decorator
  • Simplify complex subsystems → Facade
  • Memory with many similar objects → Flyweight
  • Access control/logging/caching → Proxy

Behavioral Problems → Behavioral Patterns

  • Multiple handlers in sequence → Chain of Responsibility
  • Decouple UI from business logic → Command
  • Traverse without exposing internals → Iterator
  • Reduce chaotic dependencies → Mediator
  • Undo/restore functionality → Memento
  • Notify about state changes → Observer
  • Behavior varies by state → State
  • Switch algorithms at runtime → Strategy
  • Algorithm skeleton with custom steps → Template Method
  • Operations on complex structures → Visitor </pattern_selection>

<ruby_abstract_method> Ruby doesn't have built-in abstract methods. Use:

def abstract_method
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end

</ruby_abstract_method> </quick_start>

<when_to_use> Use this skill when encountering:

  • "How do I create objects without specifying exact classes?" → Factory Method/Abstract Factory
  • "Constructor has too many parameters" → Builder
  • "Need to copy objects without knowing their concrete type" → Prototype
  • "Ensure only one instance exists" → Singleton
  • "Legacy class interface doesn't match what I need" → Adapter
  • "Class explosion from combining multiple features" → Bridge
  • "Work with tree/hierarchy uniformly" → Composite
  • "Add features without modifying class" → Decorator
  • "Simplify interaction with complex library" → Facade
  • "Too many similar objects consuming memory" → Flyweight
  • "Control access/add logging to object" → Proxy
  • "Request goes through chain of handlers" → Chain of Responsibility
  • "Need undo/redo or queue operations" → Command
  • "Custom iteration over collection" → Iterator
  • "Components too tightly coupled" → Mediator
  • "Save and restore object state" → Memento
  • "Notify multiple objects of changes" → Observer
  • "Object behavior depends on state" → State
  • "Swap algorithms at runtime" → Strategy
  • "Subclasses customize algorithm steps" → Template Method
  • "Add operations to class hierarchy" → Visitor </when_to_use>

<pattern_quick_reference> Factory Method - Define interface for creation, let subclasses decide type

class Creator
  def factory_method
    raise NotImplementedError
  end

  def operation
    product = factory_method
    "Working with #{product.operation}"
  end
end

class ConcreteCreator < Creator
  def factory_method
    ConcreteProduct.new
  end
end

File: Ruby/src/factory_method/conceptual/main.rb

Singleton (thread-safe)

class Singleton
  @instance_mutex = Mutex.new
  private_class_method :new

  def self.instance
    return @instance if @instance
    @instance_mutex.synchronize { @instance ||= new }
    @instance
  end
end

File: Ruby/src/singleton/conceptual/thread_safe/main.rb

See references/creational-patterns.md for Abstract Factory, Builder, Prototype.

def operation @component.operation end end

class ConcreteDecorator < Decorator def operation "Decorated(#{@component.operation})" end end

Stack decorators

decorated = DecoratorB.new(DecoratorA.new(ConcreteComponent.new))

File: `Ruby/src/decorator/conceptual/main.rb`

Read the full file on GitHub · 317 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 317 lines · 60 tokens per session scan A 8fde6c0272ba

Subscribe to this mod's changes

design-patterns-ruby is a skill published in the GitHub repository el-feo/ai-context (12 stars, last pushed 10d ago), licensed MIT. It adds 60 tokens to every session and 1,872 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

design-patterns-ruby compared with skills from other repositories

design-patterns-ruby next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
design-patterns-rubyel-feo/ai-contextSkill1210d agoMITA60Claude Code
newclacky-ai/openclackySkill1.2kyesterdayMITA10Claude Code
dhh-rails-styledavekilleen/DexSkill522yesterdayMITA115Claude Code
rspec-conventionsrootstrap/rails_api_baseSkill63518d agoMITA82Claude Code
ruby-patternssoftspark/ai-toolkitSkill18013d agoApache-2.0A60Claude Code
rigor-rbs-contractrigortype/rigorSkill108yesterdayMPL-2.0A95Claude Code, Codex
rails-devtech-leads-club/agent-skillsSkill7.2k4d agononeA199Claude Code, Codex