magento-module-dev
Create Magento 2 custom modules — registration, directory structure, models, resource models, collections, declarative schema, and data/schema patches. Use when building new modules or understanding module architecture.
Best use case
magento-module-dev is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create Magento 2 custom modules — registration, directory structure, models, resource models, collections, declarative schema, and data/schema patches. Use when building new modules or understanding module architecture.
Teams using magento-module-dev should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/magento-module-dev/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How magento-module-dev Compares
| Feature / Agent | magento-module-dev | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create Magento 2 custom modules — registration, directory structure, models, resource models, collections, declarative schema, and data/schema patches. Use when building new modules or understanding module architecture.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Magento 2 Module Development ## Before writing code **Fetch live docs**: 1. Fetch `https://developer.adobe.com/commerce/php/development/build/component-file-structure/` for module structure 2. Fetch `https://developer.adobe.com/commerce/php/development/` for development overview 3. Web-search `site:developer.adobe.com commerce php development build` for build guides ## Module Directory Structure ``` app/code/VendorName/ModuleName/ ├── Api/ # Service contract interfaces │ └── Data/ # Data interfaces ├── Block/ # View blocks ├── Console/ # CLI commands ├── Controller/ # Controllers │ └── Adminhtml/ # Admin controllers ├── Cron/ # Cron job classes ├── etc/ # Configuration XML │ ├── adminhtml/ # Admin-area configs │ ├── frontend/ # Frontend configs │ ├── module.xml # Module declaration │ ├── di.xml # Dependency injection │ ├── db_schema.xml # Declarative schema │ └── db_schema_whitelist.json ├── Helper/ # Utility classes ├── Model/ # Models │ └── ResourceModel/ # Resource models + collections ├── Observer/ # Event observers ├── Plugin/ # Interceptor classes ├── Setup/ │ └── Patch/ │ ├── Data/ # Data patches │ └── Schema/ # Schema patches ├── Test/ # Tests ├── ViewModel/ # MVVM view models ├── view/ # Templates, layouts, JS, CSS ├── registration.php # Module registration └── composer.json # Composer definition ``` ## Essential Files ### registration.php Registers the module with Magento's component registrar. Uses `ComponentRegistrar::register()` with type `MODULE`. ### etc/module.xml Declares the module name and sequence dependencies (modules that must load before this one). ### composer.json Package definition with type `magento2-module`, PSR-4 autoload mapping, and Magento module dependencies. ## Data Layer Pattern ### Model → Resource Model → Collection - **Model** — extends `AbstractModel`, represents a single entity, `_construct()` initializes resource model - **Resource Model** — extends `AbstractDb`, handles CRUD against a specific table, `_init()` sets table and primary key - **Collection** — extends `AbstractCollection`, represents a set of models, `_init()` maps model to resource model ### Declarative Schema (db_schema.xml) Since Magento 2.3+, database schema is declared in XML rather than install/upgrade scripts. The system computes diffs and applies changes automatically on `setup:upgrade`. ### Data and Schema Patches - **Schema Patches** — structural changes (add columns, modify indexes) - **Data Patches** — data migrations (insert default records, transform data) - Implement `DataPatchInterface` or `SchemaPatchInterface` - `apply()` method contains the migration logic - Patches run once and are tracked in `patch_list` table ## CLI Command Pattern Console commands extend `Symfony\Component\Console\Command\Command`: - Register in `etc/di.xml` as arguments to `Magento\Framework\Console\CommandListInterface` - Implement `configure()` for name/description and `execute()` for logic ## Best Practices - Follow `VendorName_ModuleName` naming convention - Declare all module dependencies in `module.xml` sequence - Use declarative schema instead of install/upgrade scripts - Use data patches for data migrations - Keep models thin — business logic in service classes - Always define service contract interfaces in `Api/` Fetch the component file structure guide for exact directory conventions and required files before creating a module.
Related Skills
medusa-modules
Build custom Medusa v2 modules — DML data models, services extending MedusaService, loaders, module links, and container registration. Use when creating custom modules.
magento-testing
Write tests for Magento 2 — PHPUnit unit tests, integration tests, MFTF functional tests, and API tests. Use when implementing test coverage for modules, debugging, or setting up CI/CD test pipelines.
magento-setup
Set up a Magento 2 Open Source project — installation, Composer setup, system requirements verification, and initial configuration. Use when starting a new Magento project or setting up a development environment.
magento-service-contracts
Implement Magento 2 service contracts — repository interfaces, data interfaces, SearchCriteria, and the repository pattern. Use when building module APIs, data access layers, or integrating with Magento's Web API.
magento-security
Implement Magento 2 security — CSP, 2FA, CSRF protection, ACL, admin security configuration, input validation, and security best practices. Use when hardening a Magento installation or reviewing security posture.
magento-plugins-interceptors
Implement Magento 2 plugins (interceptors) — before, after, and around methods for modifying class behavior without inheritance. Use when extending core or third-party module functionality.
magento-performance
Optimize Magento 2 performance — full page cache (Varnish), Redis, indexer tuning, JavaScript/CSS optimization, database optimization, and profiling. Use when diagnosing slow pages, optimizing load times, or configuring caching.
magento-frontend
Build Magento 2 frontend — layout XML, blocks, PHTML templates, ViewModels, themes, JavaScript (RequireJS/KnockoutJS), and LESS/CSS. Use when customizing the storefront, building themes, or working with frontend components.
magento-events-cron
Implement Magento 2 events, observers, cron jobs, and message queues. Use when building event-driven logic, scheduled tasks, or asynchronous processing.
magento-eav-attributes
Work with Magento 2 EAV (Entity-Attribute-Value) system — create custom attributes, attribute sets, manage EAV tables, and understand the EAV data model. Use when adding product/category/customer attributes or working with the attribute system.
magento-di
Configure Magento 2 dependency injection — di.xml, types, virtual types, preferences, argument replacement, and Object Manager. Use when wiring dependencies, creating class variations, or configuring module integrations.
magento-deploy
Deploy Magento 2 — deployment modes, static content deployment, DI compilation, CLI commands, zero-downtime strategies, and CI/CD pipeline setup. Use when preparing for production deployment or building deployment automation.