magento-module-development

Build custom Magento 2 modules with dependency injection, plugins, observers, and service contracts.

14|3|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/tomtoto757/ecomm-ai-skills-hub --skill magento-module-development-tomtoto757
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: magento-module-development
Source: https://github.com/tomtoto757/ecomm-ai-skills-hub/tree/main/skills/platform-integrations-infrastructure/finsilabs/platform-magento/magento-module-development
Command: npx skills add https://github.com/tomtoto757/ecomm-ai-skills-hub --skill magento-module-development-tomtoto757

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Magento developers avoid fragile, hard-to-maintain customizations by providing a repeatable, standards-aligned approach to build Magento 2 modules that extend core behavior safely using dependency injection, plugins, observers, and service contracts.

Core Features & Use Cases

  • Module skeleton & registration: Create a correctly structured app/code/Vendor/Module scaffold with registration.php and module.xml.
  • Service contracts & DI: Define Api/ interfaces and bind implementations via di.xml so other modules and APIs can depend on stable interfaces.
  • Plugins and observers: Use before/after plugins and event observers (with safe error handling) to modify runtime behavior without class rewrites.
  • Declarative schema & APIs: Add db_schema.xml for idempotent database changes and expose functionality via webapi.xml (REST) or GraphQL endpoints.
  • Use Case: Implement a custom entity with a repository, expose list and get endpoints for a headless storefront, and ensure upgrades require no manual SQL.

Quick Start

Create a new module scaffold under app/code/Acme/CustomModule, add Api interfaces and models, wire DI preferences in etc/di.xml, define the table in etc/db_schema.xml, and expose REST routes in etc/webapi.xml.

Frequently Asked Questions about magento-module-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a custom Magento 2 module that extends core functionality safely?

To create a Magento 2 module, you build a structured scaffold under app/code/Vendor/Module, define registration.php and module.xml, and use dependency injection, plugins, and observers to modify core behavior without class rewrites. This approach ensures upgrades require no manual SQL and maintains stable interfaces.

What is the best way to modify Magento 2 runtime behavior without class rewrites?

The best way to modify Magento 2 runtime behavior without class rewrites is using before/after plugins and event observers. This standards-aligned method safely alters core functionality via dependency injection while ensuring other modules can depend on stable Api interfaces.

How do I define idempotent database changes in a Magento 2 module?

You define idempotent database changes in a Magento 2 module by adding a declarative db_schema.xml file. This declarative schema approach ensures that database table modifications are applied consistently and upgrades require no manual SQL interventions.

Can I expose custom REST and GraphQL endpoints in a Magento 2 module?

Yes, you can expose custom REST and GraphQL endpoints in a Magento 2 module. You define Api interfaces and bind implementations via di.xml preferences, then expose functionality by defining routes in etc/webapi.xml for a headless storefront integration.

What deployment steps are required when implementing a Magento 2 module?

Required deployment steps for a Magento 2 module include dependency injection compilation and generating the declarative db-declaration whitelist. These steps ensure the module's service contracts, plugins, and db_schema.xml changes are properly registered and executed.

Why should I use service contracts and dependency injection in Magento 2 development?

You should use service contracts and dependency injection in Magento 2 development to avoid fragile customizations. Defining Api interfaces and binding implementations via di.xml ensures other modules and APIs can depend on stable interfaces for maintainable extensions.