/reactree-rails-dev:hotwire-patternsfrom reactree-rails-dev
Guides Hotwire implementation in Rails: Turbo Drive, Frames, Streams, Stimulus controllers, real-time updates via ActionCable, and common pitfalls.
Ships in reactree-rails-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
What do I need?
│
├─ Full page navigation without reload?
│ └─ Turbo Drive (automatic, no config needed)
│
├─ Update part of page on interaction?
│ └─ Turbo Frames
│ └─ Wrap section in turbo_frame_tag
│
├─ Real-time updates from server?
│ └─ Turbo Streams + ActionCable
│ └─ Model broadcasts + turbo_stream_from
│
├─ Multiple DOM changes on form submit?
│ └─ Turbo Stream responses
│ └─ respond_to format.turbo_stream
│
├─ JavaScript behavior (click, input, etc)?
│ └─ Stimulus controller
│ └─ data-controller + data-action
│
└─ Communication between controllers?
└─ Stimulus Outlets
└─ static outlets + data-*-outlet
NEVER forget matching frame IDs:
<%# WRONG - IDs don't match, frame won't update %>
<%= turbo_frame_tag "tasks" do %>
<%= link_to "Edit", edit_task_path(@task) %>
<% end %>
<%# edit.html.erb - different ID %>
<%= turbo_frame_tag "task_edit" do %>
<%= render "form" %>
<% end %>
<%# RIGHT - IDs match %>
<%= turbo_frame_tag dom_id(@task) do %>
<%= link_to "Edit", edit_task_path(@task) %>
<% end %>
<%# edit.html.erb - same ID %>
<%= turbo_frame_tag dom_id(@task) do %>
<%= render "form" %>
<% end %>
NEVER return HTML for form errors (return 422):
# WRONG - 200 status doesn't show errors properly
format.turbo_stream {
render turbo_stream: turbo_stream.replace("form", partial: "form")
}
# RIGHT - 422 status for validation errors
format.turbo_stream {
render turbo_stream: turbo_stream.replace("form", partial: "form"),
status: :unprocessable_entity
}
NEVER use target without checking existence:
// WRONG - crashes if target missing
search() {
this.resultsTarget.innerHTML = html
}
// RIGHT - check first
search() {
if (this.hasResultsTarget) {
this.resultsTarget.innerHTML = html
}
}
NEVER forget cleanup in disconnect:
// WRONG - memory leak
connect() {
this.timer = setInterval(() => this.refresh(), 1000)
}
// RIGHT - clean up
connect() {
this.timer = setInterval(() => this.refresh(), 1000)
}
disconnect() {
clearInterval(this.timer)
}
NEVER skip ARIA for dynamic content:
<%# WRONG - screen readers miss updates %>
<div id="tasks">
<%= render @tasks %>
</div>
<%# RIGHT - announce updates %>
<div id="tasks" aria-live="polite">
<%= render @tasks %>
</div>
Hotwire
├── Turbo
│ ├── Turbo Drive — Full page navigation without reload
│ ├── Turbo Frames — Partial page updates
│ └── Turbo Streams — Real-time updates over WebSocket/HTTP
│
└── Stimulus — Lightweight JavaScript controllers
External References:
Automatically converts links/forms to AJAX. Disable when needed:
<%# Skip Turbo Drive for this link %>
<%= link_to "External", "https://example.com", data: { turbo: false } %>
<%# Skip for form %>
<%= form_with model: @user, data: { turbo: false } do |f| %>
| Pattern | Usage |
|---|---|
| Basic frame | turbo_frame_tag "id" |
| Model frame | turbo_frame_tag dom_id(@task) |
| Target other | data: { turbo_frame: "other_id" } |
| Break out | data: { turbo_frame: "_top" } |
| Lazy load | src: path, loading: :lazy |
<%# Lazy loading example %>
<%= turbo_frame_tag "comments",
src: task_comments_path(@task),
loading: :lazy do %>
<p>Loading comments...</p>
<% end %>
| Action | Result |
|---|---|
append | Add to end of container |
prepend | Add to start of container |
replace | Replace entire element |
update | Replace element's contents |
remove | Delete element |
before/after | Insert adjacent |
<%# Stream response %>
<%= turbo_stream.prepend "tasks" do %>
<%= render @task %>
<% end %>
<%= turbo_stream.remove dom_id(@deleted_task) %>
class Task < ApplicationRecord
after_create_commit -> { broadcast_prepend_to "tasks" }
after_update_commit -> { broadcast_replace_to "tasks" }
after_destroy_commit -> { broadcast_remove_to "tasks" }
end
<%# Subscribe in view %>
<%= turbo_stream_from "tasks" %>
<div id="tasks"><%= render @tasks %></div>
| Feature | Declaration | HTML |
|---|---|---|
| Targets | static targets = ["input"] | data-search-target="input" |
| Values | static values = { delay: Number } | data-search-delay-value="300" |
| Classes | static classes = ["active"] | data-search-active-class="bg-blue" |
| Actions | - | data-action="click->search#submit" |
| Outlets | static outlets = ["form"] | data-search-form-outlet="#form" |
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["input", "results"]
static values = { url: String }
search() {
fetch(`${this.urlValue}?q=${this.inputTarget.value}`)
.then(r => r.text())
.then(html => this.resultsTarget.innerHTML = html)
}
}
<div data-controller="search"
data-search-url-value="<%= search_path %>">
<input data-search-target="input"
data-action="input->search#search">
<div data-search-target="results"></div>
</div>
| Modifier | Effect |
|---|---|
:prevent | event.preventDefault() |
:stop | event.stopPropagation() |
.enter | Only on Enter key |
.esc | Only on Escape key |
.away | Click outside element |
<form data-action="submit->form#save:prevent">
<input data-action="keydown.enter->form#save:prevent">
</form>
| Issue | Check |
|---|---|
| Frame not updating | Frame IDs match? |
| Streams not working | turbo_stream_from subscription? |
| Actions not firing | data-action syntax correct? Controller registered? |
| Morphing issues | data-turbo-permanent on persistent elements? |
Detailed patterns and examples in references/:
turbo-frames.md - Frame patterns, lazy loading, navigationturbo-streams.md - Stream actions, broadcasts, form validationstimulus-controllers.md - Targets, values, actions, classes, outletscommon-patterns.md - Infinite scroll, auto-submit, flash messagesaccessibility.md - ARIA, keyboard navigation, focus managementtesting.md - System tests, Stimulus controller teststurbo8-native.md - Turbo 8 morphing, native appsreferences/accessibility.md (opens in a new tab)references/common-patterns.md (opens in a new tab)references/stimulus-controllers.md (opens in a new tab)references/testing.md (opens in a new tab)references/turbo-frames.md (opens in a new tab)references/turbo-streams.md (opens in a new tab)references/turbo8-native.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kaakati/rails-enterprise-dev --plugin reactree-rails-dev26 skills in this plugin
/accessibility-patternsAccessibility PatternsWCAG 2.2 Level AA compliance for Rails/ViewComponent/Hotwire. Use when: (1) Building interactive widgets, (2) Handling form validation errors, (3) Adding dynamic content with Turbo Streams, (4) Auditing existing components. Trigger keywords: accessibility, a11y, WCAG, ARIA, screen reader, keyboard, focus, contrast/action-cable-patternsAction Cable & WebSocket PatternsReal-time WebSocket features with Action Cable in Rails. Use when: (1) Building real-time chat, (2) Live notifications/presence, (3) Broadcasting model updates, (4) WebSocket authorization. Trigger keywords: Action Cable, WebSocket, real-time, channels, broadcasting, stream, subscriptions, presence, cable/activerecord-patternsActiveRecord Query PatternsComplete guide to ActiveRecord query optimization, associations, scopes, and PostgreSQL-specific patterns. Use when: (1) Writing database queries, (2) Designing model associations, (3) Creating migrations, (4) Optimizing query performance, (5) Debugging N+1 queries and GROUP BY errors. Trigger keywords: database, models, associations, validations, queries, ActiveRecord, scopes, migrations, N+1, PostgreSQL, indexes, eager loading/api-development-patternsAPI Development PatternsComprehensive guide to building production-ready REST APIs in Rails with serialization, authentication, versioning, rate limiting, and testing. Trigger keywords: REST API, JSON, serialization, versioning, authentication, JWT, rate limiting, API controllers, request specs, API testing, endpoints, responses/codebase-inspectionCodebase Inspection ProtocolMandatory inspection before writing any Rails code. Use when: (1) Starting ANY implementation task, (2) Making architectural decisions, (3) Suggesting patterns or conventions, (4) Creating new files/classes. Core rule: Never plan without file path citations. Trigger keywords: analyze, inspect, patterns, conventions, codebase, discover, structure, dependencies, existing, before/code-quality-gatesCode Quality GatesExpert decision trees for Solargraph, Sorbet, and Rubocop validation in Rails. Use when: (1) Choosing which quality tool for a task, (2) Debugging type errors or lint failures, (3) Setting up validation pipelines, (4) Deciding strictness levels. Trigger keywords: quality gates, validation, solargraph, sorbet, rubocop, type checking, linting, code quality, static analysis, type safety, srb tcOther plugins' skills for the same job