Agent skill

Rails Idioms

by irahardianto in irahardianto/awesome-agv

Ruby on Rails framework patterns: ActiveRecord scopes, N+1 query prevention, model validations, RESTful routing, and RSpec/Minitest testing.

MITAuto-check passedBackend & APIs

Install Rails Idioms

skills CLI
$ npx skills add irahardianto/awesome-agv --skill rails-idioms -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install irahardianto/awesome-agv rails-idioms --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/irahardianto/awesome-agv.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/rails-idioms .claude/skills/rails-idioms && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
rails-idioms
GitHub stars
156
Token cost
~1.8k tokens
SKILL.md length
292 words
Files
1
Skills in repo
34
Repo updated
First seen
Licence
MIT

At a glance

Ruby on Rails framework patterns: ActiveRecord scopes, N+1 query prevention, model validations, RESTful routing, and RSpec/Minitest testing.

  • Works in 4 steps: Scopes for reusable queries → Validations in models, not controllers → includes/preload for eager loading —… → …
  • Auditing Rails web applications and APIs
  • Calls bundle
  • Tasks that involve Backend development

What it does

Rails Idioms is an agent skill from irahardianto/awesome-agv. Ruby on Rails framework patterns: ActiveRecord scopes, N+1 query prevention, model validations, RESTful routing, and RSpec/Minitest testing. Use when building, maintaining, or auditing Rails web applications and APIs. Pair with ruby-idioms.

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Backend development, REST APIs and ORMs and data access. It works with Ruby on Rails and Ruby. The repository describes itself as: Comprehensive sets of standards and practices designed to elevate the capabilities of AI coding agents. The licence is MIT.

When your agent uses it

  • Auditing Rails web applications and APIs
  • Tasks that involve Backend development
  • Tasks that involve REST APIs

Example prompts

  • “/rails-idioms”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Scopes for reusable queries
  2. Validations in models, not controllers
  3. includes/preload for eager loading — avoid N+1
  4. Callbacks — use sparingly, prefer service objects

What it can do on your machine

Read from SKILL.md and the folder at commit 9e997ba. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bundle

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Rails Idioms loads about 1.8k tokens when it runs. Until then it costs about 63 tokens; SKILL.md has 292 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~63
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from irahardianto/awesome-agv at commit 9e997ba, republished under its MIT licence (© irahardianto). 292 words, ~1,821 tokens.

