All skills

Craft CMS 5 plugin and module development — extending Craft with PHP. Covers elements, element queries, services, models, records, controllers, migrations, queue jobs, console commands, field types, native fields, events, behaviors, Twig extensions, widgets, filesystems, permissions, project config, GraphQL, testing, and debugging. Triggers on: beforePrepare()/afterSave()/defineSources()/defineTableAttributes()/attributeHtml(), MemoizableArray, BaseNativeField, EVENT_REGISTER_*/DEFINE_*/BEFORE_*/AFTER_*, CraftVariable, custom element or field type (normalizeValue/serializeValue/inputHtml), webhook, API endpoint, queue/batch job, CP section, dashboard widget, utility page, element action/exporter/condition, registerUserPermissions, requirePermission vs requireAdmin, kebab-case permission handles, allowAdminChanges, canView/canSave/canDelete, defineRules, elevated session, project-config/apply, drafts/revisions, element edit sidebar (EVENT_DEFINE_SIDEBAR_HTML) + toolbar buttons, metaFieldsHtml, VueAdminTable, GeneralConfig, getIsMultiSite/refreshSites stale after creating a site, deleteSite phantom sites, element query stops filtering by siteId, naive UTC datetime columns and strtotime drift, element-query ['like'] tuple matches nothing, configWarning config-file overrides. Always use when writing, editing, or reviewing Craft plugin/module PHP — even when no API is named. For plugin-specific work also load craft-plugins. Do NOT trigger for front-end Twig (craft-site) or content modeling (craft-content-modeling).

Use this Skill: https://skilld.dev/gh/michtio/craftcms-claude-skills/craftcms

This session only. Nothing lands on disk.

referencestesting.md

≈687 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Testing — Pointer

Pest and markhuot/craft-pest-core testing lives in the dedicated craft-pest skill. Load it for anything test-related: harness setup, database isolation, factories, HTTP/queue/DB assertions, mocking, console and event tests, shared-install hygiene, and CI test jobs.

That skill is the single source of truth so the same facts don't drift across two files. Its entry points:

Task craft-pest reference
Set up Pest for a plugin; stop tests writing to the dev database references/isolation.md
Permission memoization, login simulation, UTC fixtures, muting event sinks, queue stubs references/craft-state.md
Factories, HTTP, queue, DB assertions, multi-site, mocking, console, events references/patterns.md
Shared playground installs, Install.php vs migration drift, self-seeding references/shared-state.md
CI test job wiring (check-cs not fix-cs, running from the plugin root) references/ci.md

Two things from that skill are worth knowing before you write any test, because they cause data loss rather than test failures:

  1. craft-pest-core's rollback is opt-in. TestCase boots Craft but does not open a transaction — only the separate RefreshesDatabase trait does. Bind both in tests/Pest.php.
  2. Its env-override mechanism is cwd-bound. InstallsCraft::loadPhpunitXmlEnvironmentVariables() reads only getcwd().'/phpunit.xml(.dist)' and ignores --configuration=, so running a plugin suite from a shared project root silently discards the plugin's own database pins and runs against the live database.

Codeception (Craft's native harness)

Craft core itself is tested with Codeception, and it remains the right choice when you're contributing to core or extending an existing Codeception suite. Otherwise prefer Pest.

// Fixtures — always merge the parent's, or you silently drop them
public function _fixtures(): array
{
    return array_merge(parent::_fixtures(), [
        'sites' => ['class' => SitesFixture::class],
    ]);
}
// Queue assertion
$this->tester->assertPushedToQueue('Syncing items for category 42');

// Mocking Craft components
$this->tester->mockCraftMethods('request', [
    'getPathInfo' => 'api/v1/items',
    'getIsActionRequest' => false,
]);

consoleCommand() works the same as in craft-pest.

Don't mix the two harnesses. craft\test\TestSetup::configureCraft() transitively autoloads craft\test\Craft, which extends Codeception\Module\Yii2 — calling it from a Pest-only project is a fatal class-not-found error.

Source: SKILL.md on GitHub

No alerts16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The craftcms skill is a comprehensive reference guide for Craft CMS 5 plugin and module development. It provides extensive documentation on security best practices, including authorization layers, data handling, and common architectural pitfalls. No malicious patterns or security risks were identified.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

Signed by skilld at 614a89e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 weeks ago

README badge

README badge for michtio/craftcms-claude-skills/craftcms