rails-api-design

rails-api-design is a skill for Claude Code, Codex from sandeepmvl/rails-skills. It costs 137 tokens per session (4,490 once invoked), scanned A, original, MIT.

A guide for designing REST APIs in Ruby on Rails. REST APIs let programs exchange data through web addresses, while Rails is a Ruby web framework.

In plain words
What is it for?
Use it when building or reviewing a Rails JSON API that other applications or mobile clients will use.
Why use it?
It provides decisions for API versions, data formatting, pagination, login protection, rate limits, errors, and documentation.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building or reviewing a Rails JSON API that other applications or mobile clients will use.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sandeepmvl/rails-skills/06-rails-api-design
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.

Any agent
npx skills add sandeepmvl/rails-skills --skill 06-rails-api-design
Clone the repo
git clone --depth 1 https://github.com/sandeepmvl/rails-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rails-api-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/sandeepmvl/rails-skills/06-rails-api-design/github.svg)](https://agentmods.dev/skills/sandeepmvl/rails-skills/06-rails-api-design)
Your own site
<a href="https://agentmods.dev/skills/sandeepmvl/rails-skills/06-rails-api-design"><img src="https://agentmods.dev/badge/skills/sandeepmvl/rails-skills/06-rails-api-design/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rails-api-design

Your own site · 80×15
<a href="https://agentmods.dev/skills/sandeepmvl/rails-skills/06-rails-api-design"><img src="https://agentmods.dev/badge/skills/sandeepmvl/rails-skills/06-rails-api-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 137 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,490 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00137 $0.04490
Opus 5 $0.00068 $0.02245
Sonnet 5 $0.00027 $0.00898
Haiku 4.5 $0.00014 $0.00449

Measured 12d ago against content hash ccfd014247a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

rails-api-design scanned grade A with 1 finding 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 12d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (assets/base-api-controller-template.rb), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

| Debuggability | curl shows the version in the URL | requires correct header to see anything |
skills/06-rails-api-design/SKILL.md · 480 lines

How it starts

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

Rails API Design

Build a JSON API that ages well. AI agents generate Rails APIs by reflex: respond_to :json, to_json, no versioning, no rate limiting, no consistent error shape. This skill encodes the choices senior Rails API authors make when the API has to live for years.

Why this matters

A REST API is a contract. Once clients depend on it, every change is a coordination cost. Get the foundations right at the start — versioning strategy, serialization layer, pagination, error format — or pay for it later in deprecation pain.

The opinion

URL versioning (/api/v1). jsonapi-serializer for JSON:API; alba for plain JSON. pagy for pagination (faster than kaminari). JWT for stateless third-party / mobile clients; session cookies for first-party SPAs on the same domain. rack-attack for rate limiting + brute-force. Structured errors per RFC 9457 (problem-details) or JSON:API errors. rswag for OpenAPI generation from request specs.

Counter-positions:

  • GraphQL over REST: legitimate for highly-relational read APIs with many client variants. We default to REST because the tooling is broader and the operational burden is lower. If you have GraphQL needs, use graphql-ruby.
  • Accept-header versioning (Accept: application/vnd.myapp+json; version=2): cleaner in theory; in practice harder to debug, caches awkwardly, and devs hate it. URL versioning wins on operational ergonomics.
  • active_model_serializers (AMS): widely used historically. We default to jsonapi-serializer (formerly Fast JSONAPI) or alba because both are 10–50× faster.

Core patterns

Pattern 1: URL versioning

Route structure:

# config/routes.rb
Rails.application.routes.draw do
  namespace :api do
    namespace :v1 do
      resources :posts, only: %i[index show create update destroy] do
        resources :comments, only: %i[index create]
      end
      resource :session, only: %i[create destroy]
    end
  end
end

Controller structure:

# app/controllers/api/v1/base_controller.rb
class Api::V1::BaseController < ActionController::API
  include ActionController::HttpAuthentication::Token::ControllerMethods

  before_action :authenticate_user!
  rescue_from ActiveRecord::RecordNotFound, with: :not_found
  rescue_from ActiveRecord::RecordInvalid, with: :unprocessable_entity
  rescue_from Pundit::NotAuthorizedError, with: :forbidden

  private

  def authenticate_user!
    authenticate_or_request_with_http_token do |token, _options|
      @current_user = User.find_by(api_token: token)
    end
  end

  def current_user
    @current_user
  end

  def not_found(error)
    render json: { errors: [{ status: "404", title: "Not Found", detail: error.message }] },
      status: :not_found
  end

  def unprocessable_entity(error)
    render json: { errors: error.record.errors.map { |e| { status: "422", title: "Validation Failed", detail: "#{e.attribute} #{e.message}", source: { pointer: "/data/attributes/#{e.attribute}" } } } },
      status: :unprocessable_entity
  end

  def forbidden(_error)
    render json: { errors: [{ status: "403", title: "Forbidden" }] }, status: :forbidden
  end
end

class Api::V1::PostsController < Api::V1::BaseController
  def index
    posts = policy_scope(Post).includes(:author).order(created_at: :desc)
    pagy_obj, paginated = pagy(posts, limit: 25)
    render json: PostSerializer.new(paginated, meta: pagination_meta(pagy_obj)).serializable_hash
  end
end

Read the full file on GitHub · 480 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 12d ago First seen · 480 lines · 137 tokens per session scan A ccfd014247a0

Subscribe to this mod's changes

rails-api-design is a skill published in the GitHub repository sandeepmvl/rails-skills (21 stars, last pushed 3mo ago), licensed MIT. It adds 137 tokens to every session and 4,490 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

rails-expert

Rails 7+ specialist that optimizes Active Record queries with includes/eagerload, implements Turbo Frames and Turbo Streams for partial page updates, configures Action Cable for WebSocket connections, sets up Sidekiq workers for background job processing, and writes comprehensive RSpec test suites. Use when building…

Jeffallan/claude-skills · 104 tokens

new

Create a new project to start development quickly.

clacky-ai/openclacky · 10 tokens

rails-conventions

Rootstrap Rails conventions. Use when writing, reviewing, or editing any Rails code — controllers, models, migrations, routes, views, mailers, initializers, locale files, or Rails config. Covers routing, ActiveRecord, migrations, i18n, time zones, mailers, assets, Bundler groups, and logging.

rootstrap/rails_api_base · 71 tokens

ruby-rails

Conventions and best practices for building web applications with Ruby on Rails. Use when scaffolding Rails apps or generators, designing ActiveRecord models and migrations, wiring up Hotwire/Turbo/Stimulus interactivity, setting up background jobs or caching, or writing RSpec/Minitest coverage for Rails code.

Mindrally/skills · 65 tokens

ruby-expert

Expert-level Ruby development with Rails, modern features, testing, and best practices. Use when the user mentions Ruby on Rails, RSpec, gem, Sinatra, or metaprogramming, or when the task involves Ruby 3+ Features, Object-Oriented, Functional Features, or Pattern Matching.

personamanagmentlayer/pcl · 64 tokens

rails-dev

Opinionated Rails conventions: rich models, concerns, CRUD-everything, state-as-records, minimal dependencies, Minitest with fixtures. Load this skill BEFORE any code-level thinking, not only before editing a file. It is required the moment a task touches Rails code in ANY way: designing or even just discussing a data…

tech-leads-club/agent-skills · 199 tokens