Download SKILL.mdSave it as .claude/skills/rails-idioms/SKILL.md (or your agent's skills folder).
name
rails-idioms
description
Ruby on Rails framework patterns: ActiveRecord scopes, N+1 query prevention, model validations, RESTful routing, and RSpec/Minitest testing. Use when building, maintaining, or auditing Rails web applications and APIs. Pair with ruby-idioms.

Rails Idioms and Patterns

Rails rewards convention over configuration, Active Record, and RESTful design. Idiomatic Rails = conventional, tested, Hotwire-aware.

Scope: Rails-specific patterns. For Ruby: @.agents/skills/ruby-idioms/SKILL.md.

Active Record
  1. Scopes for reusable queries:

    ruby
    class Task < ApplicationRecord
      scope :active, -> { where(status: :active) }
      scope :by_priority, -> { order(priority: :desc) }
      scope :created_after, ->(date) { where('created_at > ?', date) }
    
      # ✅ Chainable
      # Task.active.by_priority.created_after(1.week.ago)
    end
  2. Validations in models, not controllers:

    ruby
    class Task < ApplicationRecord
      validates :title, presence: true, length: { maximum: 200 }
      validates :priority, inclusion: { in: %w[low medium high] }
    
      # ✅ Custom validation
      validate :deadline_must_be_in_future, on: :create
    
      private
    
      def deadline_must_be_in_future
        return unless deadline.present? && deadline < Time.current
        errors.add(:deadline, 'must be in the future')
      end
    end
  3. includes/preload for eager loading — avoid N+1:

    ruby
    # ❌ N+1 — fires a query per task to load user
    Task.all.each { |t| puts t.user.name }
    
    # ✅ Eager load — 2 queries total
    Task.includes(:user).each { |t| puts t.user.name }
    
    # ✅ Use Bullet gem to detect N+1 in development
  4. Callbacks — use sparingly, prefer service objects:

    ruby
    # ❌ Complex callback chains — hard to test and debug
    before_save :normalize_title, :set_defaults, :notify_assignee
    
    # ✅ Service object — explicit, testable
    class CreateTask
      def call(params)
        task = Task.new(normalize(params))
        task.save!
        NotificationService.notify(task.assignee, task)
        task
      end
    end
Controllers
  1. RESTful actions — only standard 7 actions per controller. Custom actions = new controller:

    ruby
    # ❌ Custom action crammed into TasksController
    def complete; end
    
    # ✅ Dedicated controller
    class TaskCompletionsController < ApplicationController
      def create
        task = Task.find(params[:task_id])
        task.complete!
        redirect_to task
      end
    end
  2. Strong parameters — never mass-assign without permit:

    ruby
    private
    
    def task_params
      params.require(:task).permit(:title, :priority, :deadline, :description)
    end
  3. Service objects for complex business logic:

    ruby
    class TasksController < ApplicationController
      def create
        result = CreateTask.new.call(task_params)
        if result.success?
          redirect_to result.task, notice: 'Task created'
        else
          @task = result.task
          render :new, status: :unprocessable_entity
        end
      end
    end
Error Handling

For universal error handling principles, see .agents/rules/error-handling-principles.md.

  1. rescue_from for controller-level error handling:

    ruby
    class ApplicationController < ActionController::Base
      rescue_from ActiveRecord::RecordNotFound, with: :not_found
      rescue_from ActiveRecord::RecordInvalid, with: :unprocessable
    
      private
    
      def not_found(exception)
        render json: { error: exception.message }, status: :not_found
      end
    
      def unprocessable(exception)
        render json: { errors: exception.record.errors.full_messages },
               status: :unprocessable_entity
      end
    end
  2. Custom domain errors:

    ruby
    module TaskErrors
      class NotAssignable < StandardError; end
      class DeadlinePassed < StandardError; end
    end
  3. Never rescue Exception — always rescue StandardError or specific subclasses.

Hotwire (7+)
  1. Turbo Frames for partial page updates:

    erb
    <!-- Wraps content that can be independently loaded/replaced -->
    <%= turbo_frame_tag "task_#{task.id}" do %>
      <%= render task %>
    <% end %>
  2. Turbo Streams for real-time updates:

    ruby
    # In controller — auto-broadcasts updates
    def create
      @task = Task.create!(task_params)
      respond_to do |format|
        format.turbo_stream
        format.html { redirect_to tasks_path }
      end
    end
  3. Stimulus for JavaScript sprinkles — minimal JS.

Show full SKILL.md (237 more words)Show less
Security

For universal security principles, see .agents/rules/security-principles.md.

  • CSRF protection — enabled by default, never disable
  • Content Security Policy — configure in config/initializers/content_security_policy.rb
  • Parameterized queries — Active Record handles this, but never use string interpolation in where:
    ruby
    # ❌ SQL injection risk
    Task.where("title LIKE '%#{params[:q]}%'")
    
    # ✅ Parameterized
    Task.where("title LIKE ?", "%#{params[:q]}%")
Anti-Patterns
  • ❌ Fat models — extract to service objects / form objects / query objects
  • ❌ Business logic in controllers — controllers are thin routing layers
  • ❌ Callbacks for complex side effects — use service objects
  • ❌ default_scope — implicit, surprising, hard to override
  • ❌ update_attribute (skips validation) — use update!
  • ❌ rescue Exception — catches everything including SystemExit, Interrupt
  • ❌ String interpolation in SQL — SQL injection vector
Testing

For universal testing principles, see .agents/rules/testing-strategy.md. Below: language-specific patterns only.

  1. RSpec (preferred):

    ruby
    RSpec.describe TasksController, type: :request do
      describe 'POST /tasks' do
        it 'creates a task with valid params' do
          post tasks_path, params: { task: { title: 'Test', priority: 'high' } }
          expect(response).to have_http_status(:created)
          expect(Task.last.title).to eq('Test')
        end
    
        it 'returns errors with invalid params' do
          post tasks_path, params: { task: { title: '' } }
          expect(response).to have_http_status(:unprocessable_entity)
        end
      end
    end
  2. FactoryBot for test data:

    ruby
    FactoryBot.define do
      factory :task do
        title { Faker::Lorem.sentence(word_count: 3) }
        priority { %w[low medium high].sample }
        association :user
      end
    end
  3. Database Cleaner for test isolation.

  4. Shoulda Matchers for model spec shortcuts.

Formatting and Static Analysis
ToolPurposeCommand
RuboCop + rubocop-railsLintingrubocop --autocorrect
BrakemanSecuritybrakeman --no-pager
bundle auditCVE scanningbundle audit check --update
rails_best_practicesCode qualityrails_best_practices .
  • Ruby Idioms @.agents/skills/ruby-idioms/SKILL.md
  • Database Design Principles @.agents/rules/database-design-principles.md
  • Security Principles @.agents/rules/security-principles.md
  • API Design Principles @.agents/rules/api-design-principles.md

© irahardianto, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/rails-idioms of irahardianto/awesome-agv.

Open the folder on GitHubat commit 9e997ba

Compare with similar skills

Rails Idioms next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Rails Idioms compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Rails Idioms this skillirahardianto/awesome-agv156—~1.8kAutomated safety check: PassMIT
Rails ExpertJeffallan/claude-skills12k—~1.4kAutomated safety check: PassMIT
Rails Patternsaffaan-m/ECC276k—~4.1kAutomated safety check: PassMIT
Ruby Patternssoftspark/ai-toolkit179—~2.3kAutomated safety check: PassApache-2.0
Railsericrisco/rsc-harness180—~3.1kAutomated safety check: PassMIT
Ruby Rulessoftspark/ai-toolkit179—~3.4kAutomated safety check: PassApache-2.0

Similar skills

  • Rails Expert

    Jeffallan/claude-skills

    Builds Rails 7+ apps with Hotwire Turbo Frames and Streams, Active Record tuning, Action Cable, Sidekiq jobs and RSpec specs, with migration and N+1 checks.

    12k GitHub stars~1.4k tokensUpdated 8 days ago
    Backend & APIsAuto-check passed
  • Rails Patterns

    affaan-m/ECC

    Ruby on Rails framework patterns for Rails 7.1+ and 8.x apps.

    276k GitHub stars~4.1k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • Ruby Patterns

    softspark/ai-toolkit

    Ruby/Rails: blocks, metaprogramming, ActiveRecord, Sidekiq, RSpec, Sorbet, Hanami.

    179 GitHub stars~2.3k tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • Rails

    ericrisco/rsc-harness

    A skill your agent uses when building or maintaining a Ruby on Rails app — models, controllers, views, routes and migrations; ActiveRecord associations, scopes and query performance; Hotwire (Turbo…

    180 GitHub stars~3.1k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • Ruby Rules

    softspark/ai-toolkit

    Ruby coding rules: style, patterns, security, testing. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~3.4k tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • Ruby

    ericrisco/rsc-harness

    A skill your agent uses when writing or refactoring plain Ruby outside Rails — scripts, CLIs, gems, libraries: Enumerable chains and blocks, module mixins and value objects, Bundler/gemspec…

    180 GitHub stars~3.2k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from irahardianto/awesome-agv

All 34 skills in this repo
  • Distinctive Frontend Design Builder

    irahardianto/awesome-agv

    Commits to one bold aesthetic direction, sets up a CSS token system for it, then builds the interface in Vue or plain HTML using those tokens.

    156 GitHub stars~2.4k tokensUpdated 6 days ago
    Auto-check passed
  • Perf Optimization

    irahardianto/awesome-agv

    Profile-driven performance optimization protocol. An agent skill from irahardianto/awesome-agv.

    156 GitHub stars~4.3k tokensUpdated 6 days ago
    Auto-check passed
  • Angular Idioms and Patterns

    irahardianto/awesome-agv

    Coding conventions for Angular 19 and later: standalone components, signals, OnPush change detection, lazy routes and where RxJS still belongs.

    156 GitHub stars~3.8k tokensUpdated 6 days ago
    Auto-check passed
  • CI/CD Pipeline Principles

    irahardianto/awesome-agv

    Rules for designing CI/CD pipelines in layers: universal lint, test and scan stages, container builds with SBOM attestation, and GitOps for orchestrated deployments.

    156 GitHub stars~2.7k tokensUpdated 6 days ago
    Auto-check: notes
  • Hono Idioms

    irahardianto/awesome-agv

    Hono lightweight web framework patterns: type-safe route handlers, middleware composition, Zod validation, and RPC clients for Cloudflare Workers, Node, or Bun.

    156 GitHub stars~3k tokensUpdated 6 days ago
    Auto-check passed
  • Mobile Testing

    irahardianto/awesome-agv

    Mobile E2E testing patterns — Flutter integrationtest, Patrol, Maestro, golden testing, device matrix, and test data management.

    156 GitHub stars~1.8k tokensUpdated 6 days ago
    Auto-check: notes

Categories

Questions about Rails Idioms

What does Rails Idioms do?

Ruby on Rails framework patterns: ActiveRecord scopes, N+1 query prevention, model validations, RESTful routing, and RSpec/Minitest testing. Rails Idioms is an agent skill from irahardianto/awesome-agv. Ruby on Rails framework patterns: ActiveRecord scopes, N+1 query prevention, model validations, RESTful routing, and RSpec/Minitest testing.

When should I use Rails Idioms?

Rails Idioms fits situations like: auditing Rails web applications and APIs; tasks that involve Backend development; tasks that involve REST APIs.

How do I install Rails Idioms in Claude Code?

Run `npx skills add irahardianto/awesome-agv --skill rails-idioms -a claude-code`. Or copy the skill folder (.agents/skills/rails-idioms in irahardianto/awesome-agv) into .claude/skills/rails-idioms in your project. Claude Code loads it when a task matches its description.

How do I install Rails Idioms in Codex?

Run `npx skills add irahardianto/awesome-agv --skill rails-idioms -a codex`. Or copy the skill folder (.agents/skills/rails-idioms in irahardianto/awesome-agv) into .agents/skills/rails-idioms in your project. Codex loads it when a task matches its description.

Can I use Rails Idioms in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add irahardianto/awesome-agv --skill rails-idioms -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/rails-idioms, .gemini/skills/rails-idioms, .github/skills/rails-idioms and .opencode/skills/rails-idioms in your project.

What does Rails Idioms need to run?

Going by SKILL.md and its folder, Rails Idioms needs the command-line tools its instructions call (bundle).

Does Rails Idioms access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Rails Idioms safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Rails Idioms use?

Rails Idioms is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Rails Idioms use?

About 1.8k tokens (SKILL.md is roughly 7.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Rails Idioms?

Skills that share tags, products or a category with Rails Idioms: Rails Expert (Jeffallan/claude-skills, 12k stars), Rails Patterns (affaan-m/ECC, 276k stars), Ruby Patterns (softspark/ai-toolkit, 179 stars) and Rails (ericrisco/rsc-harness, 180 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Rails Idioms?

irahardianto (a GitHub user) maintains it in irahardianto/awesome-agv, which has 156 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on October 5, 2026.

Source: irahardianto/awesome-agv on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.