Skip to main content
skill CX Codex

magento-php-specialist — Claude Code skill: install and overview

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.

MIT 263 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-php-specialist -a claude-code
Open on GitHub

What magento-php-specialist does

This skill directs the agent to generate PHP code matching PSR-12 and vendor/magento/magento-coding-standard/Magento2. It requires declare(strict_types=1); in every file, method opening braces on their own lines, and strict comparison operators such as ===.

The instructions incorporate modern PHP features: match expressions, union types, and constructor property promotion with readonly. Architecture requirements focus on single responsibility, composition, repository patterns, factories, and plugins. Logging must use \Psr\Log\LoggerInterface.

Code relying on service locators will fail these checks, as the skill strictly mandates constructor dependency injection.

What it helps with

  • write Magento 2 services with strict type coverage
  • implement repository patterns and service contracts under PSR-12
  • refactor switch statements into modern match expressions
  • structure dependency injection without service locators

Example prompts for the agent

  • Create a customer order service using constructor property promotion and strict types
  • Generate a Magento 2 repository class following PSR-12 formatting
  • Implement an around plugin for the product repository with full type hints

How to install magento-php-specialist

1Skills CLI (Vercel)

npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a claude-code

2Manually: put the files in place

~/.claude/skills/magento-php-specialist/SKILL.md

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

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

Questions about magento-php-specialist

How to install magento-php-specialist in Claude Code?

Run npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a claude-code. You can also store the file at ~/.claude/skills/magento-php-specialist/SKILL.md.

What does magento-php-specialist do?

It sets strict coding rules for Magento 2 PHP development, including complete type hinting, PSR-12 compliance, and official Magento design patterns.

What dependency injection approach does this skill enforce?

It requires constructor injection for all dependencies and explicitly forbids using service locators.

Source text

SKILL.md · MIT
---
name: magento-php-specialist
description: Advanced PHP development for Magento 2 following PSR-12 and Magento coding standards. Use when writing PHP code, implementing business logic, or ensuring code quality. Masters modern PHP features, object-oriented programming, design patterns, and Magento-specific PHP practices.
---

# Magento 2 PHP Specialist

Expert specialist in leveraging advanced PHP techniques and modern practices to create high-performance, maintainable Magento 2 applications following enterprise development standards.

## When to Use

- Writing PHP code for Magento 2
- Implementing business logic
- Ensuring code quality and standards
- Working with modern PHP features
- Implementing design patterns

## PHP Standards (STRICT ENFORCEMENT)

### PSR-12 Compliance
- **PSR-12**: Strictly adhere to PSR-12 coding standards
- **Magento2 Coding Standard**: Follow standards in `vendor/magento/magento-coding-standard/Magento2`
- **Strict Types**: `declare(strict_types=1);` required
- **EditorConfig**: Check project's `.editorconfig` for indentation (4 spaces), line endings (LF), encoding (UTF-8)

### Code Structure Requirements
- **Opening Braces**: Classes and methods must have opening braces on their own line (PSR-12)
- **Constructor Property Promotion**: Use with `readonly` modifier where appropriate
- **Type Hinting**: All parameters and return types must be type-hinted
- **Strict Comparisons**: Always use `===` and `!==` (never `==` or `!=`)
- **Constructor PHPDoc**: Must include `@param` annotation for each parameter

### Modern PHP Features
- **Constructor Property Promotion**: Use constructor property promotion
- **Readonly Properties**: Use `readonly` modifier where appropriate
- **Union Types**: Use union types for flexible type hints
- **Match Expressions**: Use match expressions instead of switch when appropriate
- **Named Arguments**: Use named arguments for clarity

### Code Example
```php
<?php

/**
 * Copyright © 2025 CompanyName. All rights reserved.
 */

declare(strict_types=1);

namespace CompanyName\ModuleName\Model;

use CompanyName\ModuleName\Api\ConfigInterface;
use CompanyName\ModuleName\Api\RepositoryInterface;

class Service
{
    /**
     * @param RepositoryInterface $repository
     * @param ConfigInterface $config
     */
    public function __construct(
        private readonly RepositoryInterface $repository,
        private readonly ConfigInterface $config
    ) {
    }

    /**
     * @param int $id
     * @return EntityInterface|null
     */
    public function getById(int $id): ?EntityInterface
    {
        if ($id <= 0) {
            return null;
        }

        return $this->repository->getById($id);
    }
}
```

## Best Practices

### Object-Oriented Programming
- **Composition Over Inheritance**: Prefer composition patterns
- **Dependency Injection**: Constructor injection only - avoid service locators
- **Single Responsibility**: One purpose per class/method
- **Interface Segregation**: Use small, focused interfaces
- **SOLID Principles**: Follow SOLID principles

### Code Quality
- **Type Safety**: 100% type coverage - parameters, return types, properties
- **Error Handling**: Comprehensive exception handling
- **Logging**: Use `\Psr\Log\LoggerInterface` for logging
- **Documentation**: Minimal PHPDoc with `@param`, `@return`, `@throws`
- **Testing**: Write unit tests for business logic

### Magento-Specific Patterns
- **Service Contracts**: Use service contracts for APIs
- **Repository Pattern**: Implement repository pattern for data access
- **Factory Pattern**: Use factories for object creation
- **Plugin Pattern**: Use plugins to extend functionality
- **Observer Pattern**: Use observers for event-driven architecture

## References

- [PSR-12 Coding Standard](https://www.php-fig.org/psr/psr-12/)
- [Adobe Commerce PHP Development](https://developer.adobe.com/commerce/php/development/)
- [Coding Standards](https://developer.adobe.com/commerce/php/coding-standards/)

Focus on writing clean, maintainable PHP code that follows Magento best practices.

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

Similar skills

All skills for Backend and APIs →

From the same set30

The whole set →
magento-performance-analyst magento-performance-analyst — a skill that walks the agent through Magento 2 profiling: finding bottlenecks, reading slow queries, planning optimizations. CX Codex +1 449installs magento-frontend-developer magento-frontend-developer guides Magento 2 frontend development across layout XML, PHTML templates, RequireJS, KnockoutJS, and Core Web Vitals optimization. CX Codex +1 420installs magento-xml-specialist magento-xml-specialist — a skill that teaches your coding agent to write and validate Magento 2 XML configs: layout, di.xml, system.xml, module.xml and db_schema.xml. CX Codex +1 394installs 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-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-model-developer magento-model-developer generates Magento 2 data layer architecture, covering entity models, repositories, collections, and declarative schemas. CX Codex +1 210installs 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

Project sponsors

Companies that keep this analytics open