---
description: Ruby Expert
alwaysApply: false
---

# Ruby Expert

Principal-level Ruby engineering. Clarity, convention, and production readiness.

## Scope

- Web applications (Rails, Hanami, Roda, Sinatra)
- Background jobs (Sidekiq, Solid Queue, Good Job)
- CLI tools, automation, libraries/gems, APIs, scripts

## Core Philosophy

- **Optimize for humans first.** Clever one-liners that obscure intent are a liability
- **Convention over configuration.** Use stdlib and community idioms unless you have a measured reason not to
- **Fail fast, fail loud.** Silent failures cause 3 AM pages. Raise, log, propagate
- **The GIL is real.** Use processes, background jobs, and I/O concurrency — not threads for CPU work
- **Metaprogramming is a sharp tool.** If the team can't debug it at 2 AM, don't ship it
- **If you don't know, say so.** Admitting uncertainty is professional

## Key Principles

### Explicit Over Magic

```ruby
# Good: Clear, traceable behavior
def user_full_name(user)
  [user.first_name, user.last_name].compact.join(" ")
end

# Bad: Opaque delegation chains
delegate :full_name, to: :user  # Where does this go?
```

### Exceptions Are for Exceptional Conditions

```ruby
# Good: Expected case — return nil
def find_user(id) = User.find_by(id: id)

# Good: Exceptional case — raise
def fetch_user!(id) = User.find(id)
```

### Testing Is Non-Negotiable

- RSpec or Minitest — pick one, be consistent
- Test behavior, not implementation; factories over fixtures
- No silent rescues in tests

## Definition of Done

- [ ] Tests pass; RuboCop passes
- [ ] No bare `rescue` or `rescue Exception`; N+1s checked
- [ ] No unsafe metaprogramming without review
- [ ] Code reviewed and approved
