Skip to main content
skill CX Codex

magento-model-developer — Claude Code skill: how to install

magento-model-developer generates Magento 2 data layer architecture, covering entity models, repositories, collections, and declarative schemas.

MIT 210 installs ★ 33 updated 2026-01-24

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add maxnorm/magento2-agent-skills --skill magento-model-developer -a claude-code
Open on GitHub

What magento-model-developer does

This skill guides coding assistants through Magento 2 data persistence patterns. It provides standard templates for entity classes derived from AbstractModel, resource layers using AbstractDb, and collections configured with primary resource bindings.

The instructions enforce service contracts with typed repository implementations and proper exception handling. The skill also provides declarative XML structures for db_schema.xml, defining InnoDB tables with primary constraints and btree indexes.

Architectural decisions follow Magento core conventions: flat storage serves high-performance transactional data, while EAV covers entities with dynamic attributes. Generated PHP files use strict typing.

What it helps with

  • generate entity models, resource models, and collection classes
  • scaffold declarative database schemas in db_schema.xml
  • build service contract repositories with typed exceptions
  • configure indexes and primary keys for custom module tables

Example prompts for the agent

  • Create an entity model with its matching resource model and collection.
  • Scaffold a repository implementing our module entity interface.
  • Generate a db_schema.xml file with an index and auto-increment primary key.

How to install magento-model-developer

1Skills CLI (Vercel)

npx skills add maxnorm/magento2-agent-skills --skill magento-model-developer -a claude-code

2Manually: put the files in place

~/.claude/skills/magento-model-developer/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/magento-model-developer/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about magento-model-developer

How to install magento-model-developer in Claude Code?

Run npx skills add maxnorm/magento2-agent-skills --skill magento-model-developer -a claude-code in your terminal.

What does magento-model-developer do?

It provides templates and guidelines for developing Magento 2 models, collections, repositories, and declarative database schemas.

When does the skill suggest using flat tables over EAV?

Flat tables are recommended for records with fixed attributes and simpler queries, such as orders or basic custom entities.

Source text

SKILL.md · MIT
---
name: magento-model-developer
description: Designs and implements data layer architecture for Magento 2. Use when creating data models, designing database schemas, implementing repositories, or working with EAV/flat table structures. Masters entity design, repository patterns, collections, and database optimization.
---

# Magento 2 Model Developer

Expert specialist in designing and implementing robust data layer architectures, creating efficient, scalable data models that serve as the foundation for enterprise e-commerce applications.

## When to Use

- Creating data models and entities
- Designing database schemas
- Implementing repository patterns
- Working with EAV or flat table structures
- Optimizing database queries
- Building data collections

## Data Architecture

- **Model Design**: Create efficient entity models following Magento patterns
- **EAV vs Flat Tables**: Choose optimal data storage strategies for different scenarios
- **Repository Pattern**: Implement clean data access layers and service contracts
- **Collection Optimization**: Build high-performance data collections and queries
- **Database Schema Design**: Design normalized, efficient database structures

## Model Development Process

### 1. Data Requirements Analysis
- **Business Requirements**: Understand entity relationships and business rules
- **Performance Requirements**: Plan for expected data volume and query patterns
- **Storage Strategy**: Choose between EAV and flat table storage approaches
- **Relationship Mapping**: Design entity relationships and dependencies
- **Scalability Planning**: Plan for future growth and data expansion

### 2. Database Schema Design
- **Table Structure**: Design efficient table structures and relationships
- **Data Types**: Choose appropriate data types for optimal storage and performance
- **Indexing Strategy**: Plan indexes for search, sorting, and filtering operations
- **Constraints**: Implement proper database constraints and validation
- **Migration Scripts**: Create database migration and upgrade scripts

### 3. Model Implementation
- **Entity Classes**: Implement model classes with proper validation and logic
- **Resource Models**: Create efficient database interaction layers
- **Collection Development**: Build optimized collection classes with filtering
- **Repository Implementation**: Create repository classes following service contracts
- **Factory Classes**: Implement proper object factories and builders

### 4. Integration & Testing
- **API Integration**: Integrate models with REST and GraphQL APIs
- **Cache Integration**: Implement proper caching strategies for model data
- **Performance Testing**: Validate model performance under expected load
- **Data Validation**: Test data integrity and validation rules
- **Migration Testing**: Test database migrations and data consistency

## Model Types

### Entity Model
```php
<?php

declare(strict_types=1);

namespace Vendor\Module\Model;

use Magento\Framework\Model\AbstractModel;
use Vendor\Module\Model\ResourceModel\Entity as ResourceModel;

class Entity extends AbstractModel
{
    protected function _construct(): void
    {
        $this->_init(ResourceModel::class);
    }
}
```

### Resource Model
```php
<?php

declare(strict_types=1);

namespace Vendor\Module\Model\ResourceModel;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class Entity extends AbstractDb
{
    protected function _construct(): void
    {
        $this->_init('vendor_module_entity', 'entity_id');
    }
}
```

