Skip to content

rails-cto init ​

The init command is the one-shot setup for a new (or existing) Rails project. Run it once after adding the gem to your Gemfile, and the project will have everything the plugin's skills need.

Usage ​

bash
bundle exec rails-cto init

Pass --force to overwrite existing config files with the latest bundled templates:

bash
bundle exec rails-cto init --force

What it does ​

The command runs through a checklist and either installs or updates each piece. By default it skips anything that already exists, so running it again is safe and idempotent.

1. Installs toolchain gems ​

Adds each of these to your Gemfile under the development and test groups (if they aren't already present):

  • rubocop with rubocop-rails and rubocop-minitest
  • reek
  • flog
  • flay
  • brakeman
  • bundler-audit
  • simplecov and simplecov_json_formatter
  • herb

Then runs bundle install to resolve them.

2. Drops in config templates ​

Creates the following files if they don't already exist:

FilePurpose
.rubocop.ymlBased on rubocop-rails-omakase with the project's overrides
.reek.ymlReek code smell rules
.bundler-audit.ymlbundler-audit config
config/brakeman.ymlBrakeman scanner config
.herb/rewriters/align-attributes.mjsHerb rewriter that aligns HTML attributes
.herb/rules/no-inline-styles.mjsHerb rule that blocks inline styles

See Config Templates for what each file contains and how to customize it.

3. Patches test/test_helper.rb ​

The QA and Minitest skills read coverage/coverage.json to evaluate code coverage. For that file to exist, SimpleCov needs to boot with the JSON formatter. init inserts the following block near the top of test/test_helper.rb:

ruby
require "simplecov"
require "simplecov_json_formatter"

SimpleCov.start "rails" do
  formatter SimpleCov::Formatter::JSONFormatter
end

If test/test_helper.rb already has a SimpleCov block, init leaves it alone.

4. Wires CLAUDE.md ​

Appends the RailsCTO skills block to your project's CLAUDE.md. See CLAUDE.md Wiring for the exact contents and what each line does.

If your project doesn't have a CLAUDE.md yet, init creates one.

Flags ​

FlagEffect
--forceOverwrite existing config files with the bundled templates
--skip-gemsDon't modify the Gemfile
--skip-claude-mdDon't touch CLAUDE.md
--skip-test-helperDon't patch test/test_helper.rb

After running init ​

Verify everything is in place:

bash
bundle exec rails-cto doctor

You should see a clean report. If doctor flags drift or missing files, re-run init (with --force if needed) to fix them. See rails-cto doctor for details.