# Craft php guidelines

> Craft php guidelines is an open-source agent skill for developer tools. Gives your agent Craft CMS 5 PHP coding standards for plugins and modules. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michtio/craftcms-claude-skills/tree/main/skills/craft-php-guidelines
- **Repository:** https://github.com/michtio/craftcms-claude-skills
- **GitHub stars:** 91
- **License:** MIT
- **Skill name:** craft-php-guidelines
- **Collection:** https://github.com/michtio/craftcms-claude-skills
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

This skill brings a set of house conventions for writing PHP in Craft CMS 5 plugins and modules. It covers PHPDoc blocks, section headers and class layout, naming for services, jobs, records and events, validation rules, date handling, environment variable access, and Craft::t copy rules. Reference files are split by topic, so the agent reads only the sections that match the current task.

Before editing, the skill runs a shell script to report the Craft version of the project, which the agent uses to choose version-specific advice. The guidance also includes a verification checklist covering ECS and PHPStan runs, test results and docblock completeness before a commit.

It expects a Craft CMS 5 codebase, PHP 8.2 or later, and DDEV for running the linting, static analysis and scaffolding commands it references. It is meant to complement the companion skills for Craft architecture and DDEV rather than replace them.

## When your agent uses it

> Craft CMS 5 PHP coding standards and conventions. ALWAYS load when writing, editing, reviewing, or discussing any PHP in a Craft plugin or module, even small edits, and when running ECS, PHPStan, or ddev craft make. Covers PHPDoc blocks (@author, @since, @throws chains), section headers (=========), class organization, naming (services, jobs, records, events, enums), defineRules(), beforePrepare() and addSelect(), MemoizableArray, DateTimeHelper vs Carbon, declare(strict_types=1), ?string nullables, early returns, CP Twig templates, form macros, Craft::t, ECS/PHPStan config, and the verification checklist.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs shell scripts](https://github.com/michtio/craftcms-claude-skills/tree/HEAD/skills/craft-php-guidelines)
- [Asks for: Bash(sh ${CLAUDE_SKILL_DIR}/scripts/craft-version.sh)](https://github.com/michtio/craftcms-claude-skills/blob/HEAD/skills/craft-php-guidelines/SKILL.md)
- [No network calls found in its scripts](https://github.com/michtio/craftcms-claude-skills/tree/HEAD/skills/craft-php-guidelines)
- [License: MIT](https://github.com/michtio/craftcms-claude-skills/tree/HEAD/skills/craft-php-guidelines)

## Features

- **PHPDoc and header standards:** Rules for docblocks, @author and @since placement, @throws chains and section separators.
- **Class and naming conventions:** Guidance on class ordering, visibility prefixes, and naming for services, records, jobs and events.
- **Dates and environment handling:** Covers DateTimeHelper versus Carbon, parsing database datetimes, and reading env variables with App helpers.
- **Authorization parity checks:** Advice on sharing one permission gate across control panel, console, GraphQL and queue surfaces.
- **Tooling and verification:** Instructions for ECS, PHPStan narrowing, scaffolding commands and a pre-commit checklist.

## Good for

- Review a Craft plugin controller for coding standard violations
- Write a new queue job or record class following Craft naming rules
- Set up ECS and PHPStan config for a Craft plugin repository
- Check that PHPDoc blocks and @throws chains are complete before a commit
- Replace getenv calls with App::env in plugin settings code

## Install

### Claude Code

This skill ships in the `craftcms-claude-skills` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add michtio/craftcms-claude-skills
/plugin install craftcms-claude-skills@craftcms-claude-skills
```

Or copy only this skill to `~/.claude/skills/craft-php-guidelines`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/craft-php-guidelines &&
cp -R "$tmp/skills/craft-php-guidelines" ~/.claude/skills/craft-php-guidelines &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/craft-php-guidelines` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/craft-php-guidelines` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/craft-php-guidelines &&
cp -R "$tmp/skills/craft-php-guidelines" ~/.agents/skills/craft-php-guidelines &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/craft-php-guidelines` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/craft-php-guidelines` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/craft-php-guidelines &&
cp -R "$tmp/skills/craft-php-guidelines" ~/.cursor/skills/craft-php-guidelines &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/craft-php-guidelines` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/michtio/craftcms-claude-skills.git --path skills/craft-php-guidelines
```

Or copy the folder to `~/.gemini/skills/craft-php-guidelines` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/craft-php-guidelines`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/craft-php-guidelines &&
cp -R "$tmp/skills/craft-php-guidelines" ~/.copilot/skills/craft-php-guidelines &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/craft-php-guidelines` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michtio/craftcms-claude-skills.git
```

Then copy `craftcms-claude-skills/skills/craft-php-guidelines` into your agent's skills folder as `craft-php-guidelines`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does Craft php guidelines apply to front-end Twig templates?

No. It states that front-end Twig is covered by a separate craft-twig-guidelines skill, and that template architecture and CP JavaScript belong to other skills.

### Which Craft version does Craft php guidelines target?

It targets Craft CMS 5 and requires PHP 8.2 or later, as stated in its standards section.

### Does Craft php guidelines need any tools installed?

It runs a shell script to detect the Craft version and references DDEV commands for ECS, PHPStan and scaffolding.

### Does Craft php guidelines allow strict_types declarations in plugin files?

No. It says declare(strict_types=1) is not used in plugin source files, only in standalone config files such as ecs.php.

### How do I install Craft php guidelines in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/craft-php-guidelines to use it in all your projects, or to .claude/skills/craft-php-guidelines in one project. Or install the craftcms-claude-skills plugin, which includes it: /plugin marketplace add michtio/craftcms-claude-skills, then /plugin install craftcms-claude-skills@craftcms-claude-skills.

### Does Craft php guidelines run scripts?

Yes. It runs shell scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Craft php guidelines?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Craft php guidelines?

The closest alternatives to Craft php guidelines are Craftcms, Craft twig guidelines, Code, Craft plugin release and Coding standards.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Craftcms](https://ai-powered.com/skills/craftcms): Craftcms is an open-source agent skill for developer tools.
- [Craft twig guidelines](https://ai-powered.com/skills/craft-twig-guidelines): Craft twig guidelines is an open-source agent skill for developer tools.
- [Code](https://ai-powered.com/skills/code): Code is an open-source agent skill for developer tools.
- [Craft plugin release](https://ai-powered.com/skills/craft-plugin-release): Craft plugin release is an open-source agent skill for developer tools.
- [Coding standards](https://ai-powered.com/skills/coding-standards-fmarzochi): Coding standards is an open-source agent skill for developer tools.
- [Coding standards](https://ai-powered.com/skills/coding-standards-abdullayevtemurmalik): Coding standards is an open-source agent skill for developer tools.
- [Cpp coding standards](https://ai-powered.com/skills/cpp-coding-standards-abdullayevtemurmalik): Cpp coding standards is an open-source agent skill for developer tools.
- [Craft plugins](https://ai-powered.com/skills/craft-plugins): Craft plugins is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/craft-php-guidelines
