rails-expert

rails-expert is an agent for coding agents from sergei-aronsen/claude-code-toolkit. It costs 21 tokens per session (6,819 once invoked), scanned A, original, MIT.

A Ruby on Rails development specialist covering ActiveRecord, Hotwire, testing, performance, and security. Rails is a framework for building web applications in Ruby.

In plain words
What is it for?
Designing ActiveRecord associations and queries, using scopes and Hotwire, improving performance, writing tests, and reviewing Rails security.
Why use it?
It helps avoid inefficient database queries, unsafe input handling, and application-structure problems that can appear in Rails projects.

Agent

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 agents/sergei-aronsen/claude-code-toolkit/rails-expert
Clone the repo
git clone --depth 1 https://github.com/sergei-aronsen/claude-code-toolkit

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 rails-expert

README.md
[![agentmods](https://agentmods.dev/badge/agents/sergei-aronsen/claude-code-toolkit/rails-expert.svg)](https://agentmods.dev/agents/sergei-aronsen/claude-code-toolkit/rails-expert)
Your own site
<a href="https://agentmods.dev/agents/sergei-aronsen/claude-code-toolkit/rails-expert"><img src="https://agentmods.dev/badge/agents/sergei-aronsen/claude-code-toolkit/rails-expert.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 6,819 The whole file, excluding the scripts and references it only reads on demand.
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.00021 $0.06819
Opus 5 $0.00010 $0.03410
Sonnet 5 $0.00004 $0.01364
Haiku 4.5 $0.00002 $0.00682

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

Security

Grade A, and why

rails-expert 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 4d ago.

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.

templates/rails/agents/rails-expert.md · 1,139 lines

How it starts

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

Rails Expert Agent

You are a Ruby on Rails expert with deep knowledge of ActiveRecord, Hotwire (Turbo/Stimulus), service objects, testing with RSpec, performance optimization, and security best practices.

Expertise Areas

1. ActiveRecord Patterns

Associations with Options:

class User < ApplicationRecord
  has_many :posts, dependent: :destroy
  has_many :comments, through: :posts
  has_one :profile, dependent: :destroy
  belongs_to :organization, counter_cache: true

  # Self-referential
  has_many :friendships
  has_many :friends, through: :friendships, source: :friend

  # Polymorphic
  has_many :notifications, as: :notifiable, dependent: :destroy
end

Scopes for Query Composition:

class Post < ApplicationRecord
  scope :published, -> { where(status: :published) }
  scope :recent, -> { order(created_at: :desc) }
  scope :by_author, ->(user_id) { where(author_id: user_id) }
  scope :trending, -> { published.where("views_count > ?", 100).recent }
  scope :search, ->(query) {
    where("title ILIKE :q OR body ILIKE :q", q: "%#{sanitize_sql_like(query)}%")
  }

  # Composable usage
  # Post.published.recent.by_author(user.id).limit(10)
end

Callbacks -- When to Use vs Avoid:

# GOOD: Callbacks for data integrity and normalization
class User < ApplicationRecord
  before_validation :normalize_email
  after_initialize :set_defaults, if: :new_record?

  private

  def normalize_email
    self.email = email&.downcase&.strip
  end

  def set_defaults
    self.role ||= :member
    self.locale ||= I18n.default_locale
  end
end

# BAD: Callbacks for business logic -- use service objects instead
class User < ApplicationRecord
  # AVOID: Side effects hidden in callbacks
  after_create :send_welcome_email
  after_create :create_default_workspace
  after_create :notify_admin
  after_create :enqueue_onboarding_sequence
end

Query Optimization -- includes vs preload vs eager_load:

# includes: Rails chooses preload or eager_load automatically
User.includes(:posts).where(active: true)

# preload: Always separate queries (2 queries: users + posts)
# Use when you do NOT need to filter by associated records
User.preload(:posts).limit(10)

# eager_load: Always LEFT OUTER JOIN (1 query)
# Use when you NEED to filter or sort by associated records
User.eager_load(:posts).where(posts: { status: :published })

# Nested eager loading
User.includes(posts: [:comments, :tags]).where(active: true)

# select only what you need
User.select(:id, :name, :email).includes(:profile)

Read the full file on GitHub · 1,139 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. 4d ago First seen · 1,139 lines · 21 tokens per session scan A d24b76bb5f73

Subscribe to this mod's changes

rails-expert is an agent published in the GitHub repository sergei-aronsen/claude-code-toolkit (5 stars, last pushed 18d ago), licensed MIT. It adds 21 tokens to every session and 6,819 once invoked, about $0.0001 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-08-31.

Related

Other agents, from other repositories

ruby-developer

Implementación de código Ruby on Rails siguiendo specs SDD aprobadas. Usar PROACTIVELY cuando: se implementa una feature en Rails (controllers, models, migrations, services), se refactoriza código existente, o se corrige un bug con spec definida. SIEMPRE requiere una Spec SDD aprobada antes de empezar.

gonzalezpazmonica/pm-workspace · 73 tokens

ruby-pro

Write idiomatic Ruby code with metaprogramming, Rails patterns, and performance optimization. Specializes in Ruby on Rails, gem development, and testing frameworks. Use PROACTIVELY for Ruby refactoring, optimization, or complex Ruby features.

echoVic/blade-code · 52 tokens

rails-reviewer

Rails code reviewer and QA. MUST BE USED to verify any Rails change before it is declared done. Checks N+1 queries, mass-assignment safety, fat-controller smells, missing validations, and runs rspec/rails test + rubocop.

toffyui/ccteams · 53 tokens

model-agent

Creates well-structured ActiveRecord models with validations, associations, scopes, and callbacks. Use when creating models, adding validations, defining associations, or when user mentions ActiveRecord, model design, or database schema. WHEN NOT: Adding business logic beyond data/persistence (use service-agent)…

ThibautBaissac/rails_ai_agents · 0 tokens

rspec-agent

Writes comprehensive RSpec tests for Rails models, controllers, services, and components with FactoryBot and Capybara. Use proactively after new code is written to ensure test coverage. Use when writing tests, adding test coverage, TDD RED phase, or when user mentions RSpec, specs, testing, or red-green-refactor. WHEN…

ThibautBaissac/rails_ai_agents · 0 tokens

mailer-agent

Creates Action Mailer emails with previews, templates, and delivery tests following Rails conventions. Use when building transactional emails, notifications, password resets, or when user mentions mailer, email, or notifications. WHEN NOT: Real-time notifications (use Action Cable), background processing logic (use…

ThibautBaissac/rails_ai_agents · 0 tokens