chaserx/cpc/hotwire-patterns

Claude Code and agent skill by chaserx/cpc

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when adding interactive UI to a Rails application without custom JavaScript — inline editing, live updates, real-time notifications, or partial page navigation. Also applies when choosing between Turbo Frames, Turbo Streams, and Stimulus, or reviewing Hotwire implementation for correctness.

Install

npx vskill@latest install chaserx/cpc/hotwire-patterns

SKILL.md

The same SKILL.md was published earlier as chaserx/cpc/hotwire-patterns.

Hotwire Patterns for Rails

Hotwire (HTML Over The Wire) provides a modern approach to building interactive Rails applications with minimal JavaScript. It consists of Turbo (Drive, Frames, Streams) and Stimulus.

Component Overview

ComponentPurposeWhen to Use
Turbo DriveFull page navigation without reloadDefault — enabled automatically
Turbo FramesIndependently updatable page sectionsInline editing, tabbed content, scoped navigation
Turbo StreamsTargeted DOM updates via CRUD actionsMulti-element updates from form submissions
ActionCable + StreamsReal-time server-pushed updatesChat, notifications, live dashboards
StimulusLightweight client-side behaviorToggles, form feedback, debounced search

Stimulus Essentials

Stimulus controllers add client-side behavior to HTML elements using data attributes.

Naming Conventions
  • data-controller="search" maps to search_controller.js
  • data-search-target="input" accesses this.inputTarget
  • data-action="input->search#search" calls search() method
  • data-search-url-value="/api/search" accesses this.urlValue
  • data-search-active-class="highlighted" accesses this.activeClass

Declare targets, values, and classes as static properties. Always implement disconnect() to clean up event listeners and timers.

Turbo Frames Essentials

Turbo Frames decompose pages into independently updatable sections. Key principles:

  • Use dom_id helper for unique, meaningful frame IDs
  • Provide loading state content for lazy-loaded frames
  • Use data-turbo-frame="_top" to break out of frame scope
  • Wrap both show and edit views in the same frame tag for inline editing

Turbo Streams Actions

ActionDescription
appendAdd to end of container
prependAdd to beginning of container
replaceReplace entire element
updateUpdate content of element
removeRemove element
beforeInsert before element
afterInsert after element
morphMorph element (Rails 7.1+)
refreshReload page via morph (Rails 7.1+)

Respond with format.turbo_stream in controllers. Use .turbo_stream.erb templates for complex responses, or render inline for simple cases.

Review Checklists

Stimulus
  • [ ] Controllers follow naming conventions (name_controller.js)
  • [ ] Targets, values, and classes are declared as static properties
  • [ ] Actions use proper event syntax (event->controller#method)
  • [ ] No direct DOM queries — use targets instead
  • [ ] disconnect() cleans up event listeners and timers
Turbo Frames
  • [ ] Frame IDs are unique and meaningful (use dom_id helper)
  • [ ] Loading states provide user feedback
  • [ ] Frame boundaries are logical (don't wrap too much or too little)
  • [ ] Non-Turbo fallback works for progressive enhancement
Turbo Streams
  • [ ] Stream actions match the intended DOM update
  • [ ] Target elements exist in the DOM before streaming
  • [ ] Partials render correctly in isolation
  • [ ] Broadcasting scope is appropriate (don't over-broadcast)
Performance
  • [ ] No unnecessary full-page reloads (Turbo Drive not disabled broadly)
  • [ ] DOM updates are targeted (prefer replace over full refresh)
  • [ ] Caching still works with frames and streams
  • [ ] JavaScript bundle size is reasonable

Quick Reference

NeedSolution
Navigate without reloadTurbo Drive (default)
Update part of a pageTurbo Frames
Multiple DOM updatesTurbo Streams
Real-time server pushActionCable + Turbo Streams
Client-side behaviorStimulus controller
Form with live updatesTurbo Frame wrapping form
Toast notificationsTurbo Stream append
Infinite scrollTurbo Frame with lazy loading

Additional Resources

Reference Files

For detailed code examples and implementation patterns, consult:

  • `references/stimulus-patterns.md` — Stimulus controller examples (search, toggle, form feedback) and conventions table
  • `references/turbo-frames-patterns.md` — Turbo Frames examples (basic frames, lazy loading, inline editing, breaking out) and Turbo Drive configuration
  • `references/turbo-streams-patterns.md` — Turbo Streams controller responses, templates, inline streams, ActionCable model broadcasting, custom broadcasting, and morphing (Rails 7.1+)

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/chaserx/cpc/hotwire-patterns/badge)](https://verified-skill.com/skills/chaserx/cpc/hotwire-patterns)

Something wrong with this skill or its page? Tell us.