rails-cto
Companion Ruby gem to the rails-cto Claude plugin. Bundles the quality toolchain the plugin's skills depend on (RuboCop, Reek, Flog, Flay, Brakeman, bundler-audit, SimpleCov, Herb) and ships matching configuration templates you can drop into any Rails app with a single command.
Install
Add to your Gemfile:
group :development, :test do
gem "rails-cto"
gem "rubocop-rails", require: false # optional companion — see note below
end
Note on rubocop-rails: it is not a hard dependency of rails-cto because it transitively pulls in activesupport (and connection_pool), which can conflict with host-app pins. The bundled .rubocop.yml still references plugins: - rubocop-rails, so add it to your own Gemfile if you want the Rails cops. Drop that line from your .rubocop.yml if you don't.
Then:
bundle install
bundle exec rails-cto init
What rails-cto init does
- Copies config templates into your project (skipping any that already exist):
.rubocop.yml.reek.yml.bundler-audit.ymlconfig/brakeman.yml.herb/rewriters/align-attributes.mjs.herb/rules/no-inline-styles.mjs
- Patches
test/test_helper.rbto boot SimpleCov with the JSON formatter (so the plugin's QA skill can readcoverage/coverage.json). - Appends a short block to
CLAUDE.mdtelling Claude Code this project uses the rails-cto plugin.
Pass --force to overwrite existing files.
Commands
| Command | Purpose |
|---|---|
rails-cto init |
Install configs and templates (skip existing). |
rails-cto init --force |
Install configs, overwriting existing files. |
rails-cto doctor |
Report which configs are present, missing, or drifted from the bundled templates. Exits non-zero if anything is missing. |
rails-cto version |
Print the gem version. |
Custom RuboCop cop: RailsCTO/MinitestSubject
The bundled .rubocop.yml auto-enables this cop. It enforces the mandatory Minitest::Spec subject rule from the plugin:
- Every
*_test.rbclass must definesubject { ... }exactly once at the top of the class. subjectmust not be reassigned inside nesteddescribe/itblocks.
Disable per file with a standard RuboCop comment:
# rubocop:disable RailsCTO/MinitestSubject
Links
- Claude plugin: https://github.com/mattsears/rails-cto
- Gem source: https://github.com/mattsears/rails-cto-gem
License
MIT.