mcpField
I
inertia-rails-best-practices

inertia-rails-best-practices

github.com/cole-robertsonDevelopment38108 installsUpdated 30w ago
Repository

About inertia-rails-best-practices

A development skill for building and reviewing Inertia.js applications on Ruby on Rails. It organizes practical guidance into eight areas, from server setup and data handling to security and testing.

Key features

  1. 01Guidance across eight development areas
  2. 02Rules for props and data handling
  3. 03Form and validation patterns
  4. 04Navigation and performance guidance
  5. 05Security and testing recommendations

Use cases

  1. 01Starting a new Inertia Rails project
  2. 02Reviewing or refactoring Inertia code
  3. 03Improving page performance
  4. 04Adding secure forms and response tests

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/cole-robertson/inertia-rails-skills --skill inertia-rails-best-practices

After installing, type/inertia-rails-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

README.md
references/
AGENTS.md
scripts/
setup.sh

Details

From the project README

Inertia Rails Best Practices

A comprehensive guide to building high-quality Inertia.js applications with Ruby on Rails. This skill provides 50+ rules across 8 categories, prioritized by impact on application quality, performance, and maintainability.

When to Use This Skill

  • Writing new Inertia Rails controllers or pages
  • Reviewing existing Inertia Rails code
  • Refactoring Rails applications to use Inertia
  • Optimizing performance of Inertia applications
  • Implementing authentication/authorization patterns
  • Building forms with validation
  • Setting up testing for Inertia responses

Categories Overview

#CategoryPriorityImpact
1Server-Side Setup & ConfigurationCRITICALFoundation for all Inertia functionality
2Props & Data ManagementCRITICAL2-5× performance improvement, security
3Forms & ValidationHIGHUser experience, data integrity
4Navigation & RoutingHIGHSPA experience, performance
5Performance OptimizationMEDIUM-HIGH30-70% faster page loads
6SecurityMEDIUM-HIGHProtection against common vulnerabilities
7TestingMEDIUMCode quality, maintainability
8Advanced PatternsMEDIUMScalability, complex use cases

Quick Reference

Server-Side Setup & Configuration (CRITICAL)
IDRuleContext
setup-01Use the Rails generator for initial setupNew projects
setup-02Configure asset versioning for cache bustingAll projects
setup-03Set up proper layout inheritanceMulti-layout apps
setup-04Configure flash keys appropriatelyFlash messaging
setup-05Use environment variables for configurationDeployment
setup-06Set up default render behavior thoughtfullyConvention over configuration
Props & Data Management (CRITICAL)
IDRuleContext
props-01Return only necessary data in propsAll responses
props-02Use shared data for global propsAuth, settings
props-03Leverage lazy evaluation with lambdasExpensive operations
props-04Use deferred props for non-critical dataPerformance
props-05Implement partial reloads correctlyData refreshing
props-06Never expose sensitive data in propsSecurity
props-07Use proper serialization with as_jsonData formatting
props-08Implement deep merge when appropriateNested data
props-09Use once props for stable dataNavigation performance
props-10Use prop transformer for consistent namingcamelCase conversion
Forms & Validation (HIGH)
IDRuleContext
forms-01Use useForm helper for complex formsProgrammatic control
forms-02Use Form component for simple formsDeclarative forms
forms-03Handle validation errors properlyUser feedback
forms-04Implement error bags for multiple formsMulti-form pages
forms-05Use redirect pattern after form submissionPRG pattern
forms-06Handle file uploads correctlyMultipart forms
forms-07Preserve form state on validation errorsUser experience
forms-08Use dotted notation for nested dataComplex forms
forms-09Use precognition for real-time validationServer validation
forms-10Use useHttp for non-navigating requestsAPI calls
Navigation & Routing (HIGH)
IDRuleContext
nav-01Use Link component for internal navigationSPA behavior
nav-02Use inertia_location for external redirectsExternal URLs
nav-03Implement preserve-scroll appropriatelyScroll position
nav-04Use preserve-state for component stateForm preservation
nav-05Configure proper HTTP methods on linksRESTful actions
nav-06Use the inertia route helper for static pagesSimple routes
nav-07Handle 303 redirects correctlyPOST/PUT/PATCH/DELETE
nav-08Use instant visits for perceived performanceFast navigation
Performance Optimization (MEDIUM-HIGH)
IDRuleContext
perf-01Implement code splitting with dynamic importsBundle size
perf-02Use prefetching for likely navigationPerceived performance
perf-03Configure stale-while-revalidate cachingData freshness
perf-04Use polling only when necessaryReal-time updates
perf-05Implement infinite scrolling with merge propsLarge datasets
perf-06Optimize progress indicatorsUser feedback
perf-07Use async visits for non-blocking operationsBackground tasks
perf-08Use InfiniteScroll component for paginationLarge datasets
perf-09Enable view transitions for smooth animationsPage transitions
Security (MEDIUM-HIGH)
IDRuleContext
sec-01Implement authentication server-sideAuth patterns
sec-02Pass authorization results as propsPermission checks
sec-03Use history encryption for sensitive dataBrowser history
sec-04Rely on Rails CSRF protectionForm security
sec-05Validate and sanitize all input server-sideData validation
sec-06Use strong parameters in controllersMass assignment
Testing (MEDIUM)
IDRuleContext
test-01Use RSpec matchers for Inertia responsesRSpec testing
test-02Use Minitest assertions for InertiaMinitest testing
test-03Test partial reloads and deferred propsAdvanced features
test-04Implement end-to-end tests with CapybaraIntegration testing
test-05Test flash messages after redirectsFlash testing
test-06Verify component renderingResponse validation
Advanced Patterns (MEDIUM)
IDRuleContext
adv-01Implement persistent layoutsState preservation
adv-02Use custom component path resolversNon-standard paths
adv-03Configure prop transformersData transformation
adv-04Handle SSR appropriatelySEO requirements
adv-05Implement view transitionsModern animations
adv-06Use scroll regions for complex layoutsScroll management
adv-07Handle events system effectivelyLifecycle hooks
adv-08Use layout props for page-layout communicationLayout data
adv-09Configure the Vite plugin for optimal DXProject setup

For detailed explanations, code examples, and implementation guidance for each rule, see AGENTS.md.

Comments

Markdown supported