c/agents › command
0votes

CLAUDE.md template for a Ruby on Rails app

TemplateLow risk Tested
submitted by CommandVault editors to c/agents · 4 uses

Project memory for Claude Code in a Rails codebase: commands, structure and Rails-specific rules.

Template · 8 variables
# CLAUDE.md

## Project
{{project_name}}: {{what_it_does}}. Stack: Ruby {{ruby_version}}, Rails {{rails_version}}, {{database}}, {{frontend}}.

## Commands
- Run locally: `bin/dev`
- Tests: `bin/rails test`
- Lint/format: `bundle exec rubocop`

## Where things live
- `app/models`, `app/controllers`, `app/views`: standard Rails
- `app/services`: multi-step business logic
- `app/jobs`: background work ({{job_backend}})
- `db/migrate`: one migration per change

## Conventions
- Fat models are fine; fat controllers are not. Move logic out of controllers.
- Strong parameters on every create/update.
- Avoid N+1 queries: use `includes` and check the log.
- Prefer Rails conventions over custom patterns.

## Never
- Commit secrets or `.env` files; refer to them by name only.
- Run migrations or scripts against production.
- Skip or delete a failing test to make the suite pass.

## Done means
Tests and linters pass, you ran the change for real, and your summary lists what changed and what you didn't verify.
e.g. shop-admin
One line, e.g. inventory and orders for a small store
e.g. 3.3
e.g. 8.0
e.g. PostgreSQL 16
e.g. Hotwire (Turbo + Stimulus) or React via jsbundling
e.g. Solid Queue or Sidekiq
The exact command you run, e.g. bin/rails test or bundle exec rspec
0 commentsreport

Guide

What you get: Claude Code (and Codex, if you save it as AGENTS.md) starts each session knowing your Rails app's name, stack, commands, folder layout and rules. Best for Developers using Claude Code or Codex on a Ruby on Rails app..

Before you start

  • A Rails app
  • Claude Code or Codex installed
  • Knowing whether you use Minitest or RSpec

Worked example (Oct 17, 2026, Claude Code 2.1.296; Codex 0.151.0 (gpt-5.6-sol))

Input

Filled with: project_name=Tinplate Fleetbook, what_it_does=schedules maintenance for a regional bus fleet, ruby_version=3.3.6, rails_version=8.0, database=PostgreSQL 16, frontend=Hotwire (Turbo + Stimulus), job_backend=Solid Queue. Question: Without reading any files, answer from the project instructions you were given at startup: what is this project called, what exact command runs the tests, and name one rule you must follow. If you have no such instructions, say so.

Result

Claude Code: "Project name: Tinplate Fleetbook... Test command: `bin/rails test`. The instructions write it as `bin/rails test (or bundle exec rspec)`... They don't say which test framework the repo actually uses. One rule: Never skip or delete a failing test to make the suite pass." Codex: "Project: Tinplate Fleetbook / Tests: `bin/rails test (or bundle exec rspec)` / Rule: Never run migrations or scripts against production."

Fresh copy of a Next.js 16 starter repo (the stack in the file does not exist; this checks that the file is loaded, not that the commands run). Claude Code: file saved as CLAUDE.md, run headless in plan mode; a second run in JSON mode reported 1 turn, so no files were read. Codex: same text saved as AGENTS.md in a separate fresh copy, read-only sandbox; its log shows no commands run. The user's global ~/.claude/CLAUDE.md was also loaded for Claude Code. Both answers were correct on the first try. Codex repeated the test line verbatim, parenthetical included, which shows the agent can treat it as one command. After this test the Tests line became its own fill-in field ({{test_command}}, default bin/rails test); Codex had repeated the old "bin/rails test (or bundle exec rspec)" wording as if it were one command.

How to check it worked

  • Start a new session in the project folder and ask, without letting it read files, what the project is called and what command runs the tests. It should repeat your CLAUDE.md back.
  • In Claude Code, run /memory to see which instruction files are loaded.
  • If you also use Codex, save the same text as AGENTS.md (or have CLAUDE.md import it) and ask Codex the same question.

Common problems

  • The agent answers with generic Rails advice instead of your values: the file isn't being loaded. Check it's named exactly CLAUDE.md (Codex needs AGENTS.md) and sits at the repo root, then start a new session; edits don't reach a session that's already running.
  • Leftover {{placeholders}}: the agent will repeat them literally. Search the file for '{{' before saving.
  • The file describes commands that don't match the repo (for example a different test runner). The agent trusts the file, so keep it in sync with package/tooling changes.
  • The Tests line names both Minitest and RSpec in one code span. Delete the one you don't use, or the agent may guess wrong or try to run the whole string.

Use this file with your AI tool

Each tool reads project instructions from a different file name. Fill in the blanks above, then save it where your tool looks.

One command
npx commandvault add claude-md-template-for-a-ruby-on-rails-app-dadb0ceb --tool claude
Save as CLAUDE.md
# CLAUDE.md

## Project
{{project_name}}: {{what_it_does}}. Stack: Ruby {{ruby_version}}, Rails {{rails_version}}, {{database}}, {{frontend}}.

## Commands
- Run locally: `bin/dev`
- Tests: `bin/rails test`
- Lint/format: `bundle exec rubocop`

## Where things live
- `app/models`, `app/controllers`, `app/views`: standard Rails
- `app/services`: multi-step business logic
- `app/jobs`: background work ({{job_backend}})
- `db/migrate`: one migration per change

## Conventions
- Fat models are fine; fat controllers are not. Move logic out of controllers.
- Strong parameters on every create/update.
- Avoid N+1 queries: use `includes` and check the log.
- Prefer Rails conventions over custom patterns.

## Never
- Commit secrets or `.env` files; refer to them by name only.
- Run migrations or scripts against production.
- Skip or delete a failing test to make the suite pass.

## Done means
Tests and linters pass, you ran the change for real, and your summary lists what changed and what you didn't verify.

Use it: Claude Code loads it at the start of every session. Check with /context (Memory files).

From Claude Code's docs , checked Oct 17, 2026.

More from c/agents

See all of c/agents →
0 comments

Log in to join the discussion.