mcpField
S
stimulus

stimulus

github.com/faqndo97Development33129 installsUpdated 37w ago
Repository

About stimulus

stimulus is a skill for developers building and maintaining Stimulus controllers that add JavaScript interaction to existing HTML. Its task-based workflows cover creation, debugging, feature changes, and Turbo integration.

Key features

  1. 01Connect behavior through HTML data attributes
  2. 02Follow controller naming conventions
  3. 03Manage controller lifecycle and cleanup
  4. 04Isolate interactions with scopes and outlets
  5. 05Use workflows for development and maintenance

Use cases

  1. 01Create a Stimulus controller from scratch
  2. 02Debug controller connections or actions
  3. 03Add functionality to an existing controller
  4. 04Implement a UI pattern or integrate Turbo

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/faqndo97/ai-skills --skill stimulus

After installing, type/stimulusin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
actions.md
anti-patterns.md
architecture.md
classes.md
outlets.md
performance.md
stimulus-use.md
targets.md
testing-debugging.md
turbo-integration.md
ui-patterns.md
values.md
workflows/
add-feature.md
build-new-controller.md
debug-controller.md
handle-forms.md
implement-ui-pattern.md
integrate-turbo.md
optimize-performance.md
review-controller.md

Details

From the project README

<essential_principles>

How Stimulus Works

Stimulus is a modest JavaScript framework that connects JavaScript behavior to HTML via data attributes. It doesn't render HTML—it enhances existing HTML with interactivity.

1. HTML-First Philosophy

State lives in the DOM, not JavaScript. Controllers can be discarded between page changes and reinitialize from cached HTML. Design controllers to read state from data attributes and restore themselves on reconnection.

2. Convention Over Configuration

Stimulus uses predictable naming conventions:

  • Controller: data-controller="clipboard"
  • Targets: data-clipboard-target="source"
  • Actions: data-action="click->clipboard#copy"
  • Values: data-clipboard-url-value="/api/copy"
  • Classes: data-clipboard-supported-class="visible"
  • Outlets: data-clipboard-result-outlet="#result"
3. Lifecycle Awareness

Controllers have three lifecycle callbacks:

  • initialize() - Called once when controller is instantiated
  • connect() - Called when controller is connected to DOM (can happen multiple times with Turbo)
  • disconnect() - Called when controller is removed from DOM

Always clean up in disconnect() what you set up in connect() (timers, event listeners, observers).

4. Scope Isolation

Each controller only sees elements within its scope (the element with data-controller and its descendants). Targets must be within scope. Use outlets to communicate across controller boundaries.

5. Progressive Enhancement

Build HTML that works without JavaScript first. Use Stimulus to enhance, not replace. Check for API support before using features:

connect() {
  if ("clipboard" in navigator) {
    this.element.classList.add(this.supportedClass)
  }
}

</essential_principles>

**What would you like to do?**
  1. Build a new controller
  2. Debug an existing controller
  3. Add a feature to a controller
  4. Review controller(s) for best practices
  5. Optimize performance
  6. Implement a UI pattern (modal, dropdown, tabs, etc.)
  7. Integrate with Turbo
  8. Handle forms
  9. Something else

Wait for response before proceeding.

| Response | Workflow | |----------|----------| | 1, "new", "create", "build", "start" | `workflows/build-new-controller.md` | | 2, "broken", "fix", "debug", "crash", "bug", "not working" | `workflows/debug-controller.md` | | 3, "add", "feature", "extend", "modify" | `workflows/add-feature.md` | | 4, "review", "audit", "check", "best practices", "patterns" | `workflows/review-controller.md` | | 5, "slow", "optimize", "performance", "fast", "memory" | `workflows/optimize-performance.md` | | 6, "modal", "dropdown", "tabs", "accordion", "toggle", "UI", "pattern" | `workflows/implement-ui-pattern.md` | | 7, "turbo", "frames", "streams", "hotwire" | `workflows/integrate-turbo.md` | | 8, "form", "validation", "submit", "input" | `workflows/handle-forms.md` | | 9, other | Clarify, then select workflow or references |

After reading the workflow, follow it exactly.

<verification_loop>

After Every Change

  1. Does it connect? Check browser console for Stimulus connection messages
  2. Do targets resolve? Verify this.hasXxxTarget returns true
  3. Do actions fire? Add temporary console.log in action methods
  4. Does it clean up? Navigate away and back - no errors, no memory leaks
// Debug mode - add to application.js
application.debug = true

Report to the user:

  • "Controller connects: ✓"
  • "Targets found: X of Y"
  • "Actions working: ✓/✗"
  • "Ready for testing" </verification_loop>

<reference_index>

Domain Knowledge

All in references/:

Core APIs: architecture.md, targets.md, values.md, actions.md, outlets.md, classes.md Ecosystem: stimulus-use.md, ui-patterns.md Integration: turbo-integration.md Quality: testing-debugging.md, performance.md, anti-patterns.md </reference_index>

<workflows_index>

Workflows

All in workflows/:

FilePurpose
build-new-controller.mdCreate new controller from scratch
debug-controller.mdFind and fix bugs
add-feature.mdAdd functionality to existing controller
review-controller.mdAudit controllers for best practices
optimize-performance.mdProfile and speed up
implement-ui-pattern.mdBuild modals, dropdowns, tabs, etc.
integrate-turbo.mdWork with Turbo Frames/Streams
handle-forms.mdForm validation and submission
</workflows_index>

Comments

Markdown supported