Documents Garnish, Craft CMS's JavaScript UI toolkit for control panel, covering class system, UI widgets, drags, forms, utilities, and Craft integration. For CP JS tasks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/craftcms-claude-skills:craft-garnishThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Reference for Garnish, Craft CMS's built-in JavaScript UI framework. Covers the class system, UI widgets, drag interactions, form components, accessibility helpers, and integration with Craft's CP.
Reference for Garnish, Craft CMS's built-in JavaScript UI framework. Covers the class system, UI widgets, drag interactions, form components, accessibility helpers, and integration with Craft's CP.
This skill is scoped to Garnish itself — the JavaScript library at src/web/assets/garnish/. For PHP-side plugin development (elements, controllers, services), see the craftcms skill. For CP template markup that Garnish widgets attach to, see the craftcms skill's cp.md reference.
craftcms — Load when the task involves PHP asset bundle classes, plugin architecture, or CP template markup that Garnish widgets attach to. Skip for pure JavaScript refactoring, Garnish API questions, or JS-only tasks.craft-php-guidelines — Load only when editing PHP files (asset bundle classes, controllers that register JS). Skip for pure JS work.src/web/assets/garnish/src/ in the Craft CMS repositoryUse WebFetch on Craft's class reference (https://docs.craftcms.com/api/v5/) when looking up PHP-side asset bundle registration.
.on() directly instead of this.addListener() — listeners added via jQuery won't auto-clean on destroy(), causing memory leaks.this.base() when overriding destroy() — parent cleanup (listener removal, event teardown) gets skipped.click instead of activate event on non-<button> elements — activate handles both click and keyboard (Space/Enter), making the UI accessible.UiLayerManager by binding ESC directly — use Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY, callback) so escape routes through the layer stack correctly.Garnish.ESC_KEY, Garnish.RETURN_KEY, etc. — constants are self-documenting and consistent.CpAsset dependency chain.destroy() when removing widgets — orphaned listeners accumulate, especially in slideouts and live preview where DOM is repeatedly created/destroyed.import Garnish from 'garnishjs' resolves to window.Garnish via webpack externals; bundling it duplicates 134KB.Garnish.Menu instead of Garnish.CustomSelect — Menu is an alias kept for BC only.Garnish.escManager or Garnish.shortcutManager instead of Garnish.uiLayerManager — the newer manager provides layer-aware keyboard routing that respects the modal/menu stack.Read the relevant reference file(s) for your task. Multiple files often apply together.
Task examples:
class-system.md + ui-widgets.mddrag-system.md + class-system.mdclass-system.md + integration.mdui-widgets.md + integration.mdutilities.md + class-system.mdui-widgets.md (HUD section)ui-widgets.md (Select section)integration.mdintegration.md (Element Index JS Loading)integration.md (Element Index JS Loading — Vite doesn't work for element index classes)utilities.md (ARIA & Focus section)integration.md + class-system.mdintegration.md (Form Widgets section)integration.md (Form Widgets section)| Reference | Scope |
|---|---|
references/class-system.md | Garnish.Base, inheritance (extend/init/base), events (on/off/trigger), listeners (addListener/removeListener), settings, namespacing, enable/disable, destroy lifecycle |
references/ui-widgets.md | Modal, HUD, DisclosureMenu, MenuBtn, SelectMenu, CustomSelect, ContextMenu, Select — constructor args, settings/defaults, methods, events, ARIA behavior |
references/drag-system.md | BaseDrag, Drag, DragSort, DragDrop, DragMove — class hierarchy, settings/defaults, events, helper system, insertion points, scroll handling |
references/utilities.md | Garnish namespace object, key constants, custom jQuery events (activate, textchange, resize), ARIA/focus management, geometry/hit testing, animation, form helpers, detection |
references/integration.md | GarnishAsset PHP bundle, webpack externals, loading sequence, Craft.* class pattern, Twig JS blocks, form widgets (NiceText, CheckboxSelect, MultiFunctionBtn, MixedInput) |
npx claudepluginhub michtio/craftcms-claude-skills --plugin craftcms-claude-skillsReference for extending Craft CMS 5 via plugins and modules: elements, services, controllers, migrations, fields, events, GraphQL, and more. Auto-activates on Craft PHP code.
Builds and reviews all extensions for Wix CLI apps: dashboard pages, modals, plugins, widgets, backend APIs, data collections, and App Market readiness.
Builds accessible, responsive, performant frontend components using design systems, modern CSS, WCAG patterns, and React/Vue/Svelte examples.