/inertia-rails-skills:alba-inertiafrom inertia-rails-skills
Alba serializers + Typelizer for type-safe Inertia Rails props with auto-generated TypeScript types. Replaces as_json with structured, auto-typed resources.
Ships in inertia-rails-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Requires: alba, typelizer, alba-inertia gems in Gemfile.
Alba serializers for Inertia props with auto-generated TypeScript types.
Replaces as_json(only: [...]) with structured, type-safe resources.
Before creating a resource, ask:
UserResource) — shared across pagesUsersIndexResource) — one per controller actionSharedPropsResource)NEVER:
as_json when Alba is set up — it bypasses type generation and creates untyped propstypelize_from when resource name differs from model — Typelizer can't infer column types and generates unknowndeclare module augmentations in serializers/index.ts — Typelizer-generated types go in serializers/index.ts, manual InertiaConfig goes in globals.d.ts# app/resources/application_resource.rb
class ApplicationResource
include Alba::Resource
helper Typelizer::DSL # enables typelize, typelize_from
helper Alba::Inertia::Resource # enables inertia: option on attributes
include Rails.application.routes.url_helpers
end
# app/controllers/inertia_controller.rb
class InertiaController < ApplicationController
include Alba::Inertia::Controller
inertia_share { SharedPropsResource.new(self).to_inertia }
end
# app/resources/user_resource.rb
class UserResource < ApplicationResource
typelize_from User # needed when resource name doesn't match model
attributes :id, :name, :email
typelize :string?
attribute :avatar_url do |user|
user.avatar.attached? ? rails_blob_path(user.avatar, only_path: true) : nil
end
end
# app/resources/users/index_resource.rb
# Naming convention: {Controller}{Action}Resource
class UsersIndexResource < ApplicationResource
has_many :users, resource: UserResource
typelize :string
attribute :search do |obj, _|
obj.params.dig(:filters, :search)
end
end
Requires Rails Current attributes (e.g., Current.user) to be configured —
see CurrentAttributes.
# app/resources/shared_props_resource.rb
class SharedPropsResource < ApplicationResource
one :auth, source: proc { Current }
attribute :unread_messages_count, inertia: { always: true } do
Current.user&.unread_count || 0
end
has_many :live_now, resource: LiveSessionsResource,
inertia: { once: { expires_in: 5.minutes } }
end
With Alba::Inertia::Controller, instance variables auto-serialize:
class UsersController < InertiaController
def index
@users = User.all # auto-serialized via UserResource
@filters = filter_params # plain data passed through
# Auto-detects UsersIndexResource
end
def show
@user = User.find(params[:id])
# Auto-detects UsersShowResource
end
end
typelize_from tells Typelizer which model to infer column types from — needed when
resource name doesn't match model. For computed attributes, declare types explicitly:
class AuthorResource < ApplicationResource
typelize_from User
attributes :id, :name, :email
typelize :string? # next attribute is string | undefined
attribute :avatar_url do |user|
rails_storage_proxy_path(user.avatar) if user.avatar.attached?
end
typelize filters: "{category: number}" # inline TS type
end
Types auto-generate when Rails server runs. Manual: bin/rake typelizer:generate.
The inertia: option on attributes/associations maps to InertiaRails prop types:
attribute :stats, inertia: :defer # InertiaRails.defer
has_many :users, inertia: :optional # InertiaRails.optional
has_many :countries, inertia: :once # InertiaRails.once
has_many :items, inertia: { merge: true } # InertiaRails.merge
attribute :csrf, inertia: { always: true } # InertiaRails.always
MANDATORY — READ ENTIRE FILE when using grouped defer, merge with match_on,
scroll props, or combining multiple options:
references/prop-options.md (~60 lines) — full syntax
for all inertia: option variants and inertia_prop alternative syntax.
Do NOT load for basic inertia: :defer, inertia: :optional, or
inertia: :once — the shorthand above is sufficient.
| Symptom | Cause | Fix |
|---|---|---|
TypeScript type is all unknown | Missing typelize_from | Add typelize_from ModelName when resource name doesn't match model |
inertia: option has no effect | Missing helper | Ensure helper Alba::Inertia::Resource is in ApplicationResource |
| Types not regenerating | Server not running | Typelizer watches files in dev only. Run bin/rake typelizer:generate manually |
NoMethodError for typelize | Missing helper | Ensure helper Typelizer::DSL is in ApplicationResource |
| Convention-based rendering picks wrong resource | Naming mismatch | Resource must be {Controller}{Action}Resource (e.g., UsersIndexResource for UsersController#index) |
to_inertia undefined | Missing include | Controller needs include Alba::Inertia::Controller |
inertia-rails-controllers (defer, once, merge, scroll)inertia-rails-typescript (InertiaConfig in globals.d.ts)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (inertia-rails/skills) — no native marketplace selected
npx claudepluginhub p/inertia-rails-inertia-rails-skills11 skills in this plugin
/inertia-rails-architectureServer-driven architecture patterns for Inertia Rails + React. Load this FIRST when building any Inertia page or feature — it routes to the right skill. Decision matrix for data loading, forms, navigation, state management. NEVER useEffect+fetch, NEVER redirect_to for external URLs (use inertia_location), NEVER react-hook-form (use Form component). MUST invoke when adding pages, models with views, CRUD, or displaying data in an Inertia Rails app. ALWAYS `render inertia: { key: value }` to pass data — `@ivars` are NOT auto-passed as props./inertia-rails-controllersALWAYS `render inertia: { key: data }` to pass data as props — instance variables are NOT auto-passed (only alba-inertia does that). Rails controller patterns for Inertia.js: render inertia, prop types (defer, optional, merge, scroll), shared data, flash, PRG redirects, validation errors. Use when writing controllers that load data, display records, or serve Inertia responses. CRITICAL: external URLs (Stripe/OAuth) MUST use inertia_location, NEVER redirect_to./inertia-rails-formsFull-stack form handling for Inertia Rails: create, edit, delete, multi-step wizard, and file upload forms with validation errors and progress tracking. React examples inline; Vue and Svelte equivalents in references. Use when building any form, handling file uploads, multi-step forms, client-side validation, or wiring form submission to Rails controllers. NEVER react-hook-form. Use `<Form>` for simple forms, useForm for dynamic/programmatic control./inertia-rails-pagesPage components, persistent layouts, Link/router navigation, Head, Deferred, WhenVisible, InfiniteScroll, and URL-driven state for Inertia Rails. React examples inline; Vue and Svelte equivalents in references. Use when building pages, adding navigation, implementing persistent layouts, infinite scroll, lazy-loaded sections, or working with client-side Inertia APIs (router.reload, router.replaceProp, prefetching)./inertia-rails-setupOne-time project initializer for Inertia Rails skills. Detects stack and frontend framework (React/Vue/Svelte) from Gemfile and package.json, offers to install recommended deps (alba-inertia, js-routes, pagy, shadcn), and generates a CLAUDE.md section that configures which skill patterns apply. Use when first installing these skills, bootstrapping a new Inertia Rails project, or when the stack changes./inertia-rails-testingTesting Inertia Rails responses with RSpec and Minitest: component assertions, prop matching, flash verification, deferred props, and partial reload helpers. Use when writing controller specs, request specs, or integration tests for Inertia pages. ALWAYS use matchers (render_component, have_props, have_flash), NOT direct access (inertia.component, inertia.props). CRITICAL: after POST/PATCH/DELETE with redirect, MUST call follow_redirect! before asserting flash or props — without it you're asserting against the 302, not the Inertia page. Setup: require 'inertia_rails/rspec'.Other plugins' skills for the same job