Ruby · Rails

Ruby on Rails rules for Cursor

Convention-over-configuration rules for Rails 7 and 8 apps, from strong parameters to Hotwire.

The rule

Save as .cursor/rules/rails.mdc. Cursor picks it up on the next request.

.cursor/rules/rails.mdc

---
description: Ruby on Rails conventions
globs: app/**/*.rb, app/**/*.erb, config/**/*.rb, db/**/*.rb, lib/**/*.rb, test/**/*.rb, spec/**/*.rb
alwaysApply: false
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.

How Cursor loads this rule

Read from the frontmatter above, per Cursor's rules documentation.

  • alwaysApply: false with globs: app/**/*.rb, app/**/*.erb, config/**/*.rb, db/**/*.rb, lib/**/*.rb, test/**/*.rb, spec/**/*.rb: attached automatically when a matching file is in context.
  • Keep the .mdc extension. A plain .md file in .cursor/rules is ignored by the rules system.
  • Prefer to generate your own? Type /create-rule in Agent and describe what you want; Cursor saves the file to .cursor/rules.
  • Team Rules come first, then Project Rules like this one, then User Rules. Earlier sources win when guidance conflicts.

Cursor rules setup guideCursor Team RulesLet Cursor run commands without asking

Ruby on Rails rules for Claude Code, Copilot, Kiro and other agents

The same instructions work as plain Markdown in AGENTS.md, which Codex, Gemini CLI, GitHub Copilot and most other coding agents read.

AGENTS.md (section)

## Ruby on Rails

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for Claude Code.claude/rules/rails.md

.claude/rules/rails.md

---
paths:
  - "app/**/*.rb"
  - "app/**/*.erb"
  - "config/**/*.rb"
  - "db/**/*.rb"
  - "lib/**/*.rb"
  - "test/**/*.rb"
  - "spec/**/*.rb"
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for GitHub Copilot.github/instructions/rails.instructions.md

.github/instructions/rails.instructions.md

---
applyTo: "app/**/*.rb,app/**/*.erb,config/**/*.rb,db/**/*.rb,lib/**/*.rb,test/**/*.rb,spec/**/*.rb"
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for Kiro.kiro/steering/rails.md

.kiro/steering/rails.md

---
inclusion: fileMatch
fileMatchPattern: ["app/**/*.rb", "app/**/*.erb", "config/**/*.rb", "db/**/*.rb", "lib/**/*.rb", "test/**/*.rb", "spec/**/*.rb"]
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for Antigravity.agents/rules/rails.md

.agents/rules/rails.md

---
trigger: glob
globs: "app/**/*.rb, app/**/*.erb, config/**/*.rb, db/**/*.rb, lib/**/*.rb, test/**/*.rb, spec/**/*.rb"
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for Devin Desktop (Windsurf).devin/rules/rails.md

.devin/rules/rails.md

---
trigger: glob
globs: app/**/*.rb, app/**/*.erb, config/**/*.rb, db/**/*.rb, lib/**/*.rb, test/**/*.rb, spec/**/*.rb
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for Cline.clinerules/rails.md

.clinerules/rails.md

---
paths:
  - "app/**/*.rb"
  - "app/**/*.erb"
  - "config/**/*.rb"
  - "db/**/*.rb"
  - "lib/**/*.rb"
  - "test/**/*.rb"
  - "spec/**/*.rb"
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.
Ruby on Rails rules for Continue.continue/rules/rails.md

.continue/rules/rails.md

---
name: "rails"
globs: ["app/**/*.rb", "app/**/*.erb", "config/**/*.rb", "db/**/*.rb", "lib/**/*.rb", "test/**/*.rb", "spec/**/*.rb"]
---

- Follow Rails naming and RESTful routes (resources); use bin/rails generate for models, migrations and controllers.
- Filter input with strong parameters (params.expect, or require and permit on older apps); never pass raw params to create or update.
- Change the schema only with new migrations; never edit a migration that has already run or edit schema.rb by hand.
- Avoid N+1 queries with includes or preload.
- Keep validations and data rules in models; keep controllers thin.
- Use Hotwire (Turbo and Stimulus) for interactivity before adding a JavaScript framework.
- Put background work in Active Job jobs, not in the request cycle.
- Keep secrets in Rails credentials or environment variables, never in committed files.
- Write tests in the project's framework (Minitest or RSpec) and run them before finishing.

Edit this rule and convert it for 11 agents →

More templates

Get Cursor rules and settings changes by email

When Cursor changes how rules, run modes or settings work, we update these templates from the docs and send a short note. One email a week at most.

Reviewed Oct 20, 2026. Written by AgentAtlas. Adapt it to your codebase before relying on it.