/sorah-guides:railsfrom sorah-guides
Provides Ruby on Rails coding conventions for configuration, models, controllers, jobs, mailers, logging, API changes, and testing. Activates when writing or reviewing Rails code.
Ships in sorah-guides. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Coding conventions and best practices for Ruby on Rails projects. Project-specific conventions (CLAUDE.md, style guides) always take priority over this guidance.
Related skills:
problem gem): /sorah-guides:rails-problemconfig/initializers/<feature>.rb, branching on Rails.env inside it, so the whole story reads top to bottom in one file. Do not add settings to config/application.rb or config/environments/*.rb; leave those with the boilerplate Rails generated (eager_load, caching, logging level) and settings that must exist before initializers run (load_defaults, autoload paths, logger setup such as config.rails_semantic_logger).Rails.configuration.x.namespace.key, two levels deep. A single-level config.x.foo is not allowed.OrderedOptions: config.x.mailer.subject_prefix = "..." creates the mailer namespace on first access. Assigning config.x.mailer = ActiveSupport::OrderedOptions.new first is noise, and clobbers anything set earlier.Rails.env stay in config: Initializers read ENV.fetch and branch on Rails.env. Application code (models, controllers, jobs, services) reads Rails.configuration.x and never checks ENV or Rails.env; environment differences are configuration values.ENV["VERBOSE"], ENV["KEY_ID"]) inside the task body and pass them down as arguments. A setting that varies per deployment still goes through config.x, even when only a task uses it.# config/initializers/mailer.rb
Rails.application.configure do
case
when Rails.env.development?
config.action_mailer.delivery_method = :letter_opener_web
when Rails.env.test?
config.action_mailer.delivery_method = :test
else
config.action_mailer.delivery_method = :ses_v2
end
config.x.mailer.subject_env_prefix = ENV.fetch("MAILER_SUBJECT_ENV_PREFIX") do
Rails.env.production? ? "" : "[#{Rails.env.upcase}] "
end
end
# Application code
prefix = Rails.configuration.x.mailer.subject_env_prefix
validates/validate on the model, so every writer (job, rake task, console, factory) hits it. Controllers check only what the model cannot see: authentication, authorization, request shape. RecordInvalid from save! renders as a problem (see /sorah-guides:rails-problem).has_many, belongs_to, has_one — specify dependent behavior and foreign key constraintsActiveModel::Type classes and other AR-adjacent modules reused across models live in app/models/concerns/, not at the root of app/models/ or in a new app/types/.rescue_from (see /sorah-guides:rails-problem)include, before_action, skip_before_action, rescue_from and other class macros open the class body, before any action.before_action: A concern registers its check with before_action in included; a controller opts out with skip_before_action :name, raise: false. Do not hide a request hook in a lazy accessor or a send_action/process_action override.enqueue_after_transaction_commit is on for every job, MailDeliveryJob included (set it in the jobs initializer, not only on ApplicationJob), so a worker never sees rows that are not committed. Never opt out per job; a spec that loses an enqueued job is holding the transaction open (see Testing).perform. Jobs are retried, so make them idempotent by checking state before mutating.CurrentAttributes) that a job needs is serialized at enqueue and restored around perform by a concern on ApplicationJob, never passed by hand.ApplicationMailer, compose inside the context they need, and send with deliver_later. Non-production deployments gate recipients with an interceptor.Patterns and pitfalls (context propagation, MailDeliveryJob, interceptor registration under reloading, common job kinds): references/jobs-and-mailers.md.
logger.info("Message", key: value). Pass an exception as its own argument (logger.error("Message", {order_id:}, e)), never interpolated into the message.logger.warn and a payload naming the reason. That is enough; add a metric only when someone will watch it.Sentry.capture_exception(e, level: :warning). Errors that propagate are reported by the framework.API details (signatures, measure_*, level checks): references/logging.md.
A behaviour change on an existing endpoint that a client could notice ships opt-in first, through a preview media type in Accept (GitHub's REST API previews model): Accept: application/json, application/vnd.<app>.<name>-preview+json.
api_preview?(:name); register each media type with Mime::Type.register in an initializer. Responses keep their usual Content-Type.api_preview? exactly where behaviour differs. Keep the current path under a TODO: naming the preview that replaces it, and cover both paths in request specs.Prefer test-driven development: write a failing test first (Red), implement minimum code to pass (Green), then refactor while keeping tests green. Tests should cover both happy paths and error conditions.
assert_api_conform(status:).let_it_be (test-prof) only for records no example mutates.build over create: Use FactoryBot.build unless the example needs a persisted record (scopes, queries, uniqueness constraints). In-memory behavior and delegation (build plus a mock) need no write.after_commit callbacks and enqueue_after_transaction_commit until the wrapper commits. Run examples asserting those outside the wrapper; never change the production code to make them pass.sql.active_record subscriber, test-prof EVENT_PROF), quote the numbers in the PR, and keep only behavioral specs. A count encodes the current implementation and breaks on unrelated refactors.spec/support/; spec files add no after { Model.delete_all }.travel_to depending on project convention, block form so time is restoredExamples and tooling (let_it_be pitfalls, openapi_first setup, profiling commands): references/testing.md.
has_secure_password or dedicated servicefilter_parameters configuration for sensitive request paramsbin/setup: Seed data, fixture files for developmentreferences/jobs-and-mailers.md - ActiveJob and ActionMailer patterns: context propagation, mail delivery job, interceptors, job kindsreferences/logging.md - SemanticLogger API and Sentry reportingreferences/testing.md - let_it_be, OpenAPI contract tests, build vs create, profilingWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sorah/config --plugin sorah-guides23 skills in this plugin
/codingThis skill should be used when writing or reviewing code in any language. Provides language-agnostic coding conventions for code quality, comments, error handling, and formatting. Project-specific conventions always take priority./commit-styleThis skill should be used when writing git commit messages, creating git commits, composing pull request titles and descriptions, or when the user asks to "commit", "git commit", "write commit message", "pull request", or "PR description". Provides conventions for subject lines, prefix patterns, body content, and verb choices./dsql-on-railsThis skill should be used when building, extending, or testing a Rails app on Amazon Aurora DSQL, or when moving a Rails app onto DSQL. Use it when writing a transaction, a uniqueness check, a schema change, a spec, a rake task, or CI for such an app, even if the user only says "add a model" or "fix this flaky spec" in such an app. Signs include `aws-sdk-dsql`, `pg-aws_rds_iam`, `aws_rds_iam_auth_token_generator`, a `*.dsql.<region>.on.aws` host, `ActiveRecord::SerializationFailure` with `OC000`/`OC001`, `retryable_transaction`, `non_idempotent_transaction`, `create index async`, `script/pdsql`, or the user mentioning "DSQL", "Aurora DSQL", or "OCC". Provides connection settings and adapter patches, OCC-aware transactions, schema constraints with psqldef, roles, per-developer schemas, RSpec setup, and CI against real clusters. Project-specific conventions always take priority./english-textThis skill should be used when writing English text on behalf of the user, such as GitHub issue/PR descriptions, code review comments, replies to maintainers or contributors, commit message bodies, business emails, or when the user asks to "write in English", "draft a reply", "write a PR description", "file an issue upstream", or "reply to this email". Provides register, phrasing, punctuation, and formatting conventions derived from the author's own GitHub activity, commits, and emails./github-ciThis skill should be used when writing, editing, or reviewing GitHub Actions workflows (`.github/workflows/*.yml`, composite actions in `.github/actions/`), or when setting up CI, a release pipeline, a Docker image build, or gem/crate publishing for a project. Use it whenever the user mentions "GitHub Actions", "CI", "workflow", "release workflow", "trusted publishing", "pin actions", "zizmor", "actionlint", or asks to "add tests to CI", "publish on tag", or "build a container image in CI", even if they never say "workflow". Provides the standard workflow layout (ci / `_test` / release), least-privilege and SHA-pinning rules, release and publishing patterns, and per-language test jobs. Project-specific conventions always take priority./japanese-textThis skill should be used when writing Japanese text, blog posts, diary entries, technical articles, prose, or when the user asks to write in Japanese, compose a blog post, draft a diary entry, or write technical content in Japanese. Provides writing style, orthography, and composition conventions across personal, technical, and corporate contexts.Other plugins' skills for the same job