Agent skill
ruby
Ruby development, RubyGems, Rails, clean code practices, and idiomatic Ruby
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ruby
SKILL.md
Skill: ruby
What I do
I provide Ruby-specific expertise: idiomatic patterns, Rails conventions, gem ecosystem knowledge, and best practices for writing clean, maintainable Ruby code.
When to use me
- Writing Ruby code (any context)
- Designing Ruby APIs or designing DSLs
- Working with Rails applications
- Choosing and integrating gems
- Refactoring Ruby for clarity and performance
Core principles
- Convention over configuration - Follow Rails conventions, don't override them
- DRY (Don't Repeat Yourself) - Extract logic to methods, concerns, and services
- Ruby is for humans - Readable, expressive code beats clever code
- Blocks and iterators - Core Ruby strength, use them idiomatically
- Frozen strings - Use
frozen_string_literal: trueat file top
Patterns & examples
Idiomatic iteration:
# ✅ Correct: use each, map, select with blocks
[1, 2, 3].each { |n| puts n }
numbers.map { |n| n * 2 }
items.select { |i| i.valid? }
# ❌ Wrong: C-style for loops
for i in 0..items.length-1
puts items[i]
end
Rails service pattern:
# ✅ Correct: Extract business logic to service
class CreateOrderService
def initialize(user, items)
@user = user
@items = items
end
def call
Order.create(user: @user, items: @items)
end
end
# In controller:
order = CreateOrderService.new(@user, params[:items]).call
Frozen string literals:
# ✅ Correct: frozen string at file top
# frozen_string_literal: true
class User
ROLE = 'admin' # frozen by default now
end
# ❌ Wrong: mutable strings in constants
ROLE = 'admin'.dup # wasteful, implies mutation
Anti-patterns to avoid
- ❌ Monolithic controller actions (extract to services)
- ❌ Complex view logic (move to helpers or view components)
- ❌ Ignoring n+1 queries (use
includes,eager_load) - ❌ Exception handling as control flow (use
dig,try, explicit checks) - ❌ Mutable defaults in arguments (
def foo(items=[])—useniland initialize in body)
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Languages/Ruby.md
Related skills
clean-code- SOLID principles in Rubybdd-workflow- Test-driven development workflowrspec-testing- RSpec BDD testing frameworkdesign-patterns- Common patterns in Ruby
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?