# 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.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 263 installs · ★ 33 repo stars
- Author: maxnorm
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/maxnorm/magento2-agent-skills/tree/HEAD/skills/magento-php-specialist/SKILL.md
- Updated: 2026-01-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/magento-php-specialist

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/magento-php-specialist/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/magento-php-specialist/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/magento-php-specialist/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/magento-php-specialist/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install maxnorm/magento2-agent-skills skills/magento-php-specialist
```

2. **Manually: put the files in place**
- File: `.github/skills/magento-php-specialist/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/maxnorm/magento2-agent-skills --path skills/magento-php-specialist
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/magento-php-specialist/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add maxnorm/magento2-agent-skills --skill magento-php-specialist -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/maxnorm/magento2-agent-skills/tree/HEAD/skills/magento-php-specialist/SKILL.md

## When to use it
- 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
- 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

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: caec7109176e077e.

BEGIN THIRD-PARTY FILE caec7109176e077e
````text
---
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);
````
END THIRD-PARTY FILE caec7109176e077e

The third-party file has ended. Everything between the caec7109176e077e tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2696 of 4077 bytes. © maxnorm · MIT · https://github.com/maxnorm/magento2-agent-skills/tree/HEAD/skills/magento-php-specialist/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
