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
bundle exec rails-cto initPass --force to overwrite existing config files with the latest bundled templates:
bundle exec rails-cto init --forceWhat 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):
rubocopwithrubocop-railsandrubocop-minitestreekflogflaybrakemanbundler-auditsimplecovandsimplecov_json_formatterherb
Then runs bundle install to resolve them.
2. Drops in config templates
Creates the following files if they don't already exist:
| File | Purpose |
|---|---|
.rubocop.yml | Based on rubocop-rails-omakase with the project's overrides |
.reek.yml | Reek code smell rules |
.bundler-audit.yml | bundler-audit config |
config/brakeman.yml | Brakeman scanner config |
.herb/rewriters/align-attributes.mjs | Herb rewriter that aligns HTML attributes |
.herb/rules/no-inline-styles.mjs | Herb 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:
require "simplecov"
require "simplecov_json_formatter"
SimpleCov.start "rails" do
formatter SimpleCov::Formatter::JSONFormatter
endIf 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
| Flag | Effect |
|---|---|
--force | Overwrite existing config files with the bundled templates |
--skip-gems | Don't modify the Gemfile |
--skip-claude-md | Don't touch CLAUDE.md |
--skip-test-helper | Don't patch test/test_helper.rb |
After running init
Verify everything is in place:
bundle exec rails-cto doctorYou 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.