ruby
Language-specific super-code guidelines for ruby.
Ruby: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for ruby.
Table of Contents
- [Enumerable & Collections](#enumerable)
- [Blocks, Procs & Lambdas](#blocks)
- [String Handling](#strings)
- [Error Handling](#errors)
- [Classes & Modules](#classes)
- [Ruby Idioms](#idioms)
- [Anti-patterns specific to Ruby](#antipatterns)
1. Enumerable & Collections {#enumerable}
# ❌ Manual accumulation
result = []
items.each do |item|
result << item.name.upcase if item.active?
end
# ✅
result = items.select(&:active?).map { |i| i.name.upcase }
# ❌ Manual grouping
grouped = {}
items.each do |item|
grouped[item.category] ||= []
grouped[item.category] << item
end
# ✅
grouped = items.group_by(&:category)
# ❌ Manual sum
total = 0
orders.each { |o| total += o.amount }
# ✅
total = orders.sum(&:amount)
# ❌ Checking existence then accessing
if hash.key?(key)
value = hash[key]
end
# ✅
value = hash[key] # returns nil if missing
# or with default:
value = hash.fetch(key, default_value)
# or raising on missing:
value = hash.fetch(key) # raises KeyError
Prefer map/select/reject/sum over manual loops. Use &:method for single-method blocks.
2. Blocks, Procs & Lambdas {#blocks}
# ❌ Explicit block-tSubscribers only
The full skill, its 1 bundled files and every download is included with every paid Complete AI plan.
Details
| Source | community |
|---|---|
| License | — |
| Risk label | safe ("critical" means the skill may run commands or touch files — read before use) |
| Files | SKILL.md |
| Added | 2026-06-16 |
