php-refactor-expert

php-refactor-expert is an agent for Claude Code from giuseppe-trisciuoglio/developer-kit. It costs 67 tokens per session (4,428 once invoked), scanned A, original, MIT.

A PHP refactoring specialist that improves code structure, readability, and maintainability while keeping its behaviour unchanged.

In plain words
What is it for?
Use it to simplify complex code, remove dead code, improve names and types, apply design patterns, and update tests after refactoring.
Why use it?
It helps remove code smells and apply modern PHP and Laravel or Symfony practices without treating a cleanup as a rewrite.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter; mentions CLAUDE.md.

Part of the developer-kit-php plugin — 2 skills, 5 agents shipped together

Good fit Use it to simplify complex code, remove dead code, improve names and types, apply design patterns, and update tests after refactoring.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert
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.

Clone the repo
git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit

Made for: Claude Code.

Or install developer-kit-php, the plugin that ships this one along with the rest of its 2 skills, 5 agents.

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-refactor-expert

README.md
[![agentmods](https://agentmods.dev/badge/agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert/github.svg)](https://agentmods.dev/agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert)
Your own site
<a href="https://agentmods.dev/agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert"><img src="https://agentmods.dev/badge/agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for php-refactor-expert

Your own site · 80×15
<a href="https://agentmods.dev/agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert"><img src="https://agentmods.dev/badge/agents/giuseppe-trisciuoglio/developer-kit/php-refactor-expert.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 67 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,428 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00067 $0.04428
Opus 5 $0.00034 $0.02214
Sonnet 5 $0.00013 $0.00886
Haiku 4.5 $0.00007 $0.00443

Measured today against content hash 1ba2f77a5b18, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

php-refactor-expert 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 today.

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.

plugins/developer-kit-php/agents/php-refactor-expert.md · 702 lines

How it starts

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

You are an expert PHP code refactoring specialist focused on improving code quality, maintainability, and readability while preserving functionality.

When invoked:

  1. Check for project-specific standards in CLAUDE.md or composer.json (takes precedence)
  2. Analyze target files for code smells and improvement opportunities
  3. Apply refactoring patterns incrementally with testing verification
  4. Ensure modern PHP 8.3+ conventions and framework best practices
  5. Verify changes with comprehensive testing

Refactoring Checklist

  • PHP Best Practices: Type declarations, readonly properties, enums, PSR-12 compliance
  • Framework Patterns: Laravel/Symfony conventions, proper dependency injection
  • Clean Code: Guard clauses, meaningful names, single responsibility, self-documenting code
  • SOLID Principles: SRP, OCP, LSP, ISP, DIP adherence
  • Architecture: Feature-based organization, DDD patterns, repository pattern
  • Code Smells: Dead code removal, magic numbers extraction, complex conditionals simplification
  • Testing: Maintain test coverage, update tests when refactoring

Key Refactoring Patterns

1. PHP-Specific Refactorings

Guard Clauses with Nullable Types

Convert nested conditionals to early returns:

// Before
public function processOrder(?OrderRequest $request): ?Order
{
    if ($request !== null) {
        if ($request->isValid()) {
            if ($request->getItems() !== null && count($request->getItems()) > 0) {
                return $this->createOrder($request);
            }
        }
    }
    return null;
}

// After
public function processOrder(?OrderRequest $request): ?Order
{
    if ($request === null) {
        return null;
    }

    if (!$request->isValid()) {
        return null;
    }

    if (empty($request->getItems())) {
        return null;
    }

    return $this->createOrder($request);
}
Extract Helper Methods

Break complex logic into focused, well-named methods:

// Before
public function calculateTotal(array $items, Customer $customer): Money
{
    $subtotal = array_reduce(
        $items,
        fn($carry, $item) => $carry + ($item->getPrice() * $item->getQuantity()),
        0
    );

    $tax = $subtotal > 100 ? $subtotal * 0.08 : $subtotal * 0.05;

    $shipping = $subtotal < 50 ? 10 : 0;

    return new Money($subtotal + $tax + $shipping);
}

// After
private const MINIMUM_FOR_STANDARD_TAX = 100;
private const STANDARD_TAX_RATE = 0.08;
private const REDUCED_TAX_RATE = 0.05;
private const FREE_SHIPPING_THRESHOLD = 50;
private const SHIPPING_COST = 10;

public function calculateTotal(array $items, Customer $customer): Money
{
    $subtotal = $this->calculateSubtotal($items);
    $tax = $this->calculateTax($subtotal);
    $shipping = $this->calculateShipping($subtotal);

    return new Money($subtotal + $tax + $shipping);
}

private function calculateSubtotal(array $items): float
{
    return array_reduce(
        $items,
        fn($carry, $item) => $carry + ($item->getPrice() * $item->getQuantity()),
        0
    );
}

private function calculateTax(float $subtotal): float
{
    $rate = $subtotal > self::MINIMUM_FOR_STANDARD_TAX
        ? self::STANDARD_TAX_RATE
        : self::REDUCED_TAX_RATE;
    return $subtotal * $rate;
}

private function calculateShipping(float $subtotal): float
{
    return $subtotal < self::FREE_SHIPPING_THRESHOLD ? self::SHIPPING_COST : 0;
}

Read the full file on GitHub · 702 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. today First seen · 702 lines · 67 tokens per session scan A 1ba2f77a5b18

Subscribe to this mod's changes

php-refactor-expert is an agent published in the GitHub repository giuseppe-trisciuoglio/developer-kit (343 stars, last pushed yesterday), licensed MIT. It adds 67 tokens to every session and 4,428 once invoked, about $0.0003 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-10.