{"enrichment":{"faq":[{"a":"Ruby emphasizes readability and expressiveness. Write idiomatic Ruby by using guard clauses to exit early, leveraging the safe navigation operator (&.) to avoid nil checks, and naming predicate methods with a trailing question mark. Prefer `hash.fetch(:key)` over bracket access for safer defaults, use frozen string literals to reduce memory overhead, and embrace blocks and iterators rather than imperative loops. Ruby 3.x+ idioms also include pattern matching for elegant case statements and lazy enumerables for memory-efficient transformations on large datasets.","q":"How do I write idiomatic Ruby code following modern conventions?"},{"a":"Ruby error handling patterns emphasize custom exception hierarchies and result objects. Define domain-specific exceptions inheriting from StandardError to signal specific failure modes. Use `raise` (not `fail`) to throw exceptions, and rescue specific exception types rather than catching all errors. For operations that may fail without exceptional circumstances, return result objects\u2014lightweight wrappers holding success/failure state and values. This separates error signaling (exceptions for truly exceptional cases) from expected failure handling (result objects for business logic failures), improving code clarity and testability.","q":"What are ruby error handling patterns and best practices?"},{"a":"Ruby 3.x introduces pattern matching with `case/in` syntax for destructuring complex data structures elegantly. Use data classes (via Struct or Data) to define immutable value objects with minimal boilerplate. Adopt frozen string literals by default to reduce garbage collection pressure. Leverage the safe navigation operator (&.) and the endless method syntax (`def name = value`) for concise definitions. Prefer keyword arguments over positional ones for clarity, and use numbered block parameters (`_1`, `_2`) in single-line blocks. These conventions make Ruby 3.x code more expressive and performant.","q":"What ruby 3.x idioms and conventions should I follow?"},{"a":"Ruby performance optimization starts with frozen string literals\u2014add `# frozen_string_literal: true` at file tops to prevent string duplication and reduce memory. Use lazy enumerables (`Enumerator::Lazy`) when chaining transformations on large collections; they defer computation until terminal operations, avoiding intermediate arrays. Memoize expensive calculations using instance variables or the `||=` pattern. Avoid string concatenation in loops; use `String#<<` or `Array#join` instead. Profile with `ruby-prof` to identify bottlenecks, and consider using `Fiber` or `Ractor` for concurrent workloads in Ruby 3.x+.","q":"How can I optimize Ruby performance with frozen strings and lazy enums?"},{"a":"Ruby data classes create immutable value objects with minimal syntax. Use `Data.define(:field1, :field2)` (Ruby 3.2+) or `Struct.new` to define frozen records. Pattern matching with `case/in` destructures these objects elegantly: `case user; in Data(name:, age:) if age >= 18; ...; end`. This replaces verbose conditional logic with readable guards. Data classes pair naturally with pattern matching to handle complex domain models\u2014each case branch extracts only needed fields, reducing intermediate variables and improving maintainability.","q":"What are ruby data class immutable objects and pattern matching examples?"},{"a":"Ruby's `raise` and `fail` are aliases\u2014both throw exceptions identically. Modern Ruby style prefers `raise` because it's more explicit about intent: you're raising an error condition. `fail` is a legacy convention from older Ruby versions and is rarely used in contemporary code. Always use `raise` with a specific exception class and message: `raise ArgumentError, 'invalid input'`. This clarity helps maintainers understand that an exceptional condition occurred, not a normal control flow decision.","q":"What's the difference between fail and raise in Ruby?"}],"shadow_tags":["language-fundamentals","code-style-guide","exception-design","performance-tuning","syntax-modernization","functional-patterns","memory-efficiency","type-safety"],"summary_rewrite":"Master Ruby language conventions and modern features (3.x+) for writing clean, performant code. This skill covers error handling strategies, pattern matching, and Ruby idioms like guard clauses and safe navigation. Use it when writing pure Ruby, optimizing performance, or establishing team conventions\u2014separate skills handle Rails, design patterns, testing, and style."},"files":[{"bytes":5434,"path":"plugins/ruby-rails/skills/ruby/SKILL.md","sha256":"beb2c08210f05f9ea24f9436bb980ce7056733dea51de5e918d39125e6e392fb","url":"https://skillfed.io/files/el-feo/ai-context/ruby/1393c51b/SKILL.md"}],"id":"el-feo/ai-context/ruby","links":{"html":"https://skillfed.io/el-feo/ai-context/ruby","md":"https://skillfed.io/el-feo/ai-context/ruby.md","repo":"https://github.com/el-feo/ai-context"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":2,"language":"Ruby","last_updated":"2026-07-22","license":"MIT","name":"ruby","publisher":"el-feo","stars":12},"relations":{"similar":[{"id":"softspark/ai-toolkit/ruby-patterns"},{"id":"Goldziher/ai-rulez/ruby-conventions"},{"id":"pproenca/dot-skills/ruby-optimise"},{"id":"personamanagmentlayer/pcl/ruby-expert"},{"id":"miles990/claude-software-skills/ruby"},{"id":"geoffjay/claude-plugins/ruby-patterns"},{"id":"geoffjay/claude-plugins/rack-middleware"},{"id":"majesticlabs-dev/majestic-marketplace/constraints-reviewer"},{"id":"majesticlabs-dev/majestic-marketplace/gem-builder"},{"id":"geoffjay/claude-plugins/sinatra-security"}]},"slug":{"owner":"el-feo","repo":"ai-context","skill":"ruby"},"version":"1393c51b"}
