wp-cleanup

A command for finding unused or duplicated PHP code and Composer packages in WordPress projects. Composer is a tool that manages PHP packages, while dead code is code that the project no longer uses.

In plain words
What is it for?
Use it to scan a project, review or apply cleanup, check Composer dependencies, remove unused imports, inspect dead classes and functions, or set up the cleanup tools.
Why use it?
It helps identify code and dependencies that add maintenance work without serving the project, while accounting for WordPress-specific hooks that can make code appear unused.

Command

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 commands/iwritec0de/wp-dev/wp-cleanup
Clone the repo
git clone --depth 1 https://github.com/iwritec0de/wp-dev
Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,464 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 $0.00020 $0.03464
Opus 5 $0.00010 $0.01732
Sonnet 5 $0.00004 $0.00693
Haiku 4.5 $0.00002 $0.00346

Measured yesterday against content hash 3c779717e08e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

wp-cleanup 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 yesterday.

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.

commands/wp-cleanup.md · 395 lines

How it starts

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

/wp-cleanup

Find and remove unused code, dependencies, imports, and dead code in PHP/WordPress projects.

Load the php-cleanup skill for tool configuration, WordPress hook-aware false positive handling, and safe removal workflows.

Usage

/wp-cleanup [scan|fix|deps|imports|unused-code|config|init]

Arguments

Parse $ARGUMENTS to extract the subcommand:

  • scan (default) — Full audit across all tools with consolidated report
  • fix — Interactive guided cleanup in safe order
  • deps — Focus on unused and missing Composer dependencies
  • imports — Focus on unused use statements with auto-fix
  • unused-code — Focus on dead classes, methods, functions, and properties via Psalm
  • config — Show current tool configurations and readiness status
  • init — Set up the full cleanup toolchain for the project

Instructions

Pre-flight Check

Before any subcommand:

  1. Verify this is a PHP project (composer.json exists).
  2. Check if it's a WordPress project (look for WordPress indicators: plugin headers in main PHP file, wp- prefixed directories, add_action/add_filter usage, style.css with Theme Name: header).
  3. Check which tools are installed:
    composer show icanhazstring/composer-unused 2>/dev/null && echo "composer-unused: installed"
    composer show maglnet/composer-require-checker 2>/dev/null && echo "require-checker: installed"
    composer show vimeo/psalm 2>/dev/null && echo "psalm: installed"
    composer show php-stubs/wordpress-stubs 2>/dev/null && echo "wp-stubs: installed"
    composer show friendsofphp/php-cs-fixer 2>/dev/null && echo "php-cs-fixer: installed"
    
  4. Report any missing tools and offer to install them before proceeding.

/wp-cleanup scan

Run all available tools and present a consolidated report:

  1. Unused dependencies (if composer-unused installed):

    composer unused --output-format=json 2>/dev/null
    
  2. Missing dependencies (if composer-require-checker installed):

    vendor/bin/composer-require-checker check --output=json 2>/dev/null
    

Read the full file on GitHub · 395 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. yesterday First seen · 395 lines · 20 tokens per session scan A 3c779717e08e

Subscribe to this mod's changes

wp-cleanup is a command published in the GitHub repository iwritec0de/wp-dev (1 stars, last pushed 4mo ago), licensed MIT. It adds 20 tokens to every session and 3,464 once invoked, about $0.0001 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-08-31.