Create Magento 2 Module
This utility skill creates new Magento 2 modules in app/code/. It is designed to be called by other skills that need module scaffolding.
Command execution: For commands that need to run inside the development environment (e.g., bin/magento), use the hyva-exec-shell-cmd skill to detect the environment and determine the appropriate command wrapper.
Parameters
When invoking this skill, the calling skill should provide:
Workflow
Step 1: Validate Input
- Verify vendor name is PascalCase (starts with uppercase, alphanumeric only)
- Verify module name is PascalCase
- Check that
app/code/{Vendor}/{Module}does not already exist
Step 2: Create Directory Structure
Step 3: Generate Files
registration.php
Use template assets/templates/registration.php.tpl:
- Replace
{{VENDOR}}with vendor name - Replace
{{MODULE}}with module name
composer.json
Use template assets/templates/composer.json.tpl:
- Replace
{{VENDOR}}with vendor name (PascalCase) - Replace
{{MODULE}}with module name (PascalCase) - Replace
{{vendor_kebabcase}}with kebab-case, hyphenated vendor name - Replace
{{module_kebabcase}}with kebab-case, hyphenated module name - Replace
{{DESCRIPTION}}with description - Add entries from
composer_requireparameter to therequiresection
module.xml
Use template assets/templates/module.xml.tpl:
- Replace
{{VENDOR}}with PascalCase vendor name - Replace
{{MODULE}}with PascalCase module name - Replace
{{SEQUENCE}}with<sequence>block containing dependencies, or empty string if none
Step 4: Run Setup (Optional)
If the calling skill requests it, run bin/magento setup:upgrade using the hyva-exec-shell-cmd skill for the appropriate wrapper.
Error Handling
Abort module creation and report the error to the calling skill when:
If hyva-exec-shell-cmd skill is unavailable when Step 4 is requested, skip the setup:upgrade step and report: "Skipped setup:upgrade - hyva-exec-shell-cmd skill not available. Run manually: bin/magento setup:upgrade"
Template Placeholders
PascalCase to kebab-case Conversion
Convert module names by inserting a hyphen before each capital letter and lowercasing:
Usage by Other Skills
Skills should reference this skill for module creation:
Example Output
For vendor Acme, module CmsComponents, with Hyva_CmsBase dependency:
app/code/Acme/CmsComponents/registration.php:
app/code/Acme/CmsComponents/composer.json:
app/code/Acme/CmsComponents/etc/module.xml:
<!-- Copyright © Hyvä Themes https://hyva.io. All rights reserved. Licensed under OSL 3.0 -->

