Ruby Best Practices
Core Ruby language guide organized as modular rules, independent of any web framework. Covers syntax and types, collections, blocks/procs/lambdas, OOP/modules, metaprogramming, dependency management, testing, style/typing tooling, and performance/debugging.
For Rails-specific concerns (Active Record, controllers, views, jobs, Kamal deployment, etc.), load the sibling ruby-on-rails skill instead.
ROUTING: Which rule file to load
IF working with variables, strings/symbols, numerics, control flow, or pattern matching (case/in):
→ Read rules/core-syntax-and-types.md
IF working with Array, Hash, Struct, Enumerable, or lazy enumerators:
→ Read rules/core-collections-enumerable.md
IF working with blocks, yield, Proc, or lambda:
→ Read rules/core-blocks-procs-lambdas.md
IF working with classes, modules, mixins, or inheritance:
→ Read rules/core-oop-modules.md
IF writing metaprogramming, DSLs, or dynamic method definitions:
→ Read rules/metaprogramming.md
IF managing dependencies, a Gemfile, or building/publishing a gem:
→ Read rules/gems-and-bundler.md
IF writing or fixing tests:
→ Read rules/testing-rspec-minitest.md
IF configuring linting, formatting, or type-checking tooling:
→ Read rules/style-and-typing.md
IF profiling, debugging, or tuning Ruby performance:
→ Read rules/performance-and-debugging.md
Rule index
| Topic |
Description |
File |
| Sections overview |
Categories and reading order |
rules/_sections.md |
| Syntax & Types |
Variables, symbols, strings, numerics, control flow, pattern matching |
rules/core-syntax-and-types.md |
| Collections & Enumerable |
Array, Hash, Struct, Enumerable, lazy enumerators |
rules/core-collections-enumerable.md |
| Blocks, Procs, Lambdas |
Blocks, yield, closures, Proc vs lambda |
rules/core-blocks-procs-lambdas.md |
| OOP & Modules |
Classes, modules, mixins, inheritance, method_missing |
rules/core-oop-modules.md |
| Metaprogramming |
define_method, instance_eval/class_eval, DSLs, refinements |
rules/metaprogramming.md |
| Gems & Bundler |
Dependency management, building/publishing gems |
rules/gems-and-bundler.md |
| Testing |
Minitest vs RSpec, doubles, fixtures |
rules/testing-rspec-minitest.md |
| Style & Typing |
RuboCop, style guides, RBS/Steep/Sorbet, ruby-lsp |
rules/style-and-typing.md |
| Performance & Debugging |
irb/pry, GC tuning, YJIT, profiling |
rules/performance-and-debugging.md |
Rule categories by priority
| Priority |
Category |
Impact |
Prefix |
| 1 |
Core language |
CRITICAL |
core- |
| 2 |
Metaprogramming |
MEDIUM (advanced/DSL work) |
(none) |
| 3 |
Dependency management |
HIGH |
(none) |
| 4 |
Testing |
HIGH |
testing- |
| 5 |
Style & Typing |
MEDIUM |
(none) |
| 6 |
Performance & Debugging |
MEDIUM |
(none) |
Coverage and maintenance
Ruby CLI quick reference
ruby -v # print Ruby version
ruby -c file.rb # syntax check only
ruby -w file.rb # run with verbose warnings
irb # interactive REPL
gem install pry && pry # richer REPL (better introspection, editing)
bundle init # create a Gemfile
bundle install # install gems from Gemfile.lock
bundle exec rspec # run RSpec inside the bundle's gem set
bundle exec rake test # run Minitest via Rake
rubocop # lint/format check
rubocop -A # auto-correct safe + unsafe offenses
ri Array#each # look up stdlib docs from the CLI
1---2name: ruby3description: Core Ruby language best-practices skill (Ruby 3.3/4.0) covering syntax and types, collections/Enumerable, blocks/procs/lambdas, OOP and modules, metaprogramming, Bundler/gems, testing (RSpec/Minitest), style/typing tooling (RuboCop, RBS, Steep, ruby-lsp), and performance/debugging. Use when the user mentions Ruby, gem, Bundler, Gemfile, RSpec, Minitest, RuboCop, irb, pry, blocks, procs, lambdas, mixins, or module/metaprogramming patterns that are not specific to a framework. For Ruby on Rails framework-specific questions (Active Record, routing, Action View, etc.), see the sibling `ruby-on-rails` skill instead.4---56# Ruby Best Practices78Core Ruby language guide organized as modular rules, independent of any web framework. Covers syntax and types, collections, blocks/procs/lambdas, OOP/modules, metaprogramming, dependency management, testing, style/typing tooling, and performance/debugging.910For Rails-specific concerns (Active Record, controllers, views, jobs, Kamal deployment, etc.), load the sibling `ruby-on-rails` skill instead.1112## ROUTING: Which rule file to load1314**IF working with variables, strings/symbols, numerics, control flow, or pattern matching (`case/in`):**15→ Read `rules/core-syntax-and-types.md`1617**IF working with Array, Hash, Struct, Enumerable, or lazy enumerators:**18→ Read `rules/core-collections-enumerable.md`1920**IF working with blocks, `yield`, `Proc`, or `lambda`:**21→ Read `rules/core-blocks-procs-lambdas.md`2223**IF working with classes, modules, mixins, or inheritance:**24→ Read `rules/core-oop-modules.md`2526**IF writing metaprogramming, DSLs, or dynamic method definitions:**27→ Read `rules/metaprogramming.md`2829**IF managing dependencies, a Gemfile, or building/publishing a gem:**30→ Read `rules/gems-and-bundler.md`3132**IF writing or fixing tests:**33→ Read `rules/testing-rspec-minitest.md`3435**IF configuring linting, formatting, or type-checking tooling:**36→ Read `rules/style-and-typing.md`3738**IF profiling, debugging, or tuning Ruby performance:**39→ Read `rules/performance-and-debugging.md`4041## Rule index4243| Topic | Description | File |44|-------|-------------|------|45| Sections overview | Categories and reading order | [rules/_sections.md](rules/_sections.md) |46| Syntax & Types | Variables, symbols, strings, numerics, control flow, pattern matching | [rules/core-syntax-and-types.md](rules/core-syntax-and-types.md) |47| Collections & Enumerable | Array, Hash, Struct, Enumerable, lazy enumerators | [rules/core-collections-enumerable.md](rules/core-collections-enumerable.md) |48| Blocks, Procs, Lambdas | Blocks, `yield`, closures, `Proc` vs `lambda` | [rules/core-blocks-procs-lambdas.md](rules/core-blocks-procs-lambdas.md) |49| OOP & Modules | Classes, modules, mixins, inheritance, `method_missing` | [rules/core-oop-modules.md](rules/core-oop-modules.md) |50| Metaprogramming | `define_method`, `instance_eval`/`class_eval`, DSLs, refinements | [rules/metaprogramming.md](rules/metaprogramming.md) |51| Gems & Bundler | Dependency management, building/publishing gems | [rules/gems-and-bundler.md](rules/gems-and-bundler.md) |52| Testing | Minitest vs RSpec, doubles, fixtures | [rules/testing-rspec-minitest.md](rules/testing-rspec-minitest.md) |53| Style & Typing | RuboCop, style guides, RBS/Steep/Sorbet, ruby-lsp | [rules/style-and-typing.md](rules/style-and-typing.md) |54| Performance & Debugging | irb/pry, GC tuning, YJIT, profiling | [rules/performance-and-debugging.md](rules/performance-and-debugging.md) |5556## Rule categories by priority5758| Priority | Category | Impact | Prefix |59|----------|----------|--------|--------|60| 1 | Core language | CRITICAL | `core-` |61| 2 | Metaprogramming | MEDIUM (advanced/DSL work) | (none) |62| 3 | Dependency management | HIGH | (none) |63| 4 | Testing | HIGH | `testing-` |64| 5 | Style & Typing | MEDIUM | (none) |65| 6 | Performance & Debugging | MEDIUM | (none) |6667## Coverage and maintenance6869- Coverage map: `rules/_coverage-map.md`70- Sources: https://www.ruby-lang.org/en/documentation/ (Ruby 4.0, with 3.3/master references) and https://rubystyle.guide/71- Update this skill when a new Ruby major/minor ships or when ruby-lang.org restructures its documentation page.7273## Ruby CLI quick reference7475```bash76ruby -v # print Ruby version77ruby -c file.rb # syntax check only78ruby -w file.rb # run with verbose warnings79irb # interactive REPL80gem install pry && pry # richer REPL (better introspection, editing)81bundle init # create a Gemfile82bundle install # install gems from Gemfile.lock83bundle exec rspec # run RSpec inside the bundle's gem set84bundle exec rake test # run Minitest via Rake85rubocop # lint/format check86rubocop -A # auto-correct safe + unsafe offenses87ri Array#each # look up stdlib docs from the CLI88```