一键导入
simplifying-ruby-code
Identify over-engineering in Ruby - prefer simple data structures (Hash, Struct, Data) and pure functions over unnecessary classes
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Identify over-engineering in Ruby - prefer simple data structures (Hash, Struct, Data) and pure functions over unnecessary classes
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when writing documentation, READMEs, explanations, blog posts, or any prose meant for humans to read
This skill should be used when the user asks to "rebase all open PRs", "update all PRs with latest main", "make sure every open PR is up to date with main", "sync all open PRs onto main", "rebase all my PRs", or wants to bring every open pull request current with its base branch by rebasing in parallel git worktrees, resolving conflicts with a team of agents, and force-pushing.
Groom and prioritize a project backlog — verify each candidate issue's claims against the current codebase, pick the most important N, rewrite them to a ready-to-work standard (Problem/Goals/Decisions/Outcomes/Verification), move them to Ready on the board, and close obsolete issues. Use when asked to "groom the backlog", "triage the backlog", "prioritize issues", "move issues to ready", or "what should we work on next".
This skill should be used when the user asks to "summarize a note", "summarize this article", "replace #summarize-later", "add a summary to a note", "generate takeaways", or mentions summarizing Obsidian notes. Replaces the #summarize-later tag with a high-level summary and actionable takeaways.
This skill should be used when the user asks to "update the changelog", "add changelog entries", "what changed since last release", or when updating CHANGELOG.md with user-facing changes. Follows Keep a Changelog format and filters out internal-only commits.
This skill should be used when the user asks to "improve a prompt", "make this prompt better", "optimize this prompt", "refine this system prompt", or wants to apply concept elevation to compress and clarify LLM instructions.
| name | simplifying-ruby-code |
| description | Identify over-engineering in Ruby - prefer simple data structures (Hash, Struct, Data) and pure functions over unnecessary classes |
Prefer simple data structures (Hash, Array, Struct, Data) and pure functions over unnecessary classes and abstractions.
MANDATORY: Identify whether code is a decision (pure logic) or effect (I/O). Keep them separate. See writing-code skill.
call method and no stateto_h, to_a, each)# ❌ Over-engineered
class UserCreator
def initialize(params); @params = params; end
def call; User.create(@params); end
end
# ✅ Simple
User.create(params) # or module function if logic needed
Keep command object when: Has state, multi-step algorithm, needs queuing.
# ❌ Manual value object
class Point
attr_reader :x, :y
def initialize(x, y); @x, @y = x, y; end
def ==(other); x == other.x && y == other.y; end
end
# ✅ Simple
Point = Data.define(:x, :y) # Ruby 3.2+, immutable
Point = Struct.new(:x, :y, keyword_init: true) # mutable
point = {x: 10, y: 20} # simplest
# ❌ Class with only class methods
class DateFormatter
def self.format_for_display(date); date.strftime("%B %d, %Y"); end
end
# ✅ Module
module DateFormatter
module_function
def format_for_display(date); date.strftime("%B %d, %Y"); end
end
# ❌ Deep hierarchy
class Animal; end
class Mammal < Animal; end
class Dog < Mammal; end
# ✅ Composition
module WarmBlooded
def warm_blooded?; true; end
end
class Dog
include WarmBlooded
end
| Use | When |
|---|---|
| Hash | Temporary data, varying keys, JSON interface |
| Struct | Fixed attributes, need methods, mutable OK |
| Data | Fixed attributes, immutable (Ruby 3.2+) |
| Custom Class | Complex validation, rich behavior, domain concepts |
Implement for interoperability with standard library:
class Collection
include Enumerable
def each(&block); @items.each(&block); end # Enables map, select, etc.
def to_a; @items.dup; end
def to_h; @items.to_h; end
def to_json(*args); @items.to_json(*args); end
end
Key protocols: to_h, to_a, to_json, to_s, each, <=>, hash/eql?
to_h, to_a, to_json → Add protocols