agentleFS
cole-robertsoncole-robertson/inertia-rails-skills/skills/CLAUDE.md

inertia-rails-skills / skills

CLAUDE.md38 starsChanged 8 months agoMITView on GitHub

This file provides guidance for Claude Code on how to use the Inertia Rails skills effectively. These skills should be referenced when the user is: Activate skills when you detect: Use for: General guidance, code review, refactoring decisions Key points to emphasize: - Always return minimal props data (security + performance) - Use as_json(only: [...]) to whitelist fields - Never expose sensitive data (password_digest, tokens, etc.) - Use deferred props for non-critical data - Follow the PRG pattern for form…

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

21 rules. About 0 are common, 14 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always return minimal props data (security + performance)

    line 34
  2. Very specific:

    Use as_json(only: [...]) to whitelist fields

    line 35
  3. Distinctive:

    Never expose sensitive data (password_digest, tokens, etc.)

    line 36
  4. Distinctive:

    Use deferred props for non-critical data

    line 37
  5. Distinctive:

    Follow the PRG pattern for form submissions

    line 38
  6. Very specific:

    Run bin/setup to install dependencies

    line 49
  7. Very specific:

    Use the Rails generator: bin/rails generate inertia:install

    line 53
  8. Distinctive:

    Create proper initializer configuration

    line 56
  9. Very specific:

    Always use useForm helper for state management

    line 63
  10. Distinctive:

    Use redirect pattern after successful submission

    line 65
  11. Distinctive:

    Use error bags for multiple forms on same page

    line 67
  12. Distinctive:

    Use history encryption for sensitive pages

    line 76
  13. Distinctive:

    Use deferred props for expensive queries

    line 95
  14. Distinctive:

    Add prefetching for likely navigation

    line 97
  15. Distinctive:

    Use code splitting for large apps

    line 98
  16. Distinctive:

    When reviewing Inertia Rails code, check for:

    line 102
  17. Very specific:

    Use setData('field', value) instead of direct assignment

    line 169
  18. Very specific:

    Use v-model directly: v-model="form.email"

    line 173
  19. Distinctive:

    When explaining Inertia concepts:

    line 182
  20. Distinctive:

    Start with the why (the problem it solves)

    line 184
  21. Very specific:

    When working with Inertia.js v3 projects, leverage these new features:

    line 202

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Claude Instructions for Inertia Rails Skills

This file provides guidance for Claude Code on how to use the Inertia Rails skills effectively.

When to Use These Skills

Automatic Activation

These skills should be referenced when the user is:

  • Working with Inertia.js and Ruby on Rails
  • Building single-page applications with Rails backends
  • Using inertia_rails gem
  • Creating React, Vue, or Svelte frontends with Rails
  • Asking about forms, navigation, or data passing in Inertia

Trigger Phrases

Activate skills when you detect:

  • "Inertia", "inertia_rails", "InertiaRails"
  • "render inertia:", "inertia_share"
  • "useForm", "@inertiajs"
  • References to React/Vue/Svelte with Rails
  • "modern monolith" architecture discussions

Skill Usage Guidelines

inertia-rails-best-practices

Use for: General guidance, code review, refactoring decisions

Key points to emphasize:

  • Always return minimal props data (security + performance)
  • Use as_json(only: [...]) to whitelist fields
  • Never expose sensitive data (password_digest, tokens, etc.)
  • Use deferred props for non-critical data
  • Follow the PRG pattern for form submissions

inertia-rails-setup

Use for: New projects, adding Inertia to existing apps

Recommend for NEW projects:

  1. Clone the official starter kit:
    • React: git clone https://github.com/inertia-rails/react-starter-kit myapp
    • Vue: git clone https://github.com/inertia-rails/vue-starter-kit myapp
    • Svelte: git clone https://github.com/inertia-rails/svelte-starter-kit myapp
  2. Run bin/setup to install dependencies
  3. Customize from there (auth, shadcn/ui, layouts included)

For EXISTING Rails apps:

  1. Use the Rails generator: bin/rails generate inertia:install
  2. Configure asset versioning with ViteRuby
  3. Set up shared data in ApplicationController
  4. Create proper initializer configuration

inertia-rails-forms

Use for: Form implementation, validation, file uploads

Key patterns:

  • Always use useForm helper for state management
  • Handle errors with form.errors
  • Use redirect pattern after successful submission
  • Preserve scroll on validation errors
  • Use error bags for multiple forms on same page

inertia-rails-auth

Use for: Authentication, authorization, permissions

Critical points:

  • Auth is handled server-side (no special OAuth needed)
  • Pass permissions as props, not helpers
  • Use history encryption for sensitive pages
  • Clear history on logout

inertia-rails-testing

Use for: Writing tests for Inertia responses

Key matchers (RSpec):

  • expect(inertia).to be_inertia_response
  • expect(inertia).to render_component('path/component')
  • expect(inertia).to have_props(key: value)
  • expect(inertia).to have_flash(notice: 'message')

inertia-rails-performance

Use for: Optimization, slow pages, large datasets

Optimization priorities:

  1. Minimize props data
  2. Use deferred props for expensive queries
  3. Implement partial reloads
  4. Add prefetching for likely navigation
  5. Use code splitting for large apps

Code Review Checklist

When reviewing Inertia Rails code, check for:

Props (CRITICAL)

  • Only necessary fields returned
  • No sensitive data exposed
  • Using as_json(only: [...]) or serializers
  • Large datasets paginated or deferred

Controllers

  • Following redirect pattern after POST/PUT/DELETE
  • Errors passed via inertia: { errors: ... }
  • Shared data set up properly
  • Authorization checked before data access

Frontend

  • Using Link component for navigation (not <a>)
  • Using useForm for form state
  • Handling form.processing state
  • Displaying validation errors

Performance

  • Expensive queries deferred
  • Partial reloads for filtered data
  • Appropriate prefetching configured

Common Mistakes to Catch

  1. Exposing entire models:
    # BAD
    render inertia: { user: User.find(id) }
    
    # GOOD
    render inertia: { user: User.find(id).as_json(only: [:id, :name]) }
  2. Rendering instead of redirecting after forms:
    # BAD
    render inertia: { user: @user }
    
    # GOOD
    redirect_to user_url(@user)
  3. Using <a> tags for internal links:
    // BAD
    <a href="/users">Users</a>
    
    // GOOD
    <Link href="/users">Users</Link>
  4. Not handling form errors:
    // BAD
    <input type="email" value={data.email} onChange={e => setData('email', e.target.value)} />
    
    // GOOD
    <input type="email" value={data.email} onChange={e => setData('email', e.target.value)} />
    {errors.email && <span>{errors.email}</span>}

Framework-Specific Notes

React

  • Use setData('field', value) instead of direct assignment
  • Destructure from useForm: { data, setData, post, errors, processing }

Vue 3

  • Use v-model directly: v-model="form.email"
  • Access via form.errors.email

Svelte 5

  • Direct property access: form.email (no $ prefix in Svelte 5 runes)
  • Access errors via form.errors.email

Response Format

When explaining Inertia concepts:

  1. Start with the why (the problem it solves)
  2. Show incorrect approach first (if applicable)
  3. Show correct approach with code
  4. Explain key points to remember
  5. Link to relevant documentation

Version Compatibility

These skills target:

  • inertia_rails gem 3.19+
  • @inertiajs/* packages 3.x+ (Inertia.js v3)
  • @inertiajs/vite plugin (recommended)
  • Rails 7.x+ (Rails 8 supported)
  • Vite Ruby (recommended bundler)
  • React 19+, Vue 3, Svelte 5+

New in v3

When working with Inertia.js v3 projects, leverage these new features:

  • @inertiajs/vite plugin for automatic page resolution and simplified SSR
  • useHttp hook for standalone HTTP requests without navigation
  • Optimistic updates with router.optimistic() and Form optimistic prop
  • Instant visits for perceived instant navigation
  • Precognition for real-time server-side validation
  • <InfiniteScroll> component with InertiaRails.scroll()
  • useLayoutProps for sharing data between pages and layouts
  • Flash API with flash.inertia for rich flash data
  • View Transitions API support

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.