ruby

ruby is a cursor rule for coding agents from sanjeed5/awesome-cursor-rules-mdc. It costs 2,400 tokens per session, scanned A, original, CC0-1.0.

A set of guidelines for writing Ruby code, including Rails conventions and RuboCop checks. Ruby is a programming language, and Rails is a Ruby framework for building web applications.

In plain words
What is it for?
Use it when creating, organising, or reviewing Ruby and Rails applications.
Why use it?
It reduces inconsistent file layouts, unclear responsibilities, and common style or security problems in Ruby projects.

Cursor rule

About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/ruby
Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ruby

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/ruby.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/ruby)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/ruby"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/ruby.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,400 This file is loaded in full into every session.
When invoked 2,400 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02400 $0.02400
Opus 5 $0.01200 $0.01200
Sonnet 5 $0.00480 $0.00480
Haiku 4.5 $0.00240 $0.00240

Measured yesterday against content hash c36550d1ee4e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ruby scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/ruby.mdc · 465 lines

How it starts

The opening of the file, as written. The whole thing — 465 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Ruby Best Practices

Our team adheres to a strict set of Ruby best practices, primarily enforced by RuboCop and aligned with the official Ruby and Rails Style Guides. This document serves as your definitive reference for writing clean, efficient, and maintainable Ruby code.

1. Code Organization & Structure

Adhere to the Single Responsibility Principle (SRP) and keep files focused.

1.1 Single Class/Module Per File

Each Ruby file must define a single class or module. Name the file using snake_case corresponding to the CamelCase class/module name.

❌ BAD

# user.rb
class User; end
class UserProfile; end

✅ GOOD

# user.rb
class User; end

# user_profile.rb
class UserProfile; end

1.2 Rails Directory Structure

Follow Rails' "convention over configuration" for project structure.

❌ BAD

# app/services/user_management/create_user.rb
# app/validators/email_validator.rb

✅ GOOD

# app/services/user_management/create_user.rb (for complex logic)
# app/validators/email_validator.rb (standard Rails convention)

1.3 Configuration Files

Place custom initialization code in config/initializers. Keep gem-specific initializers in separate files named after the gem.

❌ BAD

# config/initializers/app_setup.rb
# Contains setup for CarrierWave, Sidekiq, and custom app config.

✅ GOOD

# config/initializers/carrierwave.rb
# config/initializers/sidekiq.rb
# config/initializers/custom_app_config.rb

2. Formatting

Consistency is paramount. RuboCop enforces these rules automatically.

2.1 Indentation & Line Length

Use two-space soft tabs. Limit lines to 120 characters to balance readability and screen real estate.

❌ BAD

def long_method_name(param1, param2, param3, param4, param5, param6, param7) # > 120 chars
    puts "This line is indented with four spaces."
end

✅ GOOD

def long_method_name(param1, param2, param3, param4, param5, param6, param7)
  puts "This line is indented with two spaces."
end

Read the full file on GitHub · 465 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 465 lines · 2,400 tokens per session scan A c36550d1ee4e

Subscribe to this mod's changes

ruby is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 2,400 tokens to every session, about $0.0120 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.