craftcms
Skill90 starsChanged 4 months agoMITView on GitHub
Craft 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.
In this repository18 other files it gives its agents.
- docs/agents.mdAGENTS.md
- project-template/CLAUDE.mdCLAUDE.md
- reference/CLAUDE.mdCLAUDE.md
- craft-cloudSkill
- craft-content-modelingSkill
- craft-fortrabbitSkill
- craft-garnishSkill
- craft-gated-buildSkill
- craft-mcpSkill
- craft-pestSkill
- craft-php-guidelinesSkill
- craft-plugin-releaseSkill
- craft-pluginsSkill
- craft-project-setupSkill
- craft-siteSkill
- craft-twig-guidelinesSkill
- ddevSkill
- servdSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Always addSelect() in beforePrepare(): the Craft convention, additive when several extensions contribute columns.
- Very specific: line 28
Never put id in getConfig(): project config uses UIDs.
- Very specific: line 31
Never hardcode /admin: cpTrigger is configurable.
- Very specific: line 40
Read only what the task needs.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Craft CMS 5 — Extending (Plugins & Modules)
Craft Version of This Project
!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+]).
Extending Craft CMS 5 with PHP: plugins, modules, custom element and field types, backend integrations. Site work (content modeling, Twig, plugin selection) belongs to craft-site and craft-content-modeling.
Companion Skills
Always load craft-php-guidelines (PHP standards, required for any PHP) and ddev (every command runs through DDEV). Also load: craft-garnish for CP JavaScript, craft-pest for tests (its rollback is opt-in and its env overrides are cwd-bound: both write silently to the dev database), craft-cloud when craft-cloud.yaml or craftcms/cloud is present, craft-mcp for MCP servers, OAuth and personal access tokens [5.12+], craft-plugins for plugin-specific work. Full notes: task-routing.md (Companion skills).
Docs: https://craftcms.com/docs/5.x/extend/ · class reference https://docs.craftcms.com/api/v5/ · generator https://craftcms.com/docs/5.x/extend/generator.html. Use WebFetch when a reference doesn't cover enough.
Common Pitfalls (Cross-Cutting)
- Always
addSelect()inbeforePrepare(): the Craft convention, additive when several extensions contribute columns. - Queue workers run in primary site context: use
->site('*')for cross-site queries (queue-jobs.md). - Never put
idingetConfig(): project config uses UIDs. - Logic belongs in services, not models or controllers.
DateTimeHelperin elements/queries,Carbonin services, never mixed in one class. - Modules register template roots, translations and
controllerNamespacemanually (plugin-vs-module.md). - Never hardcode
/admin:cpTriggeris configurable.UrlHelper::cpUrl()in PHP,cpUrl()in Twig. - Split settings pages: load the full settings model, update it, then
savePluginSettings(); passinggetBodyParams()straight in drops unsubmitted keys (cp.md). - A route or query param named
tokencollides with Craft'stokenParam: 400 before your controller runs (controllers.md, Reserved request params). EVENT_DEFINE_RULESonEntry::classruns for every entry, including nested entries built beforefieldId/ownerIdexist, wheregetType()throwsEither \sectionId` or `fieldId` + `ownerId` must be set on the entry.Always add the rule, decide in'when'behind anisset($entry->fieldId) || isset($entry->sectionId)guard, validate with aValidatorsubclass (events.md`, Validation Rules on Core Elements From a Module).project-config/writeemptiesconfig/project/and rewrites it from the DB. On a stale local DB it deletes teammates' YAML. Runcraft upfirst, require a cleanproject-config/diff, and checkgit diff -- config/projectafterwards. Schema saves from PHP belong in a migration or console command, never a bare bootstrap script (YAML is only flushed onEVENT_AFTER_REQUEST). Seedeployment.md(project-config/write safely) andmigrations.md(Project config writes outside a request).- Any non-underscore-prefixed template in a plugin's
templates/is directly routable in the CP, bypassingbeforeAction()gates. Underscore-prefix the rest (cp.md, CP template routing bypasses controllers).
Reference Files
Read only what the task needs; multiple files often apply. The full task index (130+ task-to-section mappings) is task-routing.md: grep it for a keyword from the task.
Task examples:
- "Build a custom element type" →
elements.md(Architecture first) +element-index.md+fields.md+migrations.md+cp.md - "Add a webhook endpoint" →
controllers.md+events.md - "Queue job that syncs elements" →
queue-jobs.md+elements.md+debugging.md - "Require a field on one entry type / nested entry fails: Either
sectionIdorfieldId+ownerIdmust be set" →events.md(Validation Rules on Core Elements From a Module) - "project-config/write deleted YAML" →
deployment.md; "saveField()/saveEntryType() from a script changed nothing in YAML" →migrations.md(Project config writes outside a request) - "Create or delete sites from code / siteId filter lost after creating a site / phantom sites after deleteSite" →
architecture.md(Creating or deleting sites at runtime) - "'Changed since' filter off by hours" →
architecture.md(Those strings are naive UTC); "['like', ...]returns nothing" →architecture.md(Element-query param setters don't take Yii operator tuples) - "Edit-screen sidebar panel / toolbar split button / metaFieldsHtml" →
cp-ui-patterns.md(Element Edit Screen) +elements.md - "Plugin settings page, tabs, config-file override warning" →
cp.md(Settings Pages) - "Install fails: too many keys" →
migrations.md; "Upgrade to 5.12" [5.12+] →upgrade-5.12.md - Tests → load
craft-pest; Cloud compatibility → loadcraft-cloud(plugin-development.md); headless front ends →craft-site(headless.md) - "Which Craft version does this feature need? / What can this project use on its version?" → grep
version-table.mdfor the feature or version (every version tag in the pack, with older-version alternatives); it is large, so don't read it whole
Large files: read the Contents block, then only the section. architecture.md, config-app.md, config-general.md, controllers.md, cp.md, cp-ui-patterns.md, element-index.md, elements.md, events.md, graphql.md and permissions.md start with a Contents block that gives each section's line range. Read the first 40 lines, then Read only the section you need with offset/limit, never the whole file.
| Task | Read | ~Tokens |
| Full task index: task or symptom → file and section; full pitfall and companion notes | references/task-routing.md | 4.9K |
| Elements: lifecycle, queries, status, authorization, drafts, propagation, field layouts, user edit screens, events | references/elements.md | 8.4K |
| Element index: sources, table/card attributes, status pills, sort, conditions, actions, exporters, relation-field display | references/element-index.md | 6.1K |
| Services, models, records, project config, runtime site creation/deletion, MemoizableArray, API clients, validators | references/architecture.md | 7.4K |
| Plugin vs module differences, module template-root/translation/console registration | references/plugin-vs-module.md | 0.6K |
| 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: widgets, utility pages, slideouts, ajax, editable tables, modals, alerts | references/cp-components.md | 1.8K |
| CP UI patterns: tri-state controls, status indicators, CSS tokens, condition builders, asset bundles, edit-screen sidebar/toolbar | references/cp-ui-patterns.md | 3.4K |
| Migrations, Install.php, foreign keys, indexes, idempotency | references/migrations.md | 3.9K |
| Queue jobs: BaseJob, TTR, retry, progress, batch jobs, site context | references/queue-jobs.md | 4.2K |
| Console commands, options, progress, output helpers, resave actions | references/console-commands.md | 6.0K |
| Debugging, performance, profiling, Xdebug, logging | references/debugging.md | 4.6K |
| PHPStan, ECS, Rector, CI, review checklist | references/quality.md | 3.5K |
Testing: pointer to craft-pest + Codeception basics | references/testing.md | 0.6K |
| Field types, native fields, field layout UI elements, FieldLayoutBehavior | references/fields.md | 3.6K |
| Events: registration, EVENT_DEFINE_RULES, custom events, behaviors, Twig extensions, utilities, widgets, filesystems | references/events.md | 4.4K |
| GraphQL: auth, tokens, types, queries, mutations, directives, resolvers | references/graphql.md | 8.4K |
| Plugin Vite: CP asset bundles, HMR, TypeScript, Vue | references/plugin-vite.md | 2.7K |
| Headless & hybrid: headlessMode, CORS, preview tokens | craft-site skill references/headless.md | 3.4K |
| GeneralConfig (system, routing, security, users, sessions, search, assets, images) | references/config-general.md | 8.4K |
| Craft version table, generated from the pack's version tags | references/version-table.md | 13.3K |
| GeneralConfig (content, templates, performance, GC, localization, headless, GraphQL) | references/config-general-extended.md | 7.2K |
| App config: cache, session, queue, mutex (Redis, one database each), mailer, search, logging, CORS, DB replicas, modules | references/config-app.md | 8.0K |
| Config bootstrap: env vars, aliases, App::parseEnv, custom.php, db.php, routes.php | references/config-bootstrap.md | 3.6K |
| Caching: template cache, data cache, static caching, CDN, invalidation | references/caching.md | 5.2K |
| Permissions: handles, user groups, registration, checking, events | references/permissions.md | 4.7K |
| Element authorization: four-layer defense, can*() methods, query scoping | references/element-authorization.md | 4.6K |
| Sessions & auth: session model, auth tokens, invalidation, elevated sessions | references/sessions-and-auth.md | 3.0K |
| Identity protocols: SSO/OIDC logout, signing algs, issuer vs tenancy, SCIM | references/identity-protocols.md | 1.3K |
| Custom field types: value lifecycle, settings, input HTML, validation, GraphQL | references/field-types-custom.md | 3.5K |
| Conditions framework: custom condition rules, registration | references/conditions.md | 2.3K |
| Email: system messages, programmatic sending, templates, events | references/email.md | 2.4K |
| Deployment: pipeline, project-config/write safely, zero-downtime, CI/CD, rollback | references/deployment.md | 2.5K |
| Drafts & revisions: provisional drafts, autosave, applying, merge | references/drafts-revisions.md | 2.5K |
| Upgrading 5.11 to 5.12.4 [5.12+]: behaviour changes, plugin-code changes, deploy steps | references/upgrade-5.12.md | 2.1K |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

