php-rules

php-rules is a skill for Claude Code from softspark/ai-toolkit. It costs 38 tokens per session (3,510 once invoked), scanned A, original, Apache-2.0.

A set of PHP coding rules covering style, common patterns, security, and testing. PHP is a programming language commonly used for web backends, while Composer manages PHP packages.

In plain words
What is it for?
Use it when writing or reviewing PHP projects that use tools or frameworks such as Composer, Laravel, Symfony, or PHPUnit.
Why use it?
It gives PHP changes consistent conventions and points developers toward safer, testable code.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the ai-toolkit plugin — 114 skills, 44 agents, 14 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/softspark/ai-toolkit/php-rules
Any agent
npx skills add softspark/ai-toolkit --skill php-rules
Clone the repo
git clone --depth 1 https://github.com/softspark/ai-toolkit

Made for: Claude Code.

Or install ai-toolkit, the plugin that ships this one along with the rest of its 114 skills, 44 agents, 14 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for php-rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/softspark/ai-toolkit/php-rules.svg)](https://agentmods.dev/skills/softspark/ai-toolkit/php-rules)
Your own site
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/php-rules"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/php-rules.svg" alt="Measured on agentmods" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,510 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.03510
Opus 5 $0.00019 $0.01755
Sonnet 5 $0.00008 $0.00702
Haiku 4.5 $0.00004 $0.00351

Measured 2d ago against content hash 9458e9d79b4f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

php-rules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

app/skills/php-rules/SKILL.md · 293 lines

How it starts

The opening of the file, as written. The whole thing — 293 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PHP Rules

These rules come from app/rules/php/ in ai-toolkit. They cover the project's standards for coding style, frameworks, patterns, security, and testing in PHP. Apply them when writing or reviewing PHP code.

PHP Coding Style

Standards

  • Follow PSR-12 extended coding style.
  • Use declare(strict_types=1) at the top of every file.
  • Use PHP 8.1+ features: enums, fibers, readonly properties, intersection types.
  • Use PHP CS Fixer or Pint for automated formatting.

Naming

  • PascalCase: classes, interfaces, traits, enums.
  • camelCase: methods, functions, variables.
  • UPPER_SNAKE: class constants (public const MAX_RETRIES = 3).
  • snake_case: not used for methods. PSR convention is camelCase.
  • Suffix interfaces with Interface or prefix with contract name (project convention).

Type System

  • Use typed properties: private readonly string $name;.
  • Use union types: string|int. Use intersection types: Countable&Iterator.
  • Use enum (PHP 8.1) for fixed sets of values. Use backed enums for persistence.
  • Use readonly classes (PHP 8.2) for immutable DTOs.
  • Use constructor promotion: public function __construct(private string $name).
  • Use never return type for functions that throw or exit.

Functions

  • Use typed parameters and return types on all functions/methods.
  • Use named arguments for readability: new User(name: 'Ada', age: 36).
  • Use null-safe operator: $user?->address?->city.
  • Use match expression over switch for value mapping.
  • Use first-class callable syntax: array_map($this->transform(...), $items).

Imports and Namespaces

  • Use PSR-4 autoloading via Composer.
  • Group use statements: classes, functions, constants.
  • Never use require/include for class loading. Use Composer autoloader.
  • Use one class per file. File name matches class name.

Error Handling

  • Use exceptions for error conditions. Never return error codes.
  • Create domain exception hierarchies extending RuntimeException or LogicException.
  • Use match with throw for exhaustive error mapping.
  • Log exceptions with context using PSR-3 logger.

Read the full file on GitHub · 293 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 293 lines · 38 tokens per session scan A 9458e9d79b4f

Subscribe to this mod's changes

php-rules is a skill published in the GitHub repository softspark/ai-toolkit (169 stars, last pushed yesterday), licensed Apache-2.0. It adds 38 tokens to every session and 3,510 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

php

PHP development: code quality, PSR standards, testing with PHPUnit.

notque/vexjoy-agent · 16 tokens

laravel

Laravel mastery skill. Eloquent ORM, service container, queues, events, Sanctum/Passport auth, Pest testing. Triggers on: /godmode:laravel, "laravel app", "eloquent", "artisan", "blade".

arbazkhan971/godmode · 52 tokens

first-plan-lens-php

Stack lens para PHP. Use durante Discovery quando composer.json for detectado. Cobre Laravel, Symfony, Slim, Hyperf, Laminas, raw PHP. Identifica PSR compliance, ORM, padrões de fila.

vynazevedo/first-plan · 51 tokens

architecture-patterns

Use this skill when choosing a system-level architecture (monolith, modular monolith, microservices, event-driven, serverless, clean/hexagonal, or DDD) for a new or growing PHP application, or when weighing a premature move to a more distributed style. Provides a decision guide and the common pitfalls that cause…

garrettw/php-arch-skills · 77 tokens

application-layer

Use this skill when writing controllers, structuring use cases, or implementing Service Layer / Application Layer and Command/Query/Handler (CQRS) patterns in PHP applications. Triggers on questions about thin controllers, handler responsibilities, service definition, or DTO usage.

garrettw/php-arch-skills · 55 tokens

event-sourcing

Use this skill when evaluating or implementing Event Sourcing in a PHP application. Triggers on questions about event stores, aggregates, projections, snapshots, event replay, temporal queries, CQRS with event sourcing, or PHP event-sourcing libraries (Ecotone, Prooph, EventSauce, Patchlevel). Distinguishes Event…

garrettw/php-arch-skills · 86 tokens