rails_api_base CLAUDE.md

A starter project for building Rails applications that provide JSON web APIs, with an administration website included.

In plain words
What is it for?
Use it to bootstrap a new Rails API, run the application, test it, manage users and permissions, view API documentation, and operate admin tools.
Why use it?
It documents the setup commands, testing workflow, Docker behavior, and the main API and administration areas so changes can be made consistently.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/rootstrap/rails_api_base/claude-md
Clone the repo
git clone --depth 1 https://github.com/rootstrap/rails_api_base
Per session 2,081 This file is loaded in full into every session.
When invoked 2,081 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02081 $0.02081
Opus 5 $0.01040 $0.01040
Sonnet 5 $0.00416 $0.00416
Haiku 4.5 $0.00208 $0.00208

Measured 2d ago against content hash f62052b3efd0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rails_api_base CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 108 lines

How it starts

The opening of the file, as written. The whole thing — 108 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What this repo is

Rootstrap's Rails API template — a Rails 8.1 / Ruby 4.0 boilerplate for JSON APIs. It is meant to be cloned and renamed via bin/bootstrap.sh --name=<project>, which seds rails_api_base to your project name across the codebase. The template ships with two parallel surfaces:

  • A JSON API under /api/v1/* (devise_token_auth, Pundit, Jbuilder, OpenAPI docs).
  • An admin web surface built on ActiveAdmin at /admin/*, with sub-mounts for Flipper (/admin/feature-flags) and GoodJob (/admin/background-jobs).

Common commands

The bin/* wrappers transparently dispatch to Docker (docker compose) when DOCKER_ENABLED=true in .env, otherwise run locally. Use them rather than calling bundle/rails/rspec directly so the same invocation works in both modes.

  • bin/dev — start Rails + JS/CSS bundling watchers (foreman / Procfile.dev). Defaults to port 3000.
  • bin/rspec [path] — run specs. bin/rspec . runs everything. bin/rspec spec/path/to_spec.rb:42 runs a single example. Pass -rm / --remove-containers to tear down docker test services after the run.
  • bin/rails … — any Rails command (bin/rails console, bin/rails db:migrate, …).
  • bin/bundle … — bundler commands.
  • bin/web <cmd> — arbitrary shell command inside the app container/environment.
  • bundle exec rails code:analysis — runs the full lint suite: Brakeman, RuboCop, Reek, rails_best_practices, i18n-tasks (see lib/tasks/code_analysis.rake). Use this before opening a PR.
  • bundle exec annotaterb models — refresh schema annotations on models (config in .annotaterb.yml).
  • yarn build:js --watch / yarn build:css --watch — JS/CSS bundling for ActiveAdmin assets (already wired into bin/dev).

Testing notes

  • Specs require a running Postgres (see docker-compose.yml / docker-compose.test.yml). .env.test provides test DB config.
  • bin/rspec headed by default; set HEADLESS=true for headless feature specs.
  • spec/rails_helper.rb wires several behaviors that affect how to write specs:
    • Prosopite scans every example for N+1 queries — fix the query, don't silence it.
    • rspec-retry retries failed examples (2x in CI via ENV['CI'], 1x locally). Don't paper over flakes by adding retries.
    • SimpleCov is started before Rails loads; coverage lands in coverage/.
    • Flipper resets to a memory adapter before each test, so feature-flag state is per-example. Enable in a before block.
    • Files under spec/forms/ are auto-tagged type: :form and get Shoulda matchers.
    • Files under spec/requests/api/ are picked up by rspec-openapi for API doc generation; other request specs are tagged openapi: false.
  • OpenAPI doc generation is triggered by OPENAPI=1 (CI only on main / changes to spec/requests/api/**). Docs are served at /api-docs (basic auth: SWAGGER_USERNAME / SWAGGER_PASSWORD).

Read the full file on GitHub · 108 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 108 lines · 2,081 tokens per session scan A f62052b3efd0

Subscribe to this mod's changes

rails_api_base CLAUDE.md is an instructions file published in the GitHub repository rootstrap/rails_api_base (631 stars, last pushed 4d ago), licensed MIT. It adds 2,081 tokens to every session, about $0.0104 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.