Ruby Coding Practices
Application skill for Ruby style learning (from the archived awesome-guidelines style capsules). For Rails/RSpec stack patterns, load stack capsules in skills/*-foundation.
Core Principle
Ruby readability is RuboCop-community layout plus idiomatic naming and explicit failure, 2-space files, ?/! suffix rules, keyword args, no exception flow control.
When to Use / NOT
- Ruby application/library/gem source, RuboCop CI, code review.
- Reviewing naming, methods, class layout, exceptions.
NOT when:
- Non-Ruby code.
- Generated files, validate generator config instead.
- Rails-specific cops only, use Rails style guide / foundation when stack is Rails.
Workflow
- Format & layout, 2-space, spacing, safe nav, blank lines (
ruby-style-formatting-layout.md).
- Naming & files, snake_case, CapitalCase,
?/!, one class per file (ruby-style-naming-files.md).
- Methods, keyword args, parens,
&&/|| vs and/or (ruby-style-methods-blocks.md).
- Classes & exceptions, layout, nesting, rescue/raise (
ruby-style-classes-exceptions.md).
- Verify, RuboCop (project
.rubocop.yml) + test suite on changed paths.
Red Flags
- Tabs or 4-space indent
is_empty? / camelCase methods
! method without safe counterpart
class Foo::Bar top-level compact definition
@@ class variables
rescue ZeroDivisionError for expected branch
rescue Exception
- Positional default arguments
and/or in boolean conditions
Verification
bundle exec rubocop (or project equivalent) on changed files
- Autoload/Zeitwerk check if namespace/files touched
- Capsule checklist on public API review
References
awesome-guidelines/references/ruby-style-learning-note.md
awesome-guidelines/references/ruby-style-formatting-layout.md
awesome-guidelines/references/ruby-style-naming-files.md
awesome-guidelines/references/ruby-style-methods-blocks.md
awesome-guidelines/references/ruby-style-classes-exceptions.md
1---2name: ruby-coding-practices3description: Use when authoring or reviewing Ruby, 2-space layout, snake_case/CapitalCase naming, keyword args, call parentheses, class skeleton, explicit namespaces, module_function, and StandardError rescue discipline.4---56# Ruby Coding Practices78Application skill for Ruby style learning (from the archived `awesome-guidelines` style capsules). For Rails/RSpec stack patterns, load stack capsules in `skills/*-foundation`.910## Core Principle1112Ruby readability is **RuboCop-community layout plus idiomatic naming and explicit failure**, 2-space files, `?`/`!` suffix rules, keyword args, no exception flow control.1314## When to Use / NOT1516- Ruby application/library/gem source, RuboCop CI, code review.17- Reviewing naming, methods, class layout, exceptions.1819**NOT when:**2021- Non-Ruby code.22- Generated files, validate generator config instead.23- Rails-specific cops only, use Rails style guide / foundation when stack is Rails.2425## Workflow26271. **Format & layout**, 2-space, spacing, safe nav, blank lines (`ruby-style-formatting-layout.md`).282. **Naming & files**, snake_case, CapitalCase, `?`/`!`, one class per file (`ruby-style-naming-files.md`).293. **Methods**, keyword args, parens, `&&`/`||` vs `and`/`or` (`ruby-style-methods-blocks.md`).304. **Classes & exceptions**, layout, nesting, rescue/raise (`ruby-style-classes-exceptions.md`).315. **Verify**, RuboCop (project `.rubocop.yml`) + test suite on changed paths.3233## Red Flags3435- Tabs or 4-space indent36- `is_empty?` / camelCase methods37- `!` method without safe counterpart38- `class Foo::Bar` top-level compact definition39- `@@` class variables40- `rescue ZeroDivisionError` for expected branch41- `rescue Exception`42- Positional default arguments43- `and`/`or` in boolean conditions4445## Verification4647- `bundle exec rubocop` (or project equivalent) on changed files48- Autoload/Zeitwerk check if namespace/files touched49- Capsule checklist on public API review505152## References5354- `awesome-guidelines/references/ruby-style-learning-note.md`55- `awesome-guidelines/references/ruby-style-formatting-layout.md`56- `awesome-guidelines/references/ruby-style-naming-files.md`57- `awesome-guidelines/references/ruby-style-methods-blocks.md`58- `awesome-guidelines/references/ruby-style-classes-exceptions.md`