/craftcms-claude-skills:craft-garnishfrom craftcms-claude-skills
Reference for Garnish, Craft CMS's built-in JavaScript UI toolkit for the control panel. Covers class system, UI widgets, drag interactions, form components, accessibility helpers, and CP JS memory issues.
Ships in craftcms-claude-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
!sh ${CLAUDE_SKILL_DIR}/scripts/craft-version.sh
If no Craft version line appears above, establish the version before any version-specific advice: craftcms/cms in composer.lock for a site, the lowest version the craftcms/cms constraint in composer.json allows for a plugin, or ask. Then check it against the version tags in this skill ([5.10+], [changed 5.12], [seomatic 5.1+]).
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.name attributes to inputs in a panel injected into another form (an entry-edit sidebar panel, a CP template hook) — the host form serializes them on save and your plugin's values are silently swallowed. Inputs are id-only, your JS reads them by id and posts to your own endpoint, and an Enter-key guard keeps the host form from submitting. See integration.md (Panels Injected Into Another Form).PrismJsAsset for custom grammars, hooks or Prism plugins: since 5.12 it is a shim over TanStack Highlight and they silently stop working. Use HighlightAsset [5.12+] and Craft.highlighter.highlight(code, {lang}). Before 5.12: real Prism. See integration.md (Syntax Highlighting and Uploaders).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)ui-widgets.md (Building a custom overlay/slideout) + class-system.md (Enable / Disable) + utilities.md (ARIA & Focus)class-system.md (Enable / Disable) + utilities.md (Closing an overlay: move focus OUT before hiding)integration.md + class-system.mdintegration.md (Panels Injected Into Another Form) + the craftcms skill's cp-ui-patterns.md for the markupintegration.md (Panels Injected Into Another Form)integration.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) |
House rules: no AI or tool attribution and no co-author trailers in commits, PRs, comments, code or docs; no em dashes in prose; US spelling; no model or vendor names in pack files.
What SKILL.md sets; muted values are Claude Code's defaults
Triggers on: Garnish.Base.extend, this.base(), init/setSettings/destroy, addListener, CpAsset, webpack externals, CP JavaScript, Craft.* pattern, Craft.CP, Garnish.Modal, HUD popover, DisclosureMenu, MenuBtn, CustomSelect, Select, DragSort/DragDrop/DragMove, onSortChange/onSelectionChange, CheckboxSelect, ESC_KEY/RETURN_KEY, UiLayerManager, registerShortcut, trapFocusWithin, focus trap, aria-modal, inert, keyboard navigation CP, Craft.Slideout, Craft.ElementEditor, Craft.sendActionRequest, memory leak, event listener cleanup, jQuery .on() in CP, custom slideout/overlay lifecycle, disable kills listeners, sidebar panel injected into the entry form, id-only inputs with no name attribute, host form swallows my fields, Enter key submits the entry form, lightswitch value in JS. Do NOT trigger for front-end JavaScript (Alpine, Vue, htmx) or Twig templates (craft-site).
Three short reads, in order
npx claudepluginhub michtio/craftcms-claude-skills --plugin craftcms-claude-skills16 skills in this plugin
/craft-cloudCraft Cloud, Pixel & Tonic's serverless hosting platform for Craft CMS. Covers craft-cloud.yaml, the Build → Migrate → Release deploy pipeline, the craftcms/cloud extension, edge transforms and static caching (cache.rules, ESI), the Cloud S3 filesystem, MySQL 8 / Postgres 15 (no MariaDB, no tablePrefix), the Console command runner and scheduled cron, queue jobs, custom domains, preview environments per branch, limits (ephemeral filesystem, no SSH, no .htaccess, no built-in mail), Cloud-compatible plugins, and self-hosted → Cloud migration./craftcmsCraft CMS 5 plugin and module development in PHP. Covers elements, element queries, services, models, records, controllers, migrations, queue jobs, console commands, field types, events, Twig extensions, widgets, permissions, GraphQL, testing, and debugging./Other plugins' skills for the same job