### Collection
```php
<?php

declare(strict_types=1);

namespace Vendor\Module\Model\ResourceModel\Entity;

use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Vendor\Module\Model\Entity;
use Vendor\Module\Model\ResourceModel\Entity as ResourceModel;

class Collection extends AbstractCollection
{
    protected function _construct(): void
    {
        $this->_init(Entity::class, ResourceModel::class);
    }
}
```

### Repository Implementation
```php
<?php

declare(strict_types=1);

namespace Vendor\Module\Model;

use Vendor\Module\Api\Data\EntityInterface;
use Vendor\Module\Api\EntityRepositoryInterface;
use Vendor\Module\Model\ResourceModel\Entity as ResourceModel;
use Magento\Framework\Exception\NoSuchEntityException;

class EntityRepository implements EntityRepositoryInterface
{
    /**
     * @param ResourceModel $resource
     */
    public function __construct(
        private readonly ResourceModel $resource
    ) {
    }

    /**
     * @param int $id
     * @return EntityInterface
     * @throws NoSuchEntityException
     */
    public function getById(int $id): EntityInterface
    {
        $entity = $this->resource->load($id);
        if (!$entity->getId()) {
            throw new NoSuchEntityException(__('Entity with id "%1" does not exist.', $id));
        }
        return $entity;
    }
}
```

## Database Schema (db_schema.xml)

```xml
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="vendor_module_entity" resource="default" engine="innodb" comment="Entity Table">
        <column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
        <column xsi:type="varchar" name="name" length="255" nullable="false" comment="Name"/>
        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="entity_id"/>
        </constraint>
        <index referenceId="VENDOR_MODULE_ENTITY_NAME" indexType="btree">
            <column name="name"/>
        </index>
    </table>
</schema>
```

## EAV vs Flat Tables

### EAV (Entity-Attribute-Value)
- Use for entities with many optional attributes
- Flexible attribute management
- Higher query complexity
- Use for products, customers, categories

### Flat Tables
- Use for entities with fixed attributes
- Better query performance
- Simpler data model
- Use for orders, quotes, simple entities

## Best Practices

### Performance
- **Query Optimization**: Optimize database queries and eliminate N+1 problems
- **Index Strategy**: Design efficient database indexing
- **Collection Optimization**: Use proper filters and pagination
- **Lazy Loading**: Implement lazy loading for expensive operations
- **Caching**: Cache frequently accessed data

### Data Integrity
- **Validation**: Implement comprehensive data validation
- **Constraints**: Use database constraints where appropriate
- **Transactions**: Use transactions for multi-step operations
- **Referential Integrity**: Maintain proper foreign key relationships
- **Data Consistency**: Ensure data consistency across operations

### Code Quality
- **Service Contracts**: Use interfaces for repositories
- **Type Hints**: Use proper type hints throughout
- **Error Handling**: Comprehensive error handling
- **Documentation**: Document data models and relationships
- **Testing**: Write tests for models and repositories

## References

- [Adobe Commerce Models](https://developer.adobe.com/commerce/php/development/components/model/)
- [Repository Pattern](https://developer.adobe.com/commerce/php/development/components/repository-pattern/)
- [Database Schema](https://developer.adobe.com/commerce/php/development/components/declarative-schema/)

Focus on creating efficient, scalable data models that serve as a solid foundation for enterprise applications.

© maxnorm · MIT · maxnorm/magento2-agent-skills

Similar skills

All skills for Backend and APIs →

From the same set30

The whole set →
magento-issue-debugger magento-issue-debugger takes a Magento 2 failure apart step by step: reproduce it, pull the logs, isolate the cause. Handy when a production bug keeps shifting. CX Codex +1 274installs magento-php-specialist magento-php-specialist — a skill enforcing PSR-12 and Magento 2 standards for PHP development. Guides your agent to write typed code using framework patterns and strict checks. CX Codex +1 263installs magento-api-developer magento-api-developer teaches the agent to design and write Magento 2 REST and GraphQL APIs: service contracts, DTOs, auth and tests. CX Codex +1 259installs magento-security-analyst magento-security-analyst runs a security review of a Magento 2 store and helps close what it finds: code and config checks, dependency scan, PCI DSS and GDPR prep. CX Codex +1 212installs magento-feature-developer magento-feature-developer is a Claude Code skill for planning Magento 2 business features, including modules, integrations, service contracts, and tests. It supports adding custom behavior or extending an existing store. CX Codex +1 207installs magento-ui-component-developer The magento-ui-component-developer skill builds Magento UI Component grids, forms, modals, and data-driven interfaces. Use it when an admin or frontend component needs structured configuration. CX Codex +1 200installs magento-catalog-specialist magento-catalog-specialist guides your coding agent in inspecting Magento 2 product catalogs, indexer states, category hierarchies, and inventory levels. CX Codex +1 200installs magento-configuration-specialist magento-configuration-specialist reads Magento 2 system configuration across default, website and store scopes, pulls setting values and checks payment, shipping and tax options. CX Codex +1 190installs

Project sponsors

Companies that keep this analytics open