One-click install
npx skills add https://github.com/hschne/pi-stuff --skill stimulus-hschne
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stimulus
Source: https://github.com/hschne/pi-stuff/tree/main/skills/stimulus
Command: npx skills add https://github.com/hschne/pi-stuff --skill stimulus-hschne

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the problem of writing unmaintainable, tightly coupled StimulusJS controllers that ignore framework best practices, leading to technical debt, bugs, and hard-to-debug codebases.

Core Features & Use Cases

  • Best Practice Enforcement: Applies opinionated Better Stimulus patterns for controller design, state management, lifecycle handling, and inter-controller communication.
  • Turbo Compatibility: Provides proven patterns for Turbo Drive, Turbo Frames, and Turbo Streams integration, including caching teardown and form submission handling.
  • Use Cases: Ideal for writing new Stimulus controllers, refactoring legacy Stimulus code, reviewing controller architecture, debugging cross-controller communication issues, integrating third-party JavaScript libraries, and implementing form and DOM interaction logic.

Quick Start

Use the stimulus skill to refactor your existing toggle controller to use the Stimulus Values API instead of hardcoded instance state for managing the active class.

Frequently Asked Questions about stimulus

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a StimulusJS controller to use the Values API for state management?

To refactor a StimulusJS controller, replace hardcoded instance state with the Stimulus Values API for declarative state management. This ensures maintainable controller architecture and follows Better Stimulus patterns for proper lifecycle handling.

What's the best way to handle Stimulus controller lifecycle methods for Turbo caching?

Handling Stimulus controller lifecycle methods for Turbo caching requires implementing proper teardown logic in disconnect methods. This prevents memory leaks and ensures correct DOM interaction when Turbo Drive restores cached pages during navigation.

Why does my tightly coupled Stimulus controller architecture cause debugging issues?

Tightly coupled Stimulus controller architecture causes debugging issues because it ignores SOLID design principles and framework best practices. Enforcing proper inter-controller communication and declarative event handling resolves these maintainability problems.

Can I use StimulusJS to integrate third-party JavaScript libraries with Turbo Frames?

Yes, you can integrate third-party JavaScript libraries with Turbo Frames using StimulusJS. Apply correct lifecycle method implementation and Turbo compatibility patterns to manage DOM manipulation and form submission handling seamlessly.

Does this approach support declarative event handling in legacy Stimulus code refactoring?

Yes, this approach supports declarative event handling during legacy Stimulus code refactoring. It enforces SOLID design principles and proper Values API usage, transforming tightly coupled controllers into maintainable architecture.

What are the limitations of hardcoded instance state in StimulusJS controllers?

Hardcoded instance state in StimulusJS controllers limits maintainability and breaks Turbo caching support. Without the Values API, controllers fail to follow framework best practices, leading to technical debt and hard-to-debug codebases.