rails-api

Construct and configure a Rails 8.1 JSON API with serialization, versioning, pagination, error handling, CORS, and documentation.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/jcuervo/rails-skills --skill rails-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-api
Source: https://github.com/jcuervo/rails-skills/tree/main/rails-api
Command: npx skills add https://github.com/jcuervo/rails-skills --skill rails-api

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jbuilder, alba, jsonapi-serializer, blueprinter, pagy, kaminari, rack-cors, rswag, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you build and manage the JSON API surface of a Rails 8.1 app, handling serialization, versioning, pagination, error handling, CORS, and documentation.

Core Features & Use Cases

  • API Style Selection: Choose between REST and GraphQL for your API.
  • Serializer Options: Select from Jbuilder, Alba, jsonapi-serializer, or Blueprinter for JSON serialization.
  • Versioning: Decide on URL path or Accept-header versioning.
  • Pagination: Use Pagy or Kaminari for collection pagination.
  • Error Handling: Standardize error responses into a consistent envelope.
  • CORS Configuration: Configure CORS for browser or mobile clients.
  • Documentation: Generate OpenAPI/Swagger documentation with rswag.
  • Use Case: For a new Rails app, use this Skill to set up the JSON API surface with your chosen settings and ensure it returns well-shaped responses.

Quick Start

Use the rails-api skill to build a JSON API surface for your Rails app.

Frequently Asked Questions about rails-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a JSON API surface in Rails 8.1 with serialization and pagination?

You can configure a JSON API surface in Rails 8.1 by selecting serialization, pagination, versioning, and CORS options. It supports serializers like Jbuilder and Alba, plus pagination via Pagy or Kaminari for well-shaped responses.

What is the best way to version a Rails API endpoint?

Versioning a Rails API endpoint can be done by choosing either URL path or Accept-header versioning. This standardizes routing and ensures clients access the correct API version.

Can I use GraphQL instead of REST for my Rails API?

Yes, you can choose GraphQL instead of REST for your Rails API. The API style selection feature allows you to adopt GraphQL to structure your application's data queries and mutations.

Does Rails 8.1 support generating OpenAPI or Swagger documentation automatically?

Generating OpenAPI or Swagger documentation in Rails 8.1 is supported using the rswag dependency. It allows you to define API specs and produce interactive documentation for your JSON endpoints.

How do I standardize error responses in a Rails JSON API?

To standardize error responses in a Rails JSON API, configure error handling to wrap failures into a consistent envelope. This ensures all client errors return a predictable JSON structure.

Jbuilder vs Alba vs jsonapi-serializer: which should I choose for Rails JSON serialization?

Choosing between Jbuilder, Alba, jsonapi-serializer, and Blueprinter for Rails JSON serialization depends on performance needs and JSON:API specification adherence. Each shapes JSON output differently based on your API requirements.