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…
In this repository10 other files it gives its agents.
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
- Distinctive: line 34
Always return minimal props data (security + performance)
- Very specific: line 35
Use as_json(only: [...]) to whitelist fields
- Distinctive: line 36
Never expose sensitive data (password_digest, tokens, etc.)
- Distinctive: line 37
Use deferred props for non-critical data
- Distinctive: line 38
Follow the PRG pattern for form submissions
- Very specific: line 49
Run bin/setup to install dependencies
- Very specific: line 53
Use the Rails generator: bin/rails generate inertia:install
- Distinctive: line 56
Create proper initializer configuration
- Very specific: line 63
Always use useForm helper for state management
- Distinctive: line 65
Use redirect pattern after successful submission
- Distinctive: line 67
Use error bags for multiple forms on same page
- Distinctive: line 76
Use history encryption for sensitive pages
- Distinctive: line 95
Use deferred props for expensive queries
- Distinctive: line 97
Add prefetching for likely navigation
- Distinctive: line 98
Use code splitting for large apps
- Distinctive: line 102
When reviewing Inertia Rails code, check for:
- Very specific: line 169
Use setData('field', value) instead of direct assignment
- Very specific: line 173
Use v-model directly: v-model="form.email"
- Distinctive: line 182
When explaining Inertia concepts:
- Distinctive: line 184
Start with the why (the problem it solves)
- Very specific: line 202
When working with Inertia.js v3 projects, leverage these new features:
≈ “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.
Files
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_railsgem - 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:
- 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
- React:
- Run
bin/setupto install dependencies - Customize from there (auth, shadcn/ui, layouts included)
For EXISTING Rails apps:
- Use the Rails generator:
bin/rails generate inertia:install - Configure asset versioning with ViteRuby
- Set up shared data in ApplicationController
- Create proper initializer configuration
inertia-rails-forms
Use for: Form implementation, validation, file uploads
Key patterns:
- Always use
useFormhelper 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_responseexpect(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:
- Minimize props data
- Use deferred props for expensive queries
- Implement partial reloads
- Add prefetching for likely navigation
- 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
Linkcomponent for navigation (not<a>) - Using
useFormfor form state - Handling
form.processingstate - Displaying validation errors
Performance
- Expensive queries deferred
- Partial reloads for filtered data
- Appropriate prefetching configured
Common Mistakes to Catch
- Exposing entire models:
# BAD render inertia: { user: User.find(id) } # GOOD render inertia: { user: User.find(id).as_json(only: [:id, :name]) } - Rendering instead of redirecting after forms:
# BAD render inertia: { user: @user } # GOOD redirect_to user_url(@user) - Using
<a>tags for internal links:// BAD <a href="/users">Users</a> // GOOD <Link href="/users">Users</Link> - 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-modeldirectly: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:
- Start with the why (the problem it solves)
- Show incorrect approach first (if applicable)
- Show correct approach with code
- Explain key points to remember
- Link to relevant documentation
Version Compatibility
These skills target:
inertia_railsgem 3.19+@inertiajs/*packages 3.x+ (Inertia.js v3)@inertiajs/viteplugin (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/viteplugin for automatic page resolution and simplified SSRuseHttphook for standalone HTTP requests without navigation- Optimistic updates with
router.optimistic()and Formoptimisticprop - Instant visits for perceived instant navigation
- Precognition for real-time server-side validation
<InfiniteScroll>component withInertiaRails.scroll()useLayoutPropsfor sharing data between pages and layouts- Flash API with
flash.inertiafor rich flash data - View Transitions API support
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
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.

