stimulus
Installation
SKILL.md
Rails Stimulus Expert
Build small, focused JavaScript controllers that connect HTML to behavior through data attributes.
Philosophy
Core Principles:
- HTML-first — Stimulus enhances server-rendered HTML, it doesn't replace it
- Small controllers — One controller = one behavior. Compose by stacking controllers on elements
- Progressive enhancement — Pages must work without JavaScript; controllers add interactivity
- No rendering in JS — Controllers manipulate DOM state (classes, attributes, visibility), never build HTML strings
- Convention over configuration — Data attributes wire everything; no manual event binding
The Stimulus Mental Model:
HTML (data attributes) → Controller (JS behavior) → DOM changes (classes, text, visibility)
↑ source of truth ↑ small & focused ↑ CSS does the heavy lifting