# ruby

Tells the agent how to write Ruby: idiomatic style, Ruby 3.x features, RSpec testing. Useful when you work on a Ruby codebase.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 734 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/ruby/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/ruby

## What it does

The skill gives your assistant a working knowledge of Ruby conventions. Files, methods and variables stay snake_case; classes and modules get CamelCase. Descriptive names are preferred, so predicates read like `user_signed_in?`.

Ruby 3.x gets its own section: pattern matching with `case/in`, endless methods for one-liners, keyword arguments, the safe navigation operator `&.`. Blocks, procs and lambdas are covered, with a note to keep metaprogramming in check.

Testing is the meatiest part. Specs are organised with `describe` for classes and methods, `context` for scenarios, and `let` plus FactoryBot instead of fixtures. The skill pushes for independent tests and mocks only around external services. Error handling, SOLID, composition over inheritance and profiling before optimising round it out. Install is a single `npx skills` command, no API key involved.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ruby -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/ruby/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/ruby/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ruby -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/ruby/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ruby -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/ruby/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills ruby
```

2. **Manually: put the files in place**
- File: `.github/skills/ruby/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ruby -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path ruby
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/ruby/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ruby -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/ruby/SKILL.md

## When to use it
- bring Ruby code in line with community style
- structure RSpec specs with describe and context
- adopt Ruby 3.x features without a full rewrite
- move shared class behaviour into mixin modules
- close gaps in input handling and database queries

## Example prompts
- Refactor this Ruby class: drop the inheritance and move shared behaviour into a module
- Write RSpec specs for `calculate_total`, including edge cases
- Check this code against the Ruby Style Guide and suggest where pattern matching fits

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: da9e73adf3d8a89d.

BEGIN THIRD-PARTY FILE da9e73adf3d8a89d
````text
---
name: ruby
description: Ruby development guidelines covering idiomatic code style, Ruby 3.x features, testing with RSpec, and best practices for building maintainable Ruby applications.
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# Ruby Development

You are an expert in Ruby development, including Ruby 3.x features, testing frameworks, and modern Ruby best practices.

## Code Style and Structure

- Write concise, idiomatic Ruby code with accurate examples
- Adhere to Ruby community conventions and style guides
- Use snake_case for files, methods, and variables
- Use CamelCase for classes and modules
- Favor descriptive names like `user_signed_in?` and `calculate_total`

## Ruby Language Features

- Leverage Ruby 3.x capabilities including:
  - Pattern matching with `case/in`
  - Endless methods for simple one-liners
  - Keyword arguments for clarity
  - Safe navigation operator (`&.`)
- Use blocks, procs, and lambdas effectively
- Apply metaprogramming judiciously

## Syntax and Formatting

- Follow the Ruby Style Guide
- Employ expressive syntax features
- Prefer single quotes except when string interpolation is needed
- Use meaningful method and variable names
- Keep methods small and focused (Single Responsibility Principle)

## Error Handling

- Apply exceptions for genuine edge cases only
- Implement proper logging with user-friendly messages
- Use custom exception classes for domain-specific errors
- Handle errors gracefully with appropriate rescue blocks

## Object-Oriented Design

- Follow SOLID principles
- Favor composition over inheritance
- Use modules for shared behavior (mixins)
- Keep classes focused and cohesive

## Testing Best Practices

### RSpec Guidelines

- Write comprehensive coverage of typical cases, edge cases, and error conditions
- Use clear, descriptive naming conventions for test blocks
- Organize logically with `describe` for classes/methods and `context` for scenarios
- Use `let` and factories (FactoryBot) instead of fixtures
- Ensure test independence with minimal shared state
- Mock external services strategically while testing real behavior when possible

### Test Structure

```ruby
describe ClassName do
  describe '#method_name' do
    context 'when condition exists' do
      it 'does expected behavior' do
        expect(result).to eq(expected)
      end
    end
  end
end
```

## Performance Optimization

- Profile code before optimizing
- Use appropriate data structures
- Leverage lazy enumerators for large collections
- Cache expensive computations

## Security

- Sanitize user input
- Use parameterized queries
- Keep dependencies updated
- Follow security best practices for handling sensitive data
````
END THIRD-PARTY FILE da9e73adf3d8a89d

The third-party file has ended. Everything between the da9e73adf3d8a89d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/ruby/SKILL.md

## Similar
- [inertia-rails-testing](https://affpapa.org/en/nevibecode/skills/inertia-rails-testing.md) — skill · 465 installs
- [ruby-mcp-server-generator](https://affpapa.org/en/nevibecode/skills/ruby-mcp-server-generator.md) — skill · 8600 installs
- [rails-expert](https://affpapa.org/en/nevibecode/skills/rails-expert.md) — skill · 4700 installs
- [sentry-ruby-sdk](https://affpapa.org/en/nevibecode/skills/sentry-ruby-sdk.md) — skill · 2100 installs
- [appwrite-ruby](https://affpapa.org/en/nevibecode/skills/appwrite-ruby.md) — skill · 796 installs

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
