stimulus-coder
Use when creating or refactoring Stimulus controllers. Applies Hotwire conventions, controller design patterns, targets/values usage, action handling, and JavaScript best practices.
What this skill does
# Stimulus Coder
**Audience:** Developers building interactive UIs with Stimulus.js and Hotwire.
**Goal:** Write maintainable Stimulus controllers where state lives in HTML and controllers add behavior.
## Core Concepts
- **Controllers** attach behavior to HTML elements
- **Actions** respond to DOM events
- **Targets** reference important elements
- **Values** manage state through data attributes
## Controller Design Principles
### Keep Controllers Small and Reusable
```javascript
// Good: Generic, reusable controller
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["content"]
static values = { open: Boolean }
toggle() { this.openValue = !this.openValue }
openValueChanged() {
this.contentTarget.classList.toggle("hidden", !this.openValue)
}
}
```
### Use Data Attributes for Configuration
```javascript
export default class extends Controller {
static values = {
delay: { type: Number, default: 300 },
event: { type: String, default: "input" }
}
connect() {
this.element.addEventListener(this.eventValue, this.submit.bind(this))
}
submit() {
clearTimeout(this.timeout)
this.timeout = setTimeout(() => this.element.requestSubmit(), this.delayValue)
}
}
```
```erb
<%= form_with data: { controller: "auto-submit", auto_submit_delay_value: 500 } %>
```
### Compose Multiple Controllers
```erb
<div data-controller="toggle clipboard" data-toggle-open-value="false">
<button data-action="toggle#toggle">Show</button>
<div data-toggle-target="content" class="hidden">
<code data-clipboard-target="source">secret-code</code>
<button data-action="clipboard#copy">Copy</button>
</div>
</div>
```
## Targets and Values
### Targets for Element References
```javascript
export default class extends Controller {
static targets = ["tab", "panel"]
static values = { index: { type: Number, default: 0 } }
select(event) { this.indexValue = this.tabTargets.indexOf(event.currentTarget) }
indexValueChanged() {
this.panelTargets.forEach((panel, i) => panel.classList.toggle("hidden", i !== this.indexValue))
this.tabTargets.forEach((tab, i) => tab.setAttribute("aria-selected", i === this.indexValue))
}
}
```
## Action Handling
```erb
<button data-action="click->toggle#toggle">Toggle</button>
<input data-action="input->search#update focus->search#expand">
<button data-action="modal#open" data-modal-id-param="confirm-dialog">Open</button>
<input data-action="keydown.enter->form#submit keydown.escape->form#cancel">
```
### Action Parameters
```javascript
open(event) {
const modalId = event.params.id
document.getElementById(modalId)?.showModal()
}
```
## Common Controller Patterns
### Dropdown Controller
```javascript
export default class extends Controller {
static targets = ["menu"]
static values = { open: Boolean }
toggle() { this.openValue = !this.openValue }
close(event) {
if (!this.element.contains(event.target)) this.openValue = false
}
openValueChanged() {
this.menuTarget.classList.toggle("hidden", !this.openValue)
if (this.openValue) document.addEventListener("click", this.close.bind(this), { once: true })
}
}
```
### Clipboard Controller
```javascript
export default class extends Controller {
static targets = ["source", "button"]
static values = { successMessage: { type: String, default: "Copied!" } }
async copy() {
const text = this.sourceTarget.value || this.sourceTarget.textContent
await navigator.clipboard.writeText(text)
this.showSuccess()
}
showSuccess() {
const original = this.buttonTarget.textContent
this.buttonTarget.textContent = this.successMessageValue
setTimeout(() => this.buttonTarget.textContent = original, 2000)
}
}
```
## Turbo Integration
```javascript
export default class extends Controller {
connect() {
document.addEventListener("turbo:before-visit", this.dismiss.bind(this))
this.timeout = setTimeout(() => this.dismiss(), 5000)
}
disconnect() { clearTimeout(this.timeout) }
dismiss() { this.element.remove() }
}
```
## Architecture Patterns
### Make Controllers Configurable
Externalize hardcoded values into data attributes. Never embed CSS classes, selectors, or thresholds in controller logic.
```javascript
// Bad: hardcoded
export default class extends Controller {
toggle() { this.element.classList.toggle("hidden") }
}
// Good: configurable
export default class extends Controller {
static classes = ["toggle"]
toggle() { this.element.classList.toggle(this.toggleClass) }
}
```
### Mixins Over Deep Inheritance
Use mixins when behavior is shared but doesn't represent specialization.
Decision framework:
- **"is a"** → inheritance (class extends BaseController)
- **"acts as"** → mixin (apply behavior at connect)
- **"has a"** → composition (separate controller + outlets)
```javascript
// Mixin pattern
const Sortable = (controller) => {
const original = controller.prototype.connect
controller.prototype.connect = function() {
if (original) original.call(this)
this.sortable = new Sortable(this.element, this.sortableOptions)
}
}
```
### Targetless Controllers
If a controller mixes element-level and target-level concerns, split it. Controller acting on `this.element` is one responsibility; acting on targets is another.
Communicate between split controllers via custom events or outlets.
### Namespaced Attributes
For flexible parameter sets without explicitly defining each value:
```javascript
// Read arbitrary data-chart-* attributes
get chartOptions() {
return Object.entries(this.element.dataset)
.filter(([key]) => key.startsWith("chart"))
.reduce((opts, [key, val]) => {
opts[key.replace("chart", "").toLowerCase()] = val
return opts
}, {})
}
```
See [architecture-patterns.md](references/architecture-patterns.md) for SOLID principles applied to Stimulus.
## Controller Communication
Choose pattern based on coupling needs:
| Pattern | Coupling | Direction | Use When |
|---------|----------|-----------|----------|
| Custom events | Loose | Broadcast (1→many) | Sender doesn't know receivers |
| Outlets | Structured | Direct (1→1, 1→few) | Known relationships in layout |
| Callbacks | Read-only | Request/response | Sharing state without triggering actions |
### Custom Events (Preferred Default)
```javascript
// Sender
this.dispatch("submitted", { detail: { id: this.idValue }, bubbles: true })
// Receiver (in HTML)
// data-action="sender:submitted->receiver#handleSubmit"
```
Rules:
- Always set `bubbles: true` for cross-controller events
- Namespace event names: `form:submitted`, `cart:updated`
- Document the `detail` contract
### Outlets (Structured Relationships)
```javascript
export default class extends Controller {
static outlets = ["result"]
search() {
const results = this.performSearch()
this.resultOutlets.forEach(outlet => outlet.update(results))
}
resultOutletConnected(outlet) { /* setup */ }
resultOutletDisconnected(outlet) { /* cleanup */ }
}
```
## Lifecycle Best Practices
### Don't Overuse `connect()`
`connect()` is for **third-party plugin initialization only**. Not for state setup (use Values API) or event listeners (use `data-action`).
```javascript
// Good: plugin init in connect
connect() {
this.chart = new Chart(this.canvasTarget, this.chartConfig)
}
disconnect() {
this.chart.destroy()
this.chart = null
}
```
### Always Pair connect/disconnect
Every resource acquired in `connect()` must be released in `disconnect()`. Controllers can connect/disconnect multiple times during Turbo navigation.
### Turbo Cache Teardown
Prevent "flash of manipulated content" when cached pages return:
```javascript
connect() {
document.addEventListener("turbo:before-cache", this.teardown.bind(this))
this.slider = new Swiper(this.element, this.config)
}
teardown() {
this.slider?.destroy()
// Restore original DOM state befoRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.