Installable skillMIT

Ruby

Write reliable Ruby avoiding mutable string traps, block pitfalls, and metaprogramming bugs.

BY clawicUPDATED Oct 28, 2026
INTENDED FOR✳Claude CodeInstall in a listed agent.

instructions.md

---
name: ruby-6032b6f28d2e
slug: ruby
version: 1.0.1
description: Write reliable Ruby avoiding mutable string traps, block pitfalls, and metaprogramming bugs.
homepage: https://clawic.com/skills/ruby
metadata:
  clawdbot:
    emoji: πŸ’Ž
    requires:
      bins:
      - ruby
    os:
    - linux
    - darwin
    - win32
    displayName: Ruby
---

## Quick Reference

| Topic | File |
|-------|------|
| Mutable strings, object equality | `objects.md` |
| Proc vs lambda, return behavior | `blocks.md` |
| Visibility, method_missing | `methods.md` |
| Array/hash mutation traps | `collections.md` |
| define_method, eval traps | `metaprogramming.md` |
| ActiveRecord, N+1, callbacks | `rails.md` |

## Critical Rules

- Strings are mutable β€” `s = "hi"; s << "!"; t = s` means t also has "!"
- `==` vs `equal?` vs `eql?` β€” `==` value, `equal?` identity, `eql?` hash equality
- Default hash value is shared β€” `Hash.new([])` shares same array, use block form
- `return` in proc returns from enclosing method β€” use lambda for local return
- Block variable shadows outer scope β€” `x = 1; [2].each { |x| }; x` is still 1 (3.0+)
- `method_missing` without `respond_to_missing?` β€” breaks `respond_to?` checks
- `private` in Ruby is per-object β€” `self.private_method` fails, implicit receiver works
- `||=` doesn't work for false/nil distinction β€” `false ||= true` replaces false
- Frozen string literals β€” `# frozen_string_literal: true` makes strings immutable
- `Symbol#to_proc` β€” `&:method_name` only works with no-argument methods
- `rescue => e` without type β€” catches StandardError, not Exception
- `ensure` always runs β€” even after return, use for cleanup
COMPATIBILITY & REFERENCES

Platform guidance

Imported from the listed AgentSkill.sh category. Complete supplied package files and notices are retained. Required external tools and credentials are not installed. No bundled code was executed during import. Individual agent task behavior has not been tested.