Reference for extending Craft CMS 5 via plugins and modules: elements, services, controllers, migrations, fields, events, GraphQL, and more. Auto-activates on Craft PHP code.
How this skill is triggered — by the user, by Claude, or both
Slash command
/craftcms-claude-skills:craftcmsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Reference for extending Craft CMS 5 through plugins and modules. Covers everything from elements and services to controllers, migrations, fields, and events.
references/architecture.mdreferences/caching.mdreferences/conditions.mdreferences/config-app.mdreferences/config-bootstrap.mdreferences/config-general-extended.mdreferences/config-general.mdreferences/console-commands.mdreferences/controllers.mdreferences/cp-components.mdreferences/cp-ui-patterns.mdreferences/cp.mdreferences/debugging.mdreferences/deployment.mdreferences/drafts-revisions.mdreferences/element-authorization.mdreferences/element-index.mdreferences/elements.mdreferences/email.mdreferences/events.mdReference for extending Craft CMS 5 through plugins and modules. Covers everything from elements and services to controllers, migrations, fields, and events.
This skill is scoped to extending Craft — building plugins, modules, custom element types, field types, and backend integrations. For site/platform development (content modeling, sections, entry types, Twig templating, plugin selection), see the craft-site skill.
When this skill triggers, also load:
craft-php-guidelines — PHPDoc standards, section headers, naming conventions, class organization, ECS/PHPStan, verification checklist. Required for any PHP code.ddev — All commands run through DDEV. Required for running ECS, PHPStan, scaffolding, and tests.craft-garnish — When working on CP JavaScript, asset bundles, or interactive CP components. Covers Garnish's class system, UI widgets (Modal, HUD, DisclosureMenu, Select), drag system, and the Craft.* JS class pattern.craft-cloud — When the project is hosted on Craft Cloud (detect via craft-cloud.yaml at the repo root or craftcms/cloud in composer.json). Required for plugin Cloud-compatibility constraints — App::isEphemeral() guards, asset-bundle CDN publishing, 15-minute queue-job cap, csrfInput() function over raw token output, and the cloud/up deploy lifecycle events.Use WebFetch on specific doc pages when a reference file doesn't cover enough detail.
addSelect() in beforePrepare() — it's the Craft convention and safely additive when multiple extensions contribute columns.->site('*') for cross-site queries.id in getConfig() — project config uses UIDs, never database IDs.DateTimeHelper in elements/queries, Carbon in services — never mix in the same class./admin in CP URLs — cpTrigger is configurable. Use UrlHelper::cpUrl() in PHP, cpUrl() in Twig.$request->getBodyParams() directly to savePluginSettings() on split-settings pages — only submitted keys persist, other settings are silently dropped. Load the full settings model first, update properties, then save.Read the relevant reference file(s) for your task. Multiple files often apply together.
Task examples:
elements.md (Architecture section first) + element-index.md + fields.md + migrations.md + cp.mdelements.md (Architecture: One Element Class with Native Structure)controllers.md + events.mdqueue-jobs.md + elements.md + debugging.mdcontrollers.md + cp.md + architecture.mdfields.md + events.mdquality.mdcp-components.md (Dashboard Widgets) + events.md (Widget Types section)events.md (Twig Extensions section)events.md (Behaviors section)cp-components.md (Utility Pages) + events.md (Utilities section)plugin-vite.md + load craft-garnish skillcraft-garnish skillfields.md + load craft-garnish skillgraphql.md + load craft-site skill for headless.mdcraft-site skill for headless.mdtesting.mdtesting.mdconfig-app.mdconfig-bootstrap.mdconfig-general.mdconfig-bootstrap.md + config-general.mdconfig-general.md + cp.md (Read-Only Mode)config-bootstrap.md (App::parseEnv)config-bootstrap.mdconfig-app.mdconfig-bootstrap.mdconfig-app.mdgraphql.md + config-general.mdcaching.mdpermissions.mdpermissions.mdarchitecture.md (Plugin Editions section)quality.md (Rector section)quality.md (CI/CD Integration section)migrations.md (Content Migrations section)config-app.md (Database Replicas section)config-app.md (Module Registration section)architecture.md (Custom Validators section)events.md (Filesystem Types section)cp-ui-patterns.md (Condition Builders)cp-ui-patterns.md (Tri-State Inheritance Controls)cp.md (Tabbed Settings Pages)cp-ui-patterns.md (Field Warning Parameter)cp-ui-patterns.md (Craft CSS Custom Properties)quality.md (Pre-Commit Hooks section)element-authorization.md + permissions.mdelement-authorization.md (Layer 3: Query Scoping)element-authorization.md + elements.mdelement-authorization.md (Defense Patterns)sessions-and-auth.md (Plugin Patterns)sessions-and-auth.mdsessions-and-auth.md (passwordResetRequired Gap)element-index.md (Extending Element Indexes via Events)element-index.md (Adding a custom bulk action)element-index.md (Per-Element Edit-Screen Action Menu)element-index.md (Status Pills in Table Attributes)element-index.md (Adding a sidebar source)field-types-custom.md + fields.mdfield-types-custom.md (Relation Fields)conditions.md + element-index.mdconditions.mdemail.mdemail.md (Registering Custom System Messages)config-app.md + email.mddeployment.mddeployment.md (CI/CD Patterns)deployment.md (Zero-Downtime)deployment.md (Rollback Strategies)drafts-revisions.mddrafts-revisions.md (Creating Drafts)drafts-revisions.md (Plugin Considerations)elements.md (Generated Fields)element-index.md (Element Display Modes)elements.md (Extending User Edit Screens)cp.md (Read-Only Mode)cp.md (Settings Pages → With tabs or custom actions). settingsHtml() is single-pane only — tabs require a custom controller and a template extending _layouts/cp directly.craft-cloud skill → plugin-development.md (ephemeral filesystem, asset-bundle constraints, queue cap, CSRF function, cookie-free design)craft-cloud skill → config-file.md + deploy-pipeline.md + extension.mdcraft-cloud skill → migration.mdcraft-cloud skill → plugin-development.md (Ephemeral filesystem) + extension.md (App::isEphemeral)Load only the reference files your task needs — each file costs input tokens on every turn.
| Task | Read | ~Tokens |
|---|---|---|
| Element core: lifecycle, queries, status, authorization, drafts, revisions, propagation, field layouts, user edit screens, events | references/elements.md | 8.4K |
| Element index: sources, table/card attributes, status pills, sort, conditions, actions (bulk + per-element action menu), exporters, sidebar, metadata, extending via events | references/element-index.md | 6.1K |
| Services, models, records, project config, MemoizableArray, events, API clients, custom validators | references/architecture.md | 6.0K |
| Controllers: CP CRUD, webhooks, API endpoints, action routing, authorization | references/controllers.md | 3.9K |
| CP templates, form macros, settings pages, navigation, permissions, read-only mode | references/cp.md | 7.2K |
| CP components: dashboard widgets, utility pages, slideout editors, ajax, alerts | references/cp-components.md | 1.8K |
| CP UI patterns: tri-state controls, status indicators, CSS variables, condition builders, asset bundles | references/cp-ui-patterns.md | 2.4K |
| Database migrations, Install.php, foreign keys, indexes, idempotency, deployment | references/migrations.md | 3.9K |
| Queue jobs, BaseJob, TTR, retry, progress, batch jobs, site context | references/queue-jobs.md | 4.2K |
| Console commands, arguments, options, progress bars, output helpers, resave actions | references/console-commands.md | 6.0K |
| Debugging, performance, query strategy, profiling, Xdebug, caching, logging | references/debugging.md | 4.6K |
| PHPStan, ECS, code review checklist | references/quality.md | 3.5K |
| Testing: Pest setup, element factories, HTTP/queue/DB assertions, mocking, multi-site, console, events | references/testing.md | 2.9K |
| Field types, native fields, BaseNativeField, field layout elements, FieldLayoutBehavior | references/fields.md | 3.6K |
| Events: registration, lifecycle, naming conventions, custom events, behaviors, Twig extensions, utilities, widgets, filesystems | references/events.md | 4.4K |
| GraphQL types, queries, mutations, directives, schema components, resolvers | references/graphql.md | 4.6K |
| Plugin Vite: VitePluginService, CP asset bundles, HMR, TypeScript, Vue in CP | references/plugin-vite.md | 2.7K |
| Headless & hybrid: headlessMode, GraphQL API, CORS, preview tokens, front-end frameworks | craft-site skill references/headless.md | 3.4K |
| GeneralConfig (system, routing, security, users, sessions, search, assets, images) | references/config-general.md | 8.4K |
| GeneralConfig (content, templates, performance, GC, localization, headless, GraphQL, accessibility) | references/config-general-extended.md | 7.2K |
| App config: cache, session, queue, mutex, mailer/SMTP, search, logging, CORS, DB replicas | references/config-app.md | 5.5K |
| Config bootstrap: env vars, aliases, priority order, fluent API, custom.php, db.php, routes.php | references/config-bootstrap.md | 3.6K |
| Caching: template cache tag, data cache, static caching (Blitz), CDN, layered strategy, invalidation | references/caching.md | 5.2K |
| Permissions: built-in handles, user groups, custom registration, Twig/PHP checking, authorization events | references/permissions.md | 4.7K |
| Element authorization: four-layer defense model, authorization events, can*() methods, query scoping | references/element-authorization.md | 4.6K |
| Sessions & auth internals: dual-layer session model, auth tokens, session invalidation, elevated sessions | references/sessions-and-auth.md | 3.0K |
| Custom field types: build pattern, value lifecycle, settings, input HTML, validation, search, GraphQL | references/field-types-custom.md | 3.5K |
| Conditions framework: BaseCondition, ElementCondition, custom condition rules, registering rules | references/conditions.md | 2.3K |
| Email system: system messages, custom messages, programmatic sending, templates, events, testing | references/email.md | 2.4K |
| Deployment: standard pipeline, project config deploy, zero-downtime, CI/CD, rollback | references/deployment.md | 2.5K |
| Drafts & revisions: draft types, provisional drafts, autosave, applying, merge, revisions | references/drafts-revisions.md | 2.5K |
Plugins and modules share the same architecture patterns. The differences are in bootstrapping and registration:
| Feature | Plugin | Module |
|---|---|---|
| CP template root | Automatic (by handle) | Manual via EVENT_REGISTER_CP_TEMPLATE_ROOTS |
| Site template root | Manual via event | Same — manual for both |
| Translation category | Automatic (by handle) | Manual PhpMessageSource in init() |
| Settings model | Built-in createSettingsModel() | Env vars, config files, or private plugin (_ prefix) |
| Install migration | migrations/Install.php | Content migrations only |
| Console commands | Automatic controllerNamespace | Must set before parent::init(), must be bootstrapped |
| CP nav section | $hasCpSection = true | EVENT_REGISTER_CP_NAV_ITEMS |
| Project config | Settings auto-tracked | Manual ProjectConfig::set() only |
| Namespace alias | Automatic via Composer | Must call Craft::setAlias() |
use craft\events\RegisterTemplateRootsEvent;
use craft\web\View;
Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS,
function(RegisterTemplateRootsEvent $event) {
$event->roots['my-module'] = __DIR__ . '/templates';
}
);
Craft::$app->i18n->translations['my-module'] = [
'class' => \craft\i18n\PhpMessageSource::class,
'sourceLanguage' => 'en',
'basePath' => __DIR__ . '/translations',
'allowOverrides' => true,
];
public function init()
{
Craft::setAlias('@mymodule', __DIR__);
if (Craft::$app->getRequest()->getIsConsoleRequest()) {
$this->controllerNamespace = 'modules\\mymodule\\console\\controllers';
} else {
$this->controllerNamespace = 'modules\\mymodule\\controllers';
}
parent::init(); // MUST come after setting controllerNamespace
}
The module must be bootstrapped in config/app.php for console commands to be discoverable.
npx claudepluginhub michtio/craftcms-claude-skills --plugin craftcms-claude-skillsCovers Craft CMS 5 front-end Twig development: atomic design, template architecture, Vite buildchain, image presets, multi-brand theming, JavaScript boundaries, and front-end auth with plugin integrations.
Craft CMS 5 development: content modeling, Twig templating, element queries, GraphQL/headless, plugins, and 4-to-5 migration.
Guides modern WordPress plugin development: scaffolding, debugging, testing, and refactoring. Covers WooCommerce, Gutenberg blocks, custom post types, WordPress REST API, hooks, admin pages, WPCS, PHPUnit, Playwright, and wp-scripts.