/wp-plugin-code-audit:wp-plugin-code-auditfrom wp-plugin-code-audit
Audits WordPress plugins for security, performance, coding standards, and WordPress.org guidelines compliance. Produces a markdown report with risk-sorted findings, fix recommendations, and a GO/NO-GO verdict.
Ships in wp-plugin-code-audit. 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; scripts run unread.
Opinionated, verification-first audit workflow for WordPress plugins. Produces a markdown report with findings sorted by risk, a fix recommendation per finding, owner-decision ([DECISION]) questions only the owner can answer, an optional reproduction step, and a final GO / NO-GO / GO WITH FIXES verdict. Covers security, performance, coding standards, WordPress.org guidelines, and cross-plugin integration.
Scope: WordPress plugins — local checkout (directory path), targeted file / function, or remote (wp.org slug, GitHub URL). Not themes. Not bulk repo sweeps — one plugin at a time.
Verification discipline: every finding written to the report must be verified against source. Pattern matchers and subagents over-flag SQLi, missing nonces, and missing escapes. See
references/false-positive-traps.mdbefore reporting any of those categories.
If the goal is "is this safe / good enough / mergeable", this is the right reference.
AUDIT-<yyyy-mm-dd>.md to a non-public location with severity-sorted findings, fix per finding, verdict.Skipping phase 4 is how false positives ship and erode trust. Don't. Phase 5 is the one optional phase — it confirms a finding is real, but never replaces the source tracing in phase 4 that explains why.
Before reading code, scope the plugin. Write the scope inline at the top of the report — sets reader expectations.
Ask up front: is this plugin the system of record for the data it writes, or a view over someone else's? A plugin owns the authoritative copy of something (stock levels, entitlements, expiry dates, booking capacity, invoice numbers, backup archives, anything doing two-way sync) versus merely displaying or caching data whose source of truth lives elsewhere. Corrupting the system of record is a different class of problem from rendering it wrongly — the authoritative value is gone, not just shown wrong — and it changes how the Severity Rubric's silent-corruption rule applies. It's usually answerable in the first ten minutes; record the answer in the Scope section.
# Plugin entry, version, requires
head -40 plugin-name.php
grep -RhE "^\s*\*?\s*(Plugin Name|Version|Requires at least|Requires PHP|License|Text Domain|Update URI):" --include="*.php" .
# Surface area
find . -type f -name "*.php" -not -path "*/vendor/*" -not -path "*/node_modules/*" | wc -l
find . -name "block.json"
grep -RlE "register_rest_route" --include="*.php" .
grep -RlE "add_action\(\s*['\"]wp_ajax_" --include="*.php" .
grep -RlE "(WP_CLI::add_command|add_command\()" --include="*.php" .
grep -RlE "register_(activation|deactivation|uninstall)_hook" --include="*.php" .
grep -RlE "(add_menu_page|add_options_page|add_submenu_page)" --include="*.php" .
# Dependencies
test -f composer.json && jq '.require, .["require-dev"]' composer.json
test -f package.json && jq '.dependencies, .devDependencies' package.json
# Source vs build artifacts
test -d vendor && echo "vendor/ shipped (audit included)"
test -d dist && echo "dist/ shipped (likely build output — audit source if available)"
Distribution shape affects severity weighting and the remediation path. Record in the report's Scope section:
| Question | How to determine |
|---|---|
| Distribution: wp.org / GitHub / private / commercial marketplace | Check plugin header Update URI, presence of readme.txt, GitHub remote, vendor name; ask the user if unclear. |
| Update mechanism: wp.org auto-updates / GitHub Updater / private updater / manual upload | wp.org slug → wp.org updates; Update URI set → custom updater; neither → manual. |
| Author contact | Plugin header Author / Author URI. Record so the report can recommend disclosure path. |
| Audience | Internal staff only? Multi-tenant public? Affects who the attacker realistically is. |
A private plugin with no update mechanism amplifies severity — the site owner can't auto-patch when the author ships a fix. Note this in the Scope section AND in the verdict reasoning if it changes the call.
Update URI absent on a non-wp.org plugin is itself a finding, not just a classification. Any plugin classified private / GitHub / marketplace that lacks an Update URI header is exposed to wp.org slug hijacking: wp_update_plugins() broadcasts its folder slug to the wp.org update API, and an unclaimed matching slug can be published by anyone at a higher version and served as an "update" — silently, if auto-updates are on. Verify slug ownership and recommend Update URI: false (or a real updater URL) — see references/standards-checklist.md → §2 → Folder slug ownership.
Distribution is how the plugin ships. These are the conditions it runs under — and they're invisible in the plugin's own source, so you have to ask. Each one changes what the audit finds or what it can recommend. You can't read these out of the code; ask the user. Record the answers in the report's Scope section.
| Question | Why it changes the audit |
|---|---|
| Who else writes this data? Another plugin, a scheduled import, an external integration, a human in the admin, a staging-to-production sync. | Concurrency, precedence and overwrite bugs live here and are invisible in the plugin's own source. A per-record hook that's a mild "uncached query" note becomes a real finding once a nightly sync touches thousands of records; a writer that overwrites what the plugin computes is the premise of a design-risk section. This is the system-of-record question (Discover, above) from the other side — the plugin may own the data (silent-corruption rule) yet still not be its only writer. |
| How do changes actually reach production? Version control + CI, or a file copied over by hand. | Determines which remediations are reachable at all. "Put it under version control" is not advice for an owner who hand-edits on the server — see the Report-phase reachability rule. Hand-edited deployments change the fix: keep it a single file so a partial upload can't leave a half-working plugin, put the changelog inside the file (the header version is the only history that will exist), and set Update URI: false so an auto-update can't discard the edits. |
| What's already planned? A multilingual layer, a platform migration, a headless front end, a new integration not yet installed. | Turns "not applicable today" findings into ones worth writing now, while they're cheap. Two High findings can live entirely in the interaction between the plugin and a layer that isn't installed yet. |
Read .gitignore and .distignore if present. Skip their excluded paths during the scan — auditing tests/, *.md, dev configs, or .git/ wastes effort and adds noise.
Skip vendor/ and node_modules/ by default, even when they ship in the release. Auditing third-party dependency code is out of scope for a plugin audit unless the user explicitly asks for it (e.g. "audit the bundled dependencies too"). Audit the plugin's own code; assume deps are the upstream maintainers' responsibility.
List what you skipped in the report's Scope section ("Ignored (gitignore/distignore): …", and note vendor//node_modules/ skipped) so the reader knows the coverage boundary. If the user wants deps included, scan them and say so in Scope.
if [ -f .gitignore ]; then echo "--- .gitignore ---"; cat .gitignore; fi
if [ -f .distignore ]; then echo "--- .distignore ---"; cat .distignore; fi
For remote audits (wp.org slug, GitHub URL): references/remote-fetch.md.
When the target is third-party code committed to a site's repository (outside its vendor's update path) and the user wants a risk read, not a full audit, run a hotspot pass instead of phases 2 and 3. Read every hit in context and verify it as usual:
register_rest_route with permission_callback missing or __return_true, and what the callback does (security-checklist.md §1.1);wp_ajax_nopriv_ handlers, and wp_ajax_ handlers without a capability check or nonce (§1.2, §2);admin_post_ and admin_post_nopriv_ handlers, and plugin XML-RPC methods (xmlrpc_methods) (§1.7, §1.11);wp_capabilities meta, profile-save handlers, user_has_cap / map_meta_cap grants (§1.9);include / require, file_get_contents, fopen, unlink, readfile (§6);unserialize / maybe_unserialize on request data, cookies, or options a low role can write (§8);require of wp-load.php) or lack an ABSPATH guard (§12).Say in Scope that it was a hotspot pass and list the classes covered. Fix lines follow the "committed or already modified" row of the ownership table (references/shared-conventions.md → Fix guidance by ownership).
Run it when the sweep's REST, AJAX and admin-post counts do not explain what the plugin registers, and only on an approved local site with the plugin active:
wp eval-file - <plugin-dir-name> < scripts/hook-map.php > <out-dir>/hook-map.json
The JSON lists, with the file:line of each callback: REST routes and their effective permission_callback (none, open or the callable), AJAX and admin_post_ handlers, shortcodes, settings and meta with their sanitize and auth callbacks, cron hooks, and xmlrpc_methods callbacks. Compare it with the sweep's hits; read every entry the sweep did not list. When a WP-CLI wrapper does not pass STDIN through, copy the file to a temporary path inside the site (not inside the plugin), pass that path to wp eval-file, and delete it afterwards.
The script writes nothing. Loading the REST server fires rest_api_init, so the plugins' route code runs as it would for any REST request. Hooks added only on admin screens are not in the map. Scope says whether the map ran, and why not when it did not.
When the user asks for what changed ("since the last release", "between 1.4.0 and this branch"), audit the range instead of the whole plugin. This is the pre-release check for the plugin's own repository; pull requests go to wp-pr-review.
bash scripts/range.sh <plugin-dir> <out-dir> --base <ref> [--head <ref>], with <out-dir> outside the plugin. It writes scope.json (refs, SHAs, counts, warnings) and changed.json (each changed file with its status and new line ranges), and prints a confirmation block with warnings. Show the block to the user and wait for a yes before going on.bash scripts/guard-delta.sh <plugin-dir> --scope <out-dir>/scope.json <out-dir> and read guard-delta.md: checks that disappeared, checks made weaker, new ways in, dependency changes. Every item there gets a verdict in the report, as a finding or in Verified false.In range: line: yes when the defect is in the changed lines, no with a short reason otherwise (for example "old code, reached from new code at includes/Api.php:40"). Scope names the range (<base>..<head>, commits, files).The verdict covers the range. Findings with In range: no are listed too, and the verdict reasoning says whether any of them blocks the release.
Run what's available; don't block on absence. Pure-read fallback works.
Start with the tool check. bash scripts/tool-check.sh <plugin-dir> installs nothing and writes nothing. It prints the tools found, which audit steps can run (tool scan, history secrets scan, runtime inventory, reproduce, report checker), and what each missing tool would add. Record the result in Scope → Tools run. Never install anything into the audited code.
| Tool | Command | Catches |
|---|---|---|
| PHPCS + WPCS | phpcs --standard=WordPress,WordPress-VIP-Go path/ | Standards, common security smells, escape/sanitize hints |
| PHPStan | phpstan analyse --level=5 path/ | Type bugs, null derefs, undefined vars |
| Plugin Check | wp plugin check <slug> | wp.org reviewer rules; closest to official approval criteria |
| Composer audit | composer audit (in plugin dir) | Known CVEs in PHP deps |
| npm audit | npm audit --omit=dev | Known CVEs in JS deps (skip if dist/ is not built from source) |
Capture output to /tmp/audit-<slug>/. Reference findings by tool + rule code in the report (e.g. [WPCS WordPress.Security.EscapeOutput.OutputNotEscaped]).
Details + interpretation: references/tooling.md.
Tools generate candidates, not findings. A WPCS warning is a hint to look — not a confirmed bug. Verify (phase 4) before reporting.
Branch reviews: /security-review as an extra candidate source (optional). When the audit target is a feature branch or a set of pending changes, and Claude Code's built-in /security-review is available, run it on the branch. It reviews the diff only and has no WordPress-specific knowledge, so treat its output like any other tool: candidates that go through Verify, cited in the report as [security-review]. Skip it for whole-plugin audits, where the diff is not the audit's scope.
Start from the sweep. bash scripts/sweep.sh <plugin-dir> <out-dir> (out-dir outside the plugin) runs every pattern in scripts/patterns.tsv, one row per checklist detection, tagged with its section number. It writes one hit file per section and group, with secret-shaped strings masked, and a sweep.md with: hit counts per section (zero rows included, for the report's "Sections audited" line), and bundled packages with a released column. The sweep lists where to look. It is not the audit: every section below still gets read, and a section with zero hits is still checked by hand for what a line pattern cannot see (calls split over several lines, dynamic hook names).
Tools catch patterns; people catch intent. Read in this order:
register_rest_route. Inspect permission_callback, argument validation (args), response shape (does it leak meta?).wp_ajax_*, wp_ajax_nopriv_*, admin_post_*, admin_post_nopriv_* and xmlrpc_methods method. Capability + nonce + sanitization inside the handler; a capability on the menu page does not protect the handler.register_setting() sanitize callbacks.$wpdb->query, ->get_results, ->get_var, ->prepare, ->insert, ->update, ->delete. Trace inputs.file_get_contents, file_put_contents, fopen, unlink, move_uploaded_file, wp_handle_upload, wp_upload_bits. Path traversal? Extension allowlist?wp_remote_*. SSRF if URL is user-controlled.unserialize, maybe_unserialize on user-controllable or low-trust stored data → object injection.current_user_can. Missing? Wrong cap (read instead of manage_options)? is_admin() or is_user_logged_in() used as a gate? Roles or capabilities written from request data?init)?wp_schedule_event registrations. Cleared in deactivation? Hook callback registered before scheduling?references/integration-checklist.md.Apply the five checklists. Traverse every section of every checklist; don't skim and assume coverage. A common audit failure is forgetting to read a reference file end-to-end and missing entire categories (secrets storage, IDOR, ABSPATH guards, error-response disclosure).
references/security-checklist.md — rating by role (unfiltered_html, chains), auth, nonces, caps, IDOR, hand-rolled token auth, admin_post_ handlers, role and capability writes, REST meta, XML-RPC methods, sanitize, escape, add_query_arg() reflection, SQLi, CSRF, SSRF, file ops, archive extraction, deserialization, code-execution sinks, secrets in code, stored credentials, error response & info disclosure, direct file access, personal data without exporters or erasers, open redirects, block editor sinks, multisite, cross-origin requests.references/performance-checklist.md — autoloaded options, expensive queries, missing indexes, transients without TTL, cache-thrashing hooks, cron storms, enqueue scope, asset weight.references/standards-checklist.md — WPCS rules, function/class prefixing, i18n, deprecated APIs, plugin header completeness, GPL compatibility.references/integration-checklist.md — cross-plugin coupling invisible from a single plugin: companions writing shared data via direct SQL (hooks never fire), stored foreign IDs vs record-duplicating layers, hook-ordering races, cache staleness, WooCommerce HPOS / Cart-Checkout-Blocks declarations. Conditional — apply only when a companion touches the same data.references/false-positive-traps.md — verification procedures for SQLi / nonce / escape / sanitize before flagging.Traversal checklist — before moving to phase 4, confirm you ran each detection in every section of each file. If a section produced zero candidates, note that in the report's Scope section under "Sections audited" — it shows your work and tells the reader nothing was skipped.
Trace every candidate finding through source before it enters the report. The per-category verification table, the drop-and-record rule, reachability, pervasive patterns, the spot-check of every Critical and High, and the "counts are findings too" rule are in references/shared-conventions.md → Verify. Category procedures: references/false-positive-traps.md.
Where an environment is available, build the smallest fixture that triggers the top findings and capture before/after. Run it after Verify, never in its place. Rules: references/shared-conventions.md → Reproduce.
For security findings, prove every Critical and High when an approved local site exists, with references/security-reproduction.md (when a result counts: a twin request and a sink-log marker; wrong code, wrong identity and wrong place to look; recording; the run ledger for teardown). When it does not run, Scope says why and lists the unproven Critical and High IDs.
Read references/shared-conventions.md → Report before writing. It covers where to write (ask first, default .claude/, check git-ignore status), the dated filename that never overwrites, plain-terms and TL;DR rules, fix guidance by ownership, and permanent finding IDs.
Plugin specifics:
AUDIT-<yyyy-mm-dd>.md; same-day re-audit AUDIT-<yyyy-mm-dd>-<HHMM>.md. Check that the report is ignored; if not, use a dedicated report folder with its own .gitignore (references/shared-conventions.md → Where to write the report).references/report-template.md.bash scripts/lint-report.sh <report> from this skill's directory, and deliver only when it reports no errors (references/shared-conventions.md → Report → Check the report before delivery).Required section order:
# Audit: <plugin-name> <version>## TL;DR## Summary## Scope## Findings## Verified false (appendix)## Decisions needed from the owner — omit when there are no [DECISION] findings.## Recommendation## Sources## Tooling output## Audit metadataMost fixes are one or two lines and need no extra guidance. When a fix changes structure (moving a hand-rolled settings form to the Settings API, reworking activation and uninstall, splitting a handler into a REST route with a real permission_callback), consult wp-plugin-development if it is installed, so the recommended fix is idiomatic. It is not required: without it, write the fix from the checklists.
Rate every finding with the Severity Rubric in references/shared-conventions.md, including the subscriber-exploitable rule, the silent-corruption rule (it depends on the system-of-record answer from Discover) and the distribution amplifier. Mark owner-decision findings with [DECISION] as described there. Close with a verdict from its Verdict Rules: GO / NO-GO / GO WITH FIXES, with two-sentence reasoning.
The report is the start of the work, not the end — findings get fixed, the owner needs to know what changed, and [DECISION] findings wait on their answers. That remediation phase has its own skill: wp-plugin-audit-remediation. It covers the per-finding remediation log, freezing an immutable copy of the audited version so the report's file:line citations stay readable once fixing starts, and proving that renames / formatter runs / mechanical refactors changed no behaviour. Hand off to it when the verdict is written.
composer audit or npm audit calling a dev-only package "critical" says nothing about the plugin; what ships and runs decides.current_user_can() argument decides.dist/). Audit source. Note when source isn't shipped (then audit the build, downgrade confidence).references/shared-conventions.md — verification, reproduction, report rules, permanent finding IDs, severity rubric, [DECISION] findings, verdict rules. Shared with wp-theme-code-audit and wp-project-security-audit.references/security-checklist.md — security audit categories with detection patterns + verification procedures.references/performance-checklist.md — performance audit categories.references/standards-checklist.md — WPCS + WordPress.org plugin guidelines.references/integration-checklist.md — cross-plugin coupling and platform compatibility declarations (conditional; applies when a companion writes the same data or a layer duplicates referenced records).references/false-positive-traps.md — verification procedures for SQLi, nonce, escape, sanitize.references/security-reproduction.md — proving security findings on an approved local site: when a result counts, the three ways a probe misleads (wrong code, wrong identity, wrong place to look), the sink log and where each class shows its effect, recording, and the run ledger.references/report-template.md — full AUDIT-<yyyy-mm-dd>.md template with worked examples.references/tooling.md — PHPCS / PHPStan / Plugin Check commands + interpretation.references/remote-fetch.md — fetching plugins from wp.org slug or GitHub URL.scripts/lint-report.sh — read-only checker for a written plugin, theme or project report. Shared with wp-theme-code-audit and wp-project-security-audit.scripts/tool-check.sh — which tools and phases are available; installs nothing.scripts/sweep.sh + scripts/patterns.tsv — runs every checklist detection at once; hit files per section, bundled code. patterns.tsv is the single pattern list, shared with guard-delta.sh.scripts/guard-delta.sh — for a diff: checks that disappeared or got weaker, new ways in, dependency changes. Used by the diff scope and by wp-pr-review.scripts/range.sh — resolves a diff scope (<base>..<head>) and prints a confirmation block.scripts/find-secrets.sh — secrets in tracked files and git history, locations and masked values only. Shared with wp-project-security-audit.scripts/hook-map.php — runtime REST, AJAX, admin-post, shortcode, settings, meta, cron and XML-RPC surface of one plugin, via wp eval-file.wp-plugin-audit-remediation — the phase after this one: remediation log, immutable audited copy, behaviour-neutrality proof for fixes. Hand off once the report is written.wp-plugin-development — building plugins (forward-looking patterns the audit checks for). Optional at report time for structural fix recommendations; see Report → Writing fix recommendations.wp-plugin-directory-guidelines — wp.org submission rules (used in the standards checklist).wp-phpstan — PHPStan setup for WP projects (deepens the static analysis step).wp-performance — performance investigation when audit findings need deeper triage.wp-project-triage — repo-shape inspection (useful in Discover phase).references/false-positive-traps.md (opens in a new tab)references/integration-checklist.md (opens in a new tab)references/performance-checklist.md (opens in a new tab)references/remote-fetch.md (opens in a new tab)references/report-template.md (opens in a new tab)references/security-checklist.md (opens in a new tab)references/security-reproduction.md (opens in a new tab)references/shared-conventions.md (opens in a new tab)references/standards-checklist.md (opens in a new tab)references/tooling.md (opens in a new tab)scripts/find-secrets.sh (opens in a new tab)scripts/guard-delta.sh (opens in a new tab)scripts/hook-map.php (opens in a new tab)scripts/lint-report.sh (opens in a new tab)scripts/patterns.tsv (opens in a new tab)scripts/range.sh (opens in a new tab)scripts/sweep.sh (opens in a new tab)scripts/tool-check.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub s3rgiosan/wp-skills --plugin wp-plugin-code-audit