rails-generators

rails-generators is a skill for Claude Code from el-feo/ai-context. It costs 83 tokens per session (3,660 once invoked), scanned A, original, MIT.

A guide to creating custom generators for Ruby on Rails, the web application framework. Generators create files and standard code from a command, while application templates automate setup for a whole Rails app.

In plain words
What is it for?
Use it to generate models, services, controllers, tests, and full-stack features, or to automate new Rails application setup.
Why use it?
It reduces repeated manual file creation and keeps generated features consistent with the project's chosen structure.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is destination File.expand_path('../tmp', __dir__).

Part of the ruby-rails plugin — 13 skills, 3 commands shipped together

Good fit Use it to generate models, services, controllers, tests, and full-stack features, or…

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/el-feo/ai-context
agentmods
npx agentmods add skills/el-feo/ai-context/rails-generators

Made for: Claude Code.

Or install ruby-rails, the plugin that ships this one along with the rest of its 13 skills, 3 commands.

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-generators

README.md
[![agentmods](https://agentmods.dev/badge/skills/el-feo/ai-context/rails-generators.svg)](https://agentmods.dev/skills/el-feo/ai-context/rails-generators)
Your own site
<a href="https://agentmods.dev/skills/el-feo/ai-context/rails-generators"><img src="https://agentmods.dev/badge/skills/el-feo/ai-context/rails-generators.svg" alt="Measured on agentmods" height="20"></a>
Per session 83 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,660 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00083 $0.03660
Opus 5 $0.00042 $0.01830
Sonnet 5 $0.00017 $0.00732
Haiku 4.5 $0.00008 $0.00366

Measured 6d ago against content hash ec541dd5a321, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

rails-generators 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 6d 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.

plugins/ruby-rails/skills/rails-generators/SKILL.md · 458 lines

How it starts

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

<quick_start> <basic_generator> Create a simple service object generator:

# lib/generators/service/service_generator.rb
module Generators
  class ServiceGenerator < Rails::Generators::NamedBase
    source_root File.expand_path('templates', __dir__)

    def create_service_file
      template 'service.rb.tt', "app/services/#{file_name}_service.rb"
    end

    def create_service_test
      template 'service_test.rb.tt', "test/services/#{file_name}_service_test.rb"
    end
  end
end

Template file (templates/service.rb.tt):

class <%= class_name %>Service
  def initialize
  end

  def call
    # Implementation goes here
  end
end

Invoke with: rails generate service payment_processor </basic_generator>

<usage_pattern> Generator location: lib/generators/[name]/[name]_generator.rb Template location: lib/generators/[name]/templates/ Test location: test/generators/[name]_generator_test.rb </usage_pattern> </quick_start>

  • Enforce architectural patterns: Service objects, form objects, presenters, query objects
  • Reduce boilerplate: API controllers with standard CRUD, serializers, policy objects
  • Maintain consistency: Team conventions for file structure, naming, and organization
  • Automate complex setup: Multi-file features with migrations, tests, and documentation
  • Override Rails defaults: Customize scaffold behavior for your application's needs </when_to_create>

<rails_8_updates> Rails 8 introduced the authentication generator (rails generate authentication) which demonstrates modern generator patterns including ActionCable integration, controller concerns, mailer generation, and comprehensive view scaffolding. Study Rails 8 built-in generators for current best practices. </rails_8_updates>

  • Rails::Generators::Base: Simple generators without required arguments
  • Rails::Generators::NamedBase: Generators requiring a name argument (provides name, class_name, file_name, plural_name)
class ServiceGenerator < Rails::Generators::NamedBase
  # Automatically provides: name, class_name, file_name, plural_name
end

</step_1>

<step_2> Define source root and options:

source_root File.expand_path('templates', __dir__)

class_option :namespace, type: :string, default: nil, desc: "Namespace for the service"
class_option :skip_tests, type: :boolean, default: false, desc: "Skip test files"

Access options with: options[:namespace] </step_2>

<step_3> Add public methods (executed in definition order):

def create_service_file
  template 'service.rb.tt', service_file_path
end

def create_test_file
  return if options[:skip_tests]
  template 'service_test.rb.tt', test_file_path
end

private

def service_file_path
  if options[:namespace]
    "app/services/#{options[:namespace]}/#{file_name}_service.rb"
  else
    "app/services/#{file_name}_service.rb"
  end
end

</step_3>

<step_4> Create ERB templates (.tt extension):

<% if options[:namespace] -%>
module <%= options[:namespace].camelize %>
  class <%= class_name %>Service
    def call
      # Implementation
    end
  end
end
<% else -%>
class <%= class_name %>Service
  def call
    # Implementation
  end
end
<% end -%>

Important: Use <%% to output literal <% in generated files. See references/templates.md for template patterns. </step_4>

<step_5> Test the generator (see Testing section):

Read the full file on GitHub · 458 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. 6d ago First seen · 458 lines · 83 tokens per session scan A ec541dd5a321

Subscribe to this mod's changes

rails-generators is a skill published in the GitHub repository el-feo/ai-context (12 stars, last pushed 1mo ago), licensed MIT. It adds 83 tokens to every session and 3,660 once invoked, about $0.0004 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-30.

Related

Other skills, from other repositories

new

Create a new project to start development quickly.

clacky-ai/openclacky · 10 tokens

rspec-conventions

Rootstrap RSpec conventions. Use when writing, reviewing, or editing RSpec test files (spec//spec.rb, spec/railshelper.rb, spec/spechelper.rb, spec/support//.rb) or factories. Covers describe/context structure, let/subject, matchers, factories, mocking/stubbing, shared examples, and spec types (model, request…

rootstrap/rails_api_base · 82 tokens

ruby-patterns

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

softspark/ai-toolkit · 60 tokens

ruby-rules

Ruby coding rules: style, patterns, security, testing. Triggers: .rb, Gemfile, .gemspec, Rails, ActiveRecord, Sidekiq, RSpec, Sorbet, rubocop.

softspark/ai-toolkit · 48 tokens

ruby-expert

Expert-level Ruby development with Rails, modern features, testing, and best practices. Use when the user mentions Ruby on Rails, RSpec, gem, Sinatra, or metaprogramming, or when the task involves Ruby 3+ Features, Object-Oriented, Functional Features, or Pattern Matching.

personamanagmentlayer/pcl · 64 tokens

activerecord

This skill should be used when the user asks to "write a migration", "add a column", "add column to table", "create an index", "add a foreign key", "set up associations", "fix N+1 queries", "optimize queries", "add validations", "create callbacks", "use eager loading", or mentions ActiveRecord, belongsto, hasmany…

hoblin/claude-ruby-marketplace · 180 tokens