Skip to content
Skills Library
Programming · Review & audit

ruby

/ruby

This skill should be used when writing or reviewing Ruby code, or when the project uses "Ruby", "RSpec", "service objects", "Struct", "Data class", or Ruby class/module patterns. Provides Ruby coding conventions, patterns, and best practices. Project-specific conventions always take priority.

Author
sorah ↗
Repository
config ↗
Licence
MIT
Last repository change
24.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

This skill should be used when writing or reviewing Ruby code, or when the project uses "Ruby", "RSpec", "service objects", "Struct", "Data class", or Ruby class/module patterns. Provides Ruby coding conventions, patterns, and best practices. Project-specific conventions always take priority.

Triggers from the description

RubyRSpecservice objectsStructData class
Original author description

This skill should be used when writing or reviewing Ruby code, or when the project uses "Ruby", "RSpec", "service objects", "Struct", "Data class", or Ruby class/module patterns. Provides Ruby coding conventions, patterns, and best practices. Project-specific conventions always take priority.

How it works

  1. File Structure
  2. RuboCop
  3. Type Checking
  4. Naming
  5. Architecture & Design
  6. Methods
  7. Data Handling
  8. Error Handling
  9. Nil Handling
  10. Testing — RSpec
Original SKILL.md headings · 100 lines, 547 words
SKILL.md preview
---
name: ruby
description: This skill should be used when writing or reviewing Ruby code, or when the project uses "Ruby", "RSpec", "service objects", "Struct", "Data class", or Ruby class/module patterns. Provides Ruby coding conventions, patterns, and best practices. Project-specific conventions always take priority.
version: 0.1.0
---

# Ruby Conventions

Coding conventions and best practices for Ruby projects. Project-specific conventions (CLAUDE.md, style guides) always take priority over this guidance.

## File Structure

- Explicit `require` statements at top of file

## RuboCop

New projects start from sorah's baseline in [sorah/config](https://github.com/sorah/config) (checked out at `~/git/config`), copied rather than inherited, so each project owns its configuration. Leave an existing project's configuration alone.

- Copy `misc/rubocop.yml` (rubocop-shopify plus overrides) to `.rubocop.yml`, and add `rubocop-shopify` as a development dependency.
- For a Rails app, merge in `misc/rubocop.rails.yml` (the factory_bot, rails, rspec and rspec_rails plugins, with the cops it relaxes) as one `.rubocop.yml`, not as two files.
- Add an `AllCops` block:
  ```yaml
  AllCops:
    TargetRubyVersion: 3.3  # a gem's minimum supported Ruby
    SuggestExtensions: false
    Exclude:
      # protoc output, checked as generated rather than linted.
      - "lib/**/*_pb.rb"
      - "vendor/**/*"
      - ".gem_rbs_collection/**/*"
  ```
- Exclude generated code and installed signatures, each with a comment saying what it is. Never disable a cop to fit generated code.
- RuboCop runs from hk; see the `toolchain` skill.

## Type Checking

- Libraries and gems: Steep with rbs-inline. See the `steep` and `steep-adoption` skills.
- Applications: Sorbet with inline RBS comments. See the `sorbet` and `sorbet-adoption` skills.

## Naming

- Class names in PascalCase, method names in snake_case
- File paths matching class hierarchy (e.g., `lib/my_app/user_service.rb` for `MyApp::UserService`)
- Constants in `SCREAMING_SNAKE_CASE`

## Architecture & Design

- **Service objects**: Command/service pattern for encapsulating business logic outside models
- **Module structure**: Namespace hierarchy; `include` for instance behavior, `extend` for class behavior
- **Data structures**: Struct or Data classes for value objects instead of raw hashes

## Methods

- Keyword arguments for methods with multiple parameters
- `def self.method_name` for class methods
- Guard clauses for early returns on precondition checks
- `attr_reader` over direct instance variable access
- Short single-line methods when appropriate

## Data Handling

- `Hash#fetch` and `Array#fetch` for required keys/indexes
- Omit hash value when identical to key: `{foo:}` instead of `{foo: foo}`
- Consistent hash syntax with symbol keys and colons

## Error Handling

- Rescue specific exceptions only (e.g., `Aws::S3::Errors::NoSuchKey`), never `rescue Exception` or bare `rescue`
- Raise with descriptive messages
- Let exceptions propagate unless there is a meaningful reason to catch them:
  - Adding context to the error
  - Performing cleanup operations
  - Converting one exception type to another
  - Recovering from expected error conditions

## Nil Handling

- Explicit nil checks vs safe navigation (`&.`) vs `fetch` with defaults
- Prefer `fetch` to surface unexpected missing keys early

## Testing — RSpec

- Describe/context/it hierarchy; spec file placement mirroring source tree
- Factory patterns for test data; understand `let` (lazy) vs `let!` (eager) semantics
- Cover error paths and edge cases: nil inputs, empty collections, boundary values
- Spec examples for each documented error condition

## AWS SDK

- Lazy initialize AWS clients as instance variables
- Pass logger to AWS clients
- Use symbolized keys for AWS responses
- In AWS Lambda contexts, initialize with dependency injection via `environment:` parameter

## Logging

- Use structured logging with JSON when appropriate
- Log important operations (locks, state changes)

## Security

- **Credential hashing**: bcrypt or argon2 for passwords
- **Token storage**: Hashed tokens in database, plaintext never persisted
- **Constant-time comparison**: `ActiveSupport::SecurityUtils.secure_compare` or equivalent for secret comparison

Versions

RepositoryScoreLicence
This page · sorah/config100MIT
ericrisco/rsc-harness100MIT
nimadorostkar/Claude-Skills-collection100MIT
appwrite/claude-plugin100BSD-3-Clause
G1Joshi/Agent-Skills100MIT
el-feo/ai-context100MIT
sorah/config90MIT
dkbnull/hello-skill86MIT

Database snapshot: 13.11.2026 · package version 0c055f6bb318 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90ruby-rails
    Use this skill when building Ruby on Rails applications — MVC, ActiveRecord, service objects, API mode, background jobs, and testing. This skill enforces: thin controllers, service objects for business logic, ActiveRecord query best practices, Rails API mode conventions, and…
  • 100ruby-script
    Use when writing a Ruby script. Covers the template, conventions, and required patterns.
  • 86ruby-on-rails
    Ruby on Rails coding conventions and guidelines Triggers on: **/*.rb
  • 90rust
    This skill should be used when writing or reviewing Rust code, or when the project uses "Rust", "Cargo", "cargo clippy", "crate", or Rust module patterns. Provides Rust coding conventions, patterns, and best practices. Project-specific conventions always take priority.
  • 100rails
    This skill should be used when writing or reviewing Ruby on Rails code, or when the project uses "Rails", "ActiveRecord", "ActiveJob", "concerns", "migrations", "Rails.configuration", "request specs", or "controller". Provides Rails coding conventions, patterns, and best…
  • 95rspec-skill
    Generates RSpec tests in Ruby with describe/context/it blocks, matchers, let/before hooks, and mocking. Use when user mentions "RSpec", "describe do", "expect().to", "Ruby test". Triggers on: "RSpec", "expect().to eq()", "describe do", "Ruby test", "spec file".

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.