Agent Skills: ✅ ALWAYS: Use Ruby idioms

>

UncategorizedID: poletron/custom-rules/ruby

Install this agent skill to your local

pnpm dlx add-skill https://github.com/odjaramillo/custom-rules/tree/HEAD/registry/skills/ruby

Skill Files

Browse the full folder contents for ruby.

Download Skill

Loading file tree…

registry/skills/ruby/SKILL.md

Skill Metadata

Name
ruby
Description
>

Critical Patterns

Ruby Idioms (REQUIRED)

# ✅ ALWAYS: Use Ruby idioms
users.map(&:name)                    # Symbol to proc
user&.address&.city                  # Safe navigation
name ||= "Default"                   # Memoization

Class Structure (REQUIRED)

# ✅ ALWAYS: Clear class structure
class User
  attr_reader :name, :email

  def initialize(name:, email:)
    @name = name
    @email = email
  end

  def admin?
    role == 'admin'
  end
end

Error Handling (REQUIRED)

# ✅ Use custom exceptions
class UserNotFoundError < StandardError; end

def find_user!(id)
  user = User.find_by(id: id)
  raise UserNotFoundError, "User #{id} not found" unless user
  user
end

Decision Tree

Need attribute access?     → Use attr_reader/writer
Need boolean check?        → Use predicate method (?)
Need dangerous operation?  → Use bang method (!)
Need configuration?        → Use block with yield

Commands

ruby script.rb             # Run script
irb                        # Interactive Ruby
bundle install             # Install dependencies
rspec                      # Run tests
rubocop                    # Lint code

Resources