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.
Best use case
magento-frontend is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using magento-frontend 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-frontend/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How magento-frontend Compares
| Feature / Agent | magento-frontend | 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?
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.
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 Frontend Development
## Before writing code
**Fetch live docs**:
1. Web-search `site:developer.adobe.com commerce frontend-core` for frontend development guide
2. Fetch `https://developer.adobe.com/commerce/frontend-core/guide/css/preprocess` for CSS/LESS docs
3. Web-search `site:developer.adobe.com commerce frontend-core guide layouts` for layout XML reference
4. Web-search `site:developer.adobe.com commerce frontend-core guide templates` for template guide
## Layout XML
### How Layouts Work
Layout files map to route handles and define the page structure:
- **Containers** — structural wrappers (header, content, footer)
- **Blocks** — content-rendering units tied to PHP classes and templates
- Handle naming: `<route>_<controller>_<action>.xml` (e.g., `catalog_product_view.xml`)
- `default.xml` — applies to all pages
### Key Layout Instructions
- `<referenceContainer>` — modify an existing container
- `<referenceBlock>` — modify an existing block
- `<block>` — add a new block with class, template, name
- `<move>` — relocate a block/container
- `<referenceBlock name="block_name" remove="true"/>` — remove a block (or use `<referenceContainer>` for containers). Note: there is no standalone `<remove>` element for blocks; the `remove="true"` attribute is set on `<referenceBlock>` or `<referenceContainer>`.
- `<update>` — include another layout handle
- `<arguments>` — pass data to blocks
### Layout Files Location
- Module: `view/frontend/layout/` or `view/adminhtml/layout/`
- Theme: `Magento_Module/layout/`
## Blocks and Templates
### Block Classes
- Extend `Magento\Framework\View\Element\Template`
- Contain data logic that templates consume
- `$block->someMethod()` in PHTML templates
### PHTML Templates
- Located in `view/frontend/templates/` or theme overrides
- PHP + HTML files with `.phtml` extension
- Access block: `$block`, escape output: `$escaper->escapeHtml()`
### ViewModels (Recommended)
MVVM pattern — inject ViewModels into blocks via layout XML arguments:
- ViewModels implement `Magento\Framework\View\Element\Block\ArgumentInterface`
- Keeps blocks thin; ViewModels carry the logic
- Access in template: `$viewModel = $block->getData('view_model');`
## JavaScript
### RequireJS
- AMD module system — all JS loaded as modules
- `requirejs-config.js` — maps module aliases, mixins, shims
- Located in `view/frontend/web/` or `view/frontend/requirejs-config.js`
### KnockoutJS
- Two-way data binding for dynamic UI
- Used extensively in checkout and UI components
- Custom bindings via `ko.bindingHandlers`
- HTML templates in `view/frontend/web/template/` (`.html` files)
### JS Mixins
Extend existing JS modules without overriding:
- Declared in `requirejs-config.js` under `config.mixins`
- Wrapper function receives original module and modifies it
### jQuery Widgets
Custom widgets extend `$.widget`:
- Initialized via `data-mage-init` attribute or `<script type="text/x-magento-init">`
- Configuration passed as JSON
## Themes
### Theme Structure
```
app/design/frontend/VendorName/theme-name/
├── etc/view.xml # Image sizes, responsive breakpoints
├── registration.php # Theme registration
├── theme.xml # Theme name, parent
├── composer.json
├── Magento_Module/ # Module overrides
│ ├── layout/ # Layout XML overrides
│ └── templates/ # Template overrides
├── web/
│ ├── css/source/ # LESS source files
│ ├── images/
│ └── js/
└── media/preview.jpg
```
### Theme Inheritance
Themes declare a parent in `theme.xml`. Fallback chain: current theme → parent theme → module views → framework. Override files by placing them in the same relative path.
### Hyva Themes (Modern Alternative)
Open source since late 2025. Replaces KnockoutJS + RequireJS + jQuery with **Alpine.js + Tailwind CSS**. Dramatically faster: ~5 requests vs ~230, ~0.4MB vs ~3MB page weight.
## LESS/CSS
- Default preprocessor: LESS
- `@magento_import` directive for theme fallback
- Variables in `_variables.less`, overridden per theme
- Server-side compilation for production, client-side for development
## Best Practices
- Use ViewModels instead of heavy block classes
- Override templates at the theme level, not module level (for customization)
- Use layout XML to add/move/remove blocks — avoid direct template editing of core
- Minimize JavaScript — prefer server-rendered HTML where possible
- Use `$escaper->escapeHtml()`, `escapeUrl()`, `escapeJs()` for XSS prevention
- Consider Hyva for new projects — dramatically better performance
Fetch the frontend development guide for exact layout XML schema, template escaping methods, and RequireJS configuration patterns before implementing.Related Skills
woo-frontend
Customize WooCommerce frontend — template overrides, theme integration, shortcodes, hooks for product/cart/checkout display, and WooCommerce block themes. Use when modifying the storefront appearance or building WooCommerce themes.
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-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.
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.