Enforces PHP 8.x modern patterns, PSR standards, and SOLID principles. Use for reviewing PHP code, checking type safety, and auditing code quality.
Ships in asyrafhussin-agent-skills-1. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Modern PHP 8.x patterns, PSR standards, type system best practices, and SOLID principles. Contains 51 rules for writing clean, maintainable PHP code.
Always check the project's PHP version before giving any advice. Features vary significantly across 8.0 - 8.5. Never suggest syntax that doesn't exist in the project's version.
Check composer.json for the required PHP version:
{ "require": { "php": "^8.1" } } // -> 8.1 rules and below
{ "require": { "php": "^8.3" } } // -> 8.3 rules and below
{ "require": { "php": ">=8.4" } } // -> 8.4 rules and below
Also check the runtime version:
php -v # e.g. PHP 8.3.12
| Feature | Version | Rule Prefix |
|---|---|---|
| Union types, match, nullsafe, named args, constructor promotion, attributes | 8.0+ | type-, modern- |
| Enums, readonly properties, intersection types, first-class callables, never, fibers | 8.1+ | modern- |
| Readonly classes, DNF types, true/false/null standalone types | 8.2+ | modern- |
Typed class constants, #[\Override], json_validate() | 8.3+ | modern- |
Property hooks, asymmetric visibility, #[\Deprecated], new without parens | 8.4+ | modern- |
| Pipe operator ` | >` | 8.5+ |
Only suggest features available in the detected version. If the user asks about upgrading or newer features, mention what becomes available at each version.
Reference these guidelines when:
| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Type System | CRITICAL | type- | 9 |
| 2 | Modern PHP Features | CRITICAL | modern- | 16 |
| 3 | PSR Standards | HIGH | psr- | 6 |
| 4 | SOLID Principles | HIGH | solid- | 5 |
| 5 | Error Handling | HIGH | error- | 5 |
| 6 | Performance | MEDIUM | perf- | 5 |
| 7 | Security | CRITICAL | sec- | 5 |
type-strict-mode - Declare strict types in every filetype-return-types - Always declare return typestype-parameter-types - Type all parameterstype-property-types - Type class propertiestype-union-types - Use union types effectivelytype-intersection-types - Use intersection typestype-nullable-types - Handle nullable types properlytype-void-never - Use void/never for appropriate return typestype-mixed-avoid - Avoid mixed type when possible8.0+:
modern-constructor-promotion - Constructor property promotionmodern-match-expression - Match over switchmodern-named-arguments - Named arguments for claritymodern-nullsafe-operator - Nullsafe operator (?->)modern-attributes - Attributes for metadata8.1+:
modern-enums - Enums instead of constantsmodern-enums-methods - Enums with methods and interfacesmodern-readonly-properties - Readonly for immutable datamodern-first-class-callables - First-class callable syntaxmodern-arrow-functions - Arrow functions (7.4+, pairs well with 8.1 features)8.2+:
modern-readonly-classes - Readonly classes8.3+:
modern-typed-constants - Typed class constants (const string NAME = 'foo')modern-override-attribute - #[\Override] to catch parent method typos8.4+:
modern-property-hooks - Property hooks replacing getters/settersmodern-asymmetric-visibility - public private(set) for controlled access8.5+:
modern-pipe-operator - Pipe operator (|>) for functional chainingpsr-4-autoloading - Follow PSR-4 autoloadingpsr-12-coding-style - Follow PSR-12 coding stylepsr-naming-classes - Class naming conventionspsr-naming-methods - Method naming conventionspsr-file-structure - One class per filepsr-namespace-usage - Proper namespace usagesolid-srp - Single Responsibility: one reason to changesolid-ocp - Open/Closed: extend, don't modifysolid-lsp - Liskov Substitution: subtypes must be substitutablesolid-isp - Interface Segregation: small, focused interfacessolid-dip - Dependency Inversion: depend on abstractionserror-custom-exceptions - Create specific exceptions for different errorserror-exception-hierarchy - Organize exceptions into meaningful hierarchyerror-try-catch-specific - Catch specific exceptions, not generic \Exceptionerror-finally-cleanup - Use finally for guaranteed resource cleanuperror-never-suppress - Never use @ error suppression operatorperf-avoid-globals - Avoid global variables, use dependency injectionperf-lazy-loading - Defer expensive operations until neededperf-array-functions - Use native array functions over manual loopsperf-string-functions - Use native string functions over regexperf-generators - Use generators for large datasetssec-input-validation - Validate and sanitize all external inputsec-output-escaping - Escape output based on context (HTML, JS, URL)sec-password-hashing - Use password_hash/verify, never MD5/SHA1sec-sql-prepared - Use prepared statements for all SQL queriessec-file-uploads - Validate file type, size, name; store outside web rootFor detailed examples and explanations, see the rule files:
<?php
declare(strict_types=1);
// 8.0+ Constructor promotion + readonly (8.1+)
class User
{
public function __construct(
public readonly string $id,
private string $email,
) {}
}
// 8.1+ Enums with methods
enum Status: string
{
case Active = 'active';
case Inactive = 'inactive';
public function label(): string
{
return match($this) {
self::Active => 'Active',
self::Inactive => 'Inactive',
};
}
}
// 8.0+ Match expression
$result = match($status) {
'pending' => 'Waiting',
'active' => 'Running',
default => 'Unknown',
};
// 8.0+ Nullsafe operator
$country = $user?->getAddress()?->getCountry();
// 8.3+ Typed class constants + #[\Override]
class PaymentService extends BaseService
{
public const string GATEWAY = 'stripe';
#[\Override]
public function process(): void { /* ... */ }
}
// 8.4+ Property hooks + asymmetric visibility
class Product
{
public string $name { set => trim($value); }
public private(set) float $price;
}
// 8.5+ Pipe operator
$result = $input
|> trim(...)
|> strtolower(...)
|> htmlspecialchars(...);
When auditing code, output findings in this format:
file:line - [category] Description of issue
Example:
src/Services/UserService.php:15 - [type] Missing return type declaration
src/Models/Order.php:42 - [modern] Use match expression instead of switch
src/Controllers/ApiController.php:28 - [solid] Class has multiple responsibilities
Read individual rule files for detailed explanations:
rules/modern-constructor-promotion.md
rules/type-strict-mode.md
rules/solid-srp.md
AGENTS.md (opens in a new tab)README.md (opens in a new tab)metadata.json (opens in a new tab)rules/_sections.md (opens in a new tab)rules/_template.md (opens in a new tab)rules/error-custom-exceptions.md (opens in a new tab)rules/error-exception-hierarchy.md (opens in a new tab)rules/error-finally-cleanup.md (opens in a new tab)rules/error-never-suppress.md (opens in a new tab)rules/error-try-catch-specific.md (opens in a new tab)rules/modern-arrow-functions.md (opens in a new tab)rules/modern-asymmetric-visibility.md (opens in a new tab)rules/modern-attributes.md (opens in a new tab)rules/modern-constructor-promotion.md (opens in a new tab)rules/modern-enums-methods.md (opens in a new tab)rules/modern-enums.md (opens in a new tab)rules/modern-first-class-callables.md (opens in a new tab)rules/modern-match-expression.md (opens in a new tab)rules/modern-named-arguments.md (opens in a new tab)rules/modern-nullsafe-operator.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
24 skills in this plugin
/api-design-patternsRESTful API design, error handling, versioning, and best practices. Use when designing APIs, reviewing endpoints, implementing error responses, or setting up API structure. Triggers on "design API", "review API", "REST best practices", or "API patterns"./clean-code-principlesSOLID principles, design patterns, DRY, KISS, and clean code fundamentals. Use when reviewing architecture, checking code quality, refactoring, or discussing design decisions. Triggers on "review architecture", "check code quality", "SOLID principles", "design patterns", or "clean code"./code-slopDetect AI-generated code patterns ("slop") in PHP/Laravel and TypeScript/React source — comment narration, generic naming, premature interfaces, defensive overdose, mock-everything tests, and the absence of human "scars". Use when reviewing AI-assisted PRs, auditing code for taste/quality (not metrics — that's technical-debt), or hardening a code-review checklist. Triggers on "review for AI slop", "find AI patterns", "check code feels human", "audit code-quality taste"./e2e-playwright-testingEnd-to-end testing with Playwright for web applications. Use when writing E2E tests, browser automation, form submission testing, or user flow testing. Triggers on "playwright", "e2e test", "browser test", "end-to-end", "form flow testing", or test files in tests/e2e/./git-workflowGit best practices, branching strategies, commit conventions, and PR workflows. Use when reviewing git history, writing commits, setting up branching strategy, or improving git practices. Triggers on "git best practices", "commit message", "branching strategy", or "PR workflow"./laravel-ai-sdkLaravel AI SDK for building AI-powered features. Use when creating agents, generating images or audio, working with embeddings, vector search, or testing AI features. Triggers on tasks involving laravel/ai, AI agents, tool-calling, structured output, streaming, embeddings, reranking, or AI faking in tests./asyrafhussin-agent-skills-1:php-best-practicesfrom asyrafhussin-agent-skills-1
asyrafhussin-agent-skills-1@cascade-code-languages-misc-1 is listed by joshuarweaver/cascade-code-languages-misc-1 — review the source before installing
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin asyrafhussin-agent-skills-1Other plugins' skills for the same job