Rails hotwire

From mikker/dotfiles · View interactive version

Rails hotwire is an AI agent skill from the GitHub repository mikker/dotfiles. Ruby on Rails Hotwire best practices for building interactive applications with Turbo Drive, Turbo Frames, Turbo Streams, Turbo 8 morphing, and Stimulus controllers. This skill should be used when writing, reviewing, or refactoring Hotwire-powered Rails code to ensure optimal patterns for navigation

How to use this skill

Skill file

Community Rails Hotwire Best Practices

Comprehensive guide for building interactive Rails applications with Hotwire (Turbo + Stimulus), maintained by Community. Contains 53 rules across 9 categories, prioritized by impact to guide automated refactoring and code generation. Follows the DHH "One Person Framework" philosophy: the server renders HTML, Turbo makes it feel like an SPA, Stimulus adds the sprinkle of JS where needed.

Default Policy: Adopt First, Opt Out Deliberately

Use Hotwire's conventions fully on the ordinary path: keep prefetch enabled, prefer refresh broadcasts with morphing for broad page updates, and use declarative model broadcasts for lifecycle-driven changes. Do not add architectural complexity for hypothetical scale or future requirements.

Opt out locally when correctness, the interaction, or measured cost warrants it—not only after a visible failure. Expensive hover requests, request fan-out from frames or refresh broadcasts, and operation-specific side effects are concrete reasons to depart from the default. Measure total work per user visit and across connected subscribers, not just the speed of individual endpoints.

The rules below express preferred defaults, not a prohibition on justified alternatives. Preserve the simple path and document exceptions where they are introduced.

When to Apply

Reference these guidelines when:

Rule Categories by Priority

| Priority | Category | Impact | Prefix |

|----------|----------|--------|--------|

| 1 | Navigation & Drive | CRITICAL | drive- |

| 2 | Turbo Frames | CRITICAL | frame- |

| 3 | Turbo Streams | HIGH | stream- |

| 4 | Broadcasting & Real-Time | HIGH | bcast- |

| 5 | Morphing & Page Refresh | HIGH | morph- |

| 6 | Performance Optimization | MEDIUM-HIGH | perf- |

| 7 | Stimulus Patterns | MEDIUM-HIGH | stim- |

| 8 | Architecture Decisions | MEDIUM | arch- |

| 9 | Testing Hotwire | MEDIUM | test- |

Quick Reference

1. Navigation & Drive (CRITICAL)

2. Turbo Frames (CRITICAL)

3. Turbo Streams (HIGH)

4. Broadcasting & Real-Time (HIGH)

5. Morphing & Page Refresh (HIGH)

6. Performance Optimization (MEDIUM-HIGH)

7. Stimulus Patterns (MEDIUM-HIGH)

8. Architecture Decisions (MEDIUM)

9. Testing Hotwire (MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

| File | Description |

|------|-------------|

| references/_sections.md | Category definitions and ordering |

| assets/templates/_template.md | Template for new rules |

| metadata.json | Version and reference information |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.