programming-ruby_skill

This skill helps you write idiomatic Ruby by applying community standards, readability, and best practices across classes, modules, and methods.
  • Shell

0

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill renzo4web/automaton --skill programming-ruby

  • SKILL.md14.0 KB

Overview

This skill teaches Ruby best practices and idiomatic style so you write code that reads like Ruby. It focuses on readable formatting, small composable methods, Ruby-specific control structures, and safe use of metaprogramming. The guidance emphasizes pragmatic choices that reduce surprises and improve maintainability.

How this skill works

The skill inspects common Ruby patterns and offers concise, actionable rules for indentation, naming, method shapes, block usage, and collection handling. It highlights idioms such as modifier forms, safe navigation (&.), pattern matching, and the composed-method technique, while warning about fragile constructs like class variables and global monkey patches. The result is practical recommendations you can apply immediately to code, tests, and design decisions.

When to use it

  • When you want code to follow community Ruby style and idioms.
  • During code reviews to identify non-idiomatic or verbose constructs.
  • While designing APIs, classes, and modules to favor clarity and duck typing.
  • When introducing metaprogramming so it stays safe and testable.
  • When writing tests to keep them independent, quiet, and descriptive.

Best practices

  • Use 2-space indentation, snake_case for methods/vars, CamelCase for types, and ?/! suffixes for predicates and dangerous methods.
  • Prefer small methods (5–10 lines), single level of abstraction, and descriptive names over comments.
  • Use braces {} for single-line value-returning blocks and do/end for multi-line side-effect blocks.
  • Favor iterators (each, map, select) over for/while; use ||= for conditional assignment and &. to avoid nil checks.
  • Avoid @@ class variables; use class instance variables and expose them through class-level accessors.
  • When using metaprogramming, prefer define_method and implement respond_to_missing? alongside method_missing.

Example use cases

  • Refactoring legacy Ruby code to remove Java/C++ idioms and adopt Ruby style.
  • Designing a new domain model that favors duck typing and small, testable objects.
  • Implementing an internal DSL or builder while keeping syntax readable and safe.
  • Writing parsers or data processors that use pattern matching and destructuring.
  • Creating well-scoped monkey patches with refinements to avoid global side effects.

FAQ

Use symbols for identifiers and hash keys when the value represents identity or internal flags; use strings for displayable or variable content.

Is metaprogramming always bad?

No. Use metaprogramming to remove boilerplate and clarify intent, but prefer define_method, keep behavior simple, and always implement the matching respond_to_missing?.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational