Magento module dev

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Magento module dev is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. 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.

How to use this skill

Skill file

Magento 2 Module Development

Before writing code

Fetch live docs:

  1. Fetch https://developer.adobe.com/commerce/php/development/ 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

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

CLI Command Pattern

Console commands extend Symfony\Component\Console\Command\Command:

Best Practices

Fetch the component file structure guide for exact directory conventions and required files before creating a module.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.