Skip to content
Web apps

Rails app rules

Rails 8 rules for agents: reversible migrations with real constraints, params.expect, N+1 checks with assert_queries_count, and rubocop and brakeman as the gate.

Verified install Not agent-tested v1.0.0 MIT updated rubyrails
Equips
  • 1 1 Rules
  • 1 1 Skills
  • – 0 MCP

Agents write Rails code that runs, then leave the database to the model layer: validations with no constraint behind them, migrations that only go up, an each loop that fires a query per row, permit! to make a form work. This loadout gives your agent the Rails 8 conventions from the official guides, with the commands that prove a change is done, and a model-change skill whose migration, models and tests the verifier runs on Active Record 8.1 and SQLite. The N+1 test is checked both ways: it passes with includes and fails without it.

What's in it

  • Every schema change is a reversible migration, checked by rolling back and migrating again
  • Database constraints behind validations: null false, foreign keys, unique indexes
  • params.expect, scoped record lookups and no html_safe on user content
  • assert_queries_count guards against N+1 queries
  • bin/rails test, bin/rubocop and bin/brakeman as the done-gate

You'll need

  • Tools: ruby, bundler
Level 1 · automated

Verification

Verified install

Checked at commit 021470d · 9 passed, 0 failed, 1 not applicable

CheckResultWhat we found
Listinglisting.yaml matches the schema and declares every file in the folder. Pass
Schema valid; 7 files declared, none missing or extra
  • tested.status: untested (agent tests are separate from Level 1)
Files parseJSON parses; SKILL.md and .mdc front matter is valid YAML with the fields each agent needs; code fences are closed. Pass All 7 files parse; front matter valid
AdaptersCLAUDE.md imports @AGENTS.md, GEMINI.md imports @./AGENTS.md, and both match the generator. Pass
CLAUDE.md and GEMINI.md import AGENTS.md and are up to date
  • CLAUDE.md: matches the generator
  • GEMINI.md: matches the generator
Install pathsEvery file lands where each agent documents it, with no collisions, and the laid-out project is re-discovered correctly. Pass
Correct paths for all 6 agents; layouts re-discovered
  • Claude Code: 6 files, 1 skill in .claude/skills/
  • Codex CLI: 5 files, 1 skill in .agents/skills/
  • Cursor: 5 files, 1 skill in .agents/skills/
  • Gemini CLI: 6 files, 1 skill in .agents/skills/
  • Antigravity CLI: 5 files, 1 skill in .agents/skills/
  • GitHub Copilot: 5 files, 1 skill in .agents/skills/
MCP configmcp.json is structurally valid, converts to each agent's format, declares no literal secrets, and referenced packages exist on npm/PyPI. Not applicable No MCP servers in this loadout
Safety scanThe intake scanner finds no credentials, risky shell, hidden Unicode or prompt-injection wording, and the listing's network flag is honest. Pass
Clean: no credentials, risky shell or hidden text
  • Scanner intake-precheck/1: verdict clean; network no (listing says yes)
ReferencesLinks and file paths between the loadout's files resolve, including for each agent's installed layout. Pass 1 reference between files resolves for every agent
Size limitsFile count and sizes are within the submission limits; SKILL.md bodies stay under 500 lines. Pass
7 files, 6.9 KB total; largest AGENTS.md 2.2 KB
  • Limits: 30 files, 32 KB per file, 128 KB total, 500 lines per skill or rule
LicenceA recognised SPDX licence, with the licence text available. Pass MIT, by Agent Loadout; text in the repository LICENSE
Starter buildA minimal fixture project with the loadout applied installs and builds or type-checks, and the loadout's own code examples compile. Pass
The rails-model-change skill's migration, models and test run on Active Record 8.1 with SQLite: the migration reverses cleanly, all six model tests pass (including an assert_queries_count N+1 guard), rubocop-rails-omakase is clean, and dropping the includes fails the N+1 test
  • Applied 11 loadout files at every agent's paths
  • ✓ place the examples: bash -c mkdir -p db/migrate app/models test/models && R=.agents/skills/rails-model-change/references && cp $R/20261017120000_create_orders.rb db/migrate/ && cp $R/order.rb app/models/ && cp $R/order_test.rb test/models/ && echo placed
  • ✓ bundle install (pinned gems): bash -c export BUNDLE_PATH="${BUNDLE_PATH:-$HOME/.cache/agent-loadout-verify/bundle}"; bundle install --quiet && echo bundled
  • ✓ migration is reversible: bash -c export BUNDLE_PATH="${BUNDLE_PATH:-$HOME/.cache/agent-loadout-verify/bundle}"; bundle exec ruby reversible.rb
  • ✓ model tests: bash -c export BUNDLE_PATH="${BUNDLE_PATH:-$HOME/.cache/agent-loadout-verify/bundle}"; bundle exec ruby -I. test/models/order_test.rb
  • ✓ rubocop-rails-omakase: bash -c export BUNDLE_PATH="${BUNDLE_PATH:-$HOME/.cache/agent-loadout-verify/bundle}"; bundle exec rubocop db app test
  • ✓ N+1 guard catches a missing includes: bash -c export BUNDLE_PATH="${BUNDLE_PATH:-$HOME/.cache/agent-loadout-verify/bundle}"; sed -i 's/includes(:customer)/all/' app/models/order.rb && bundle exec ruby -I. test/models/order_test.rb -n /avoids_N/; test $? -ne 0 && echo caught
  • Covers: Reversible migration with null: false, a foreign key and unique indexes
  • Covers: Validations mirroring the constraints; normalizes on email
  • Covers: assert_queries_count proves includes avoids N+1, and fails without it
  • Covers: rubocop-rails-omakase clean, as in a new Rails 8 app

What this means: a script checked the files themselves: they parse, they install where each agent looks, any MCP config is sound, the safety scan is clean, references between files resolve, and, where a free and repeatable fixture exists, a small starter project builds with the loadout applied. No AI agent was run. Per-agent results ("tested with agent") are separate and stay untested until an agent actually runs.

Install

Choose your agent. Run the commands from your project root, or download a zip already laid out in the right folders.

Claude Code reads CLAUDE.md (imports AGENTS.md with @AGENTS.md) and skills from .claude/skills/.

Download zip
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/rails-app/1.0.0/AGENTS.md
curl -fsSL --create-dirs -o CLAUDE.md https://loadout.jnw-it.com/raw/rails-app/1.0.0/CLAUDE.md
curl -fsSL --create-dirs -o .claude/skills/rails-model-change/SKILL.md https://loadout.jnw-it.com/raw/rails-app/1.0.0/skills/rails-model-change/SKILL.md
curl -fsSL --create-dirs -o .claude/skills/rails-model-change/references/20261017120000_create_orders.rb https://loadout.jnw-it.com/raw/rails-app/1.0.0/skills/rails-model-change/references/20261017120000_create_orders.rb
curl -fsSL --create-dirs -o .claude/skills/rails-model-change/references/order.rb https://loadout.jnw-it.com/raw/rails-app/1.0.0/skills/rails-model-change/references/order.rb
curl -fsSL --create-dirs -o .claude/skills/rails-model-change/references/order_test.rb https://loadout.jnw-it.com/raw/rails-app/1.0.0/skills/rails-model-change/references/order_test.rb
FileGoes to
AGENTS.mdAGENTS.md
CLAUDE.mdCLAUDE.md
skills/rails-model-change/SKILL.md.claude/skills/rails-model-change/SKILL.md
skills/rails-model-change/references/20261017120000_create_orders.rb.claude/skills/rails-model-change/references/20261017120000_create_orders.rb
skills/rails-model-change/references/order.rb.claude/skills/rails-model-change/references/order.rb
skills/rails-model-change/references/order_test.rb.claude/skills/rails-model-change/references/order_test.rb

Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.

Files

Rules AGENTS.md Rails rules for migrations, models, controllers, secrets and gems. 37 lines
Download Raw
# AGENTS.md: Rails app

Ruby on Rails app. Check `Gemfile.lock` for the Rails version before using newer APIs; these rules assume Rails 8.

## Commands
- Tests: `bin/rails test` (and `bin/rails test:system` if system tests exist). Single file:
  `bin/rails test test/models/order_test.rb`.
- Lint: `bin/rubocop` (rubocop-rails-omakase in new apps). Security: `bin/brakeman --no-pager`.
- Migrations: `bin/rails db:migrate`, then confirm `bin/rails db:rollback` and migrate again work.
- Done means: tests green, rubocop clean, brakeman shows no new warnings, `db/schema.rb` changed only by migrations.

## Models and the database
- Every schema change is a migration generated with `bin/rails generate migration`. Never edit `db/schema.rb` by hand.
- Migrations are reversible (`change` with reversible operations, or `up` and `down`). No data backfills in schema
  migrations on large tables; write a separate task or job.
- Constraints in the database as well as the model: `null: false`, foreign keys, unique indexes behind
  `validates ... uniqueness`.
- If `strong_migrations` is in the Gemfile, follow its advice instead of silencing it.
- Avoid N+1 queries: `includes` or `preload` for associations used in loops. Prove it with `assert_queries_count`.
- Money in integer minor units or `decimal`, never `float`.
- New model or column: use the `rails-model-change` skill.

## Controllers and views
- Strong parameters with `params.expect(order: [:title, :quantity])` (Rails 8) or `require`/`permit`. Never
  `permit!`.
- Keep controllers to the seven REST actions where possible; add a new controller rather than custom actions.
- Escape output: no `html_safe` or `raw` on user content. Use `sanitize` with an allow-list if HTML is required.
- Authorise every record lookup through the current user (`current_user.orders.find(params[:id])`).

## Secrets and config
- Credentials live in `config/credentials.yml.enc`, edited with `bin/rails credentials:edit`. Never commit
  `config/master.key` or print credentials.
- Do not run commands against production (`RAILS_ENV=production`, `kamal`, `cap`) unless the user asks.

## Dependencies
- Ask before adding a gem. Add it with `bundle add <gem> --version "~> x.y"` and commit `Gemfile.lock`.
Adapter CLAUDE.md Imports AGENTS.md for Claude Code. 10 lines
Download Raw
# CLAUDE.md

@AGENTS.md

## Claude Code notes
- Skills from this loadout live in `.claude/skills/`: `rails-model-change`. Use them when their description matches the task.
- Follow AGENTS.md above; where this file and AGENTS.md disagree, AGENTS.md wins.

<!-- From the Agent Loadout "Rails app rules" v1.0.0 — https://loadout.jnw-it.com/loadouts/rails-app/ -->
Adapter GEMINI.md Imports AGENTS.md for Gemini CLI. 10 lines
Download Raw
# GEMINI.md

@./AGENTS.md

## Gemini CLI notes
- Skills from this loadout live in `.agents/skills/`: `rails-model-change`. Use them when their description matches the task.
- Follow AGENTS.md above; where this file and AGENTS.md disagree, AGENTS.md wins.

<!-- From the Agent Loadout "Rails app rules" v1.0.0 — https://loadout.jnw-it.com/loadouts/rails-app/ -->
Skill skills/rails-model-change/SKILL.md Add or change a model with a reversible migration and tests. 23 lines
Download Raw
---
name: rails-model-change
description: Add or change a Rails model with a reversible migration, database constraints, validations, an N+1-safe query scope and a model test. Use for new tables, new columns and new associations.
---

# Rails model change

Examples: `references/20261017120000_create_orders.rb`, `references/order.rb`, `references/order_test.rb`.

1. Generate, do not hand-write the file name: `bin/rails generate migration CreateOrders` (or `AddXToY`).
2. In the migration:
   - `null: false` on required columns, with a default where it makes sense.
   - `t.references ... foreign_key: true` for associations.
   - A unique index for anything validated as unique.
   - Money as integer pence (`price_pence`) or `decimal` with precision and scale.
3. Run `bin/rails db:migrate`, then `bin/rails db:rollback` and `bin/rails db:migrate` again. Both directions must work.
   Commit the `db/schema.rb` change the migration produced.
4. Model: validations that mirror the constraints, associations with `dependent:` chosen on purpose, and scopes that
   preload what callers will use.
5. Test in `test/models/`: one test per validation, one for each scope, and an `assert_queries_count` test for any
   scope that should avoid N+1 queries.
6. Run `bin/rails test test/models/<model>_test.rb`, then the full suite and `bin/rubocop`.
Skill file skills/rails-model-change/references/20261017120000_create_orders.rb Migration with constraints, foreign key and unique indexes. 19 lines
Download Raw
class CreateOrders < ActiveRecord::Migration[8.1]
  def change
    create_table :customers do |t|
      t.string :email, null: false
      t.timestamps
    end
    add_index :customers, :email, unique: true

    create_table :orders do |t|
      t.references :customer, null: false, foreign_key: true
      t.string :reference, null: false
      t.integer :total_pence, null: false, default: 0
      t.string :status, null: false, default: "pending"
      t.timestamps
    end
    add_index :orders, :reference, unique: true
  end
end
Skill file skills/rails-model-change/references/order.rb Models with validations, normalizes and preloading scopes. 24 lines
Download Raw
class Customer < ApplicationRecord
  has_many :orders, dependent: :restrict_with_error

  normalizes :email, with: ->(email) { email.strip.downcase }
  validates :email, presence: true, uniqueness: true
end

class Order < ApplicationRecord
  STATUSES = %w[pending paid refunded].freeze

  belongs_to :customer

  validates :reference, presence: true, uniqueness: true, format: { with: /\AORD-\d{6}\z/ }
  validates :total_pence, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
  validates :status, inclusion: { in: STATUSES }

  scope :paid, -> { where(status: "paid") }
  scope :with_customer, -> { includes(:customer) }

  def total
    format("£%.2f", total_pence / 100.0)
  end
end
Skill file skills/rails-model-change/references/order_test.rb Model tests including an N+1 guard. 44 lines
Download Raw
require "test_helper"

class OrderTest < ActiveSupport::TestCase
  setup do
    @customer = Customer.create!(email: "  Ada@Example.com ")
  end

  test "normalises customer email" do
    assert_equal "ada@example.com", @customer.email
  end

  test "requires a well-formed, unique reference" do
    Order.create!(customer: @customer, reference: "ORD-000001", total_pence: 1250)
    duplicate = Order.new(customer: @customer, reference: "ORD-000001")
    assert_not duplicate.valid?
    assert_includes duplicate.errors[:reference], "has already been taken"
    assert_not Order.new(customer: @customer, reference: "123").valid?
  end

  test "rejects negative totals and unknown statuses" do
    order = Order.new(customer: @customer, reference: "ORD-000002", total_pence: -1, status: "lost")
    assert_not order.valid?
    assert order.errors.key?(:total_pence)
    assert order.errors.key?(:status)
  end

  test "formats the total in pounds" do
    assert_equal "£12.50", Order.new(total_pence: 1250).total
  end

  test "paid scope filters by status" do
    paid = Order.create!(customer: @customer, reference: "ORD-000003", status: "paid")
    Order.create!(customer: @customer, reference: "ORD-000004")
    assert_equal [ paid ], Order.paid.to_a
  end

  test "with_customer avoids N+1 queries" do
    3.times { |i| Order.create!(customer: Customer.create!(email: "c#{i}@example.com"), reference: format("ORD-1%05d", i)) }
    assert_queries_count(2) do
      Order.with_customer.each { |order| order.customer.email }
    end
  end
end

All files: source zip · Licence MIT · By Agent Loadout · First listed

Installing and testing

How do I install Rails app rules in Claude Code?

From your project root, put AGENTS.md, CLAUDE.md, skills/rails-model-change/SKILL.md at .claude/skills/rails-model-change/SKILL.md, skills/rails-model-change/references/20261017120000_create_orders.rb at .claude/skills/rails-model-change/references/20261017120000_create_orders.rb, skills/rails-model-change/references/order.rb at .claude/skills/rails-model-change/references/order.rb, skills/rails-model-change/references/order_test.rb at .claude/skills/rails-model-change/references/order_test.rb. The "Claude Code" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/rails-app/claude-code.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Rails app rules in Codex CLI?

From your project root, put AGENTS.md, skills/rails-model-change/SKILL.md at .agents/skills/rails-model-change/SKILL.md, skills/rails-model-change/references/20261017120000_create_orders.rb at .agents/skills/rails-model-change/references/20261017120000_create_orders.rb, skills/rails-model-change/references/order.rb at .agents/skills/rails-model-change/references/order.rb, skills/rails-model-change/references/order_test.rb at .agents/skills/rails-model-change/references/order_test.rb. The "Codex CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/rails-app/codex.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Rails app rules in Cursor?

From your project root, put AGENTS.md, skills/rails-model-change/SKILL.md at .agents/skills/rails-model-change/SKILL.md, skills/rails-model-change/references/20261017120000_create_orders.rb at .agents/skills/rails-model-change/references/20261017120000_create_orders.rb, skills/rails-model-change/references/order.rb at .agents/skills/rails-model-change/references/order.rb, skills/rails-model-change/references/order_test.rb at .agents/skills/rails-model-change/references/order_test.rb. The "Cursor" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/rails-app/cursor.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Rails app rules in Gemini CLI?

From your project root, put AGENTS.md, GEMINI.md, skills/rails-model-change/SKILL.md at .agents/skills/rails-model-change/SKILL.md, skills/rails-model-change/references/20261017120000_create_orders.rb at .agents/skills/rails-model-change/references/20261017120000_create_orders.rb, skills/rails-model-change/references/order.rb at .agents/skills/rails-model-change/references/order.rb, skills/rails-model-change/references/order_test.rb at .agents/skills/rails-model-change/references/order_test.rb. The "Gemini CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/rails-app/gemini-cli.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Rails app rules in Antigravity CLI?

From your project root, put AGENTS.md, skills/rails-model-change/SKILL.md at .agents/skills/rails-model-change/SKILL.md, skills/rails-model-change/references/20261017120000_create_orders.rb at .agents/skills/rails-model-change/references/20261017120000_create_orders.rb, skills/rails-model-change/references/order.rb at .agents/skills/rails-model-change/references/order.rb, skills/rails-model-change/references/order_test.rb at .agents/skills/rails-model-change/references/order_test.rb. The "Antigravity CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/rails-app/antigravity-cli.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Rails app rules in GitHub Copilot?

From your project root, put AGENTS.md, skills/rails-model-change/SKILL.md at .agents/skills/rails-model-change/SKILL.md, skills/rails-model-change/references/20261017120000_create_orders.rb at .agents/skills/rails-model-change/references/20261017120000_create_orders.rb, skills/rails-model-change/references/order.rb at .agents/skills/rails-model-change/references/order.rb, skills/rails-model-change/references/order_test.rb at .agents/skills/rails-model-change/references/order_test.rb. The "GitHub Copilot" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/rails-app/copilot.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

Has Rails app rules been tested?

It passed the Level 1 automated install checks on 2026-10-17: the files parse, install to each agent's documented paths, and pass the safety scan. No AI agent has run it yet, so no agent pass or fail is claimed.

More for Claude Code, Codex, Cursor, Gemini CLI, Antigravity CLI and GitHub Copilot.