Menu

Post image 1
Post image 2
1 / 2
0

CLAUDE.md for Ruby on Rails: 12 Rules That Stop AI from Writing Legacy Patterns

DEV Community·Olivia Craft·27 days ago
#RsJWkNal
#rails#ruby#claudeai#webdev#fullscreen#order
Reading 0:00
15s threshold

If you've ever asked Claude Code to "add a feature" to a Rails app, you know the failure mode: a 200-line controller, validations duplicated in three places, callbacks chained four-deep, and an N+1 so loud the bullet gem has a panic attack. The model isn't broken — it just doesn't know which Rails you're using. Rails 3 patterns and Rails 7 patterns share syntax but almost nothing else. A CLAUDE.md at the repo root fixes this. It's the file Claude reads on every turn, and it's where you encode the conventions that turn "generic Ruby" into "the way this app is built." Here's a battle-tested ruleset for Ruby on Rails projects. Drop it in your repo and watch generated code stop looking like a 2014 tutorial. Start with project-type detection Rails has three personalities: classic MVC fullstack, Hotwire-first (Rails 7+ with Turbo + Stimulus), and API mode. Each one rejects patterns that are normal in the others. A Turbo Frame in an --api app is a bug; a respond_to :json block in a Hotwire app is a smell.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More