# Ruby Conventions

> Ruby code conventions covering Ruby 3.2+, RuboCop, RBS type checking, RSpec/Minitest, security scanning, exception handling, composition, Bundler, and gem packaging. Load when writing or reviewing Ruby code.

- Skill: `goldziher/ruby-conventions` (Agent Skill)
- Install (CLI): `npx skillmds@latest add goldziher/ruby-conventions`
- Raw SKILL.md: https://api.skillmd.com/api/skills/goldziher/ruby-conventions/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: goldziher (https://skillmd.com/u/goldziher)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/goldziher/ruby-conventions

---


- Ruby 3.2+, `frozen_string_literal: true`, `.ruby-version` file.
- Linting: a linter/formatter (e.g., RuboCop) with auto-fix (120 char max), plus its RSpec/performance plugins.
- Type checking: RBS with a type checker (e.g., steep). Use `rbs prototype` for scaffolding type signatures.
- Testing: RSpec (or Minitest) with `describe`/`context`/`it`, factories over fixtures, a coverage tool (e.g., SimpleCov) at 80%+.
- Security: a SAST tool (e.g., Brakeman for Rails), `bundler-audit` for dependency CVE scanning.
- Error handling: specific exceptions inheriting `StandardError`, no bare `rescue`.
- Composition over inheritance, `Comparable`/`Enumerable` mixins, `case/in` pattern matching.
- Dependencies: `bundler`, commit `Gemfile.lock`, pessimistic `~>` constraints.
- Gem packaging: use `gemspec` with `bundler` gem template, `rake release` for distribution.
- `&:method_name` block shorthand, `=>` pattern matching destructuring (3.2+).
- Anti-patterns: monkey patching, `method_missing` without `respond_to_missing?`, `eval` with user input.

