Skill Press Index Testing & Code Review WP PHPStan TESTING & CODE REVIEW WP PHPStan WordPress
No. 959 · wp-phpstan
WP PHPStan A field guide from WordPress
WordPress
When to use it Use when configuring, running, or fixing PHPStan static analysis in WordPress projects (plugins/themes/sites): phpstan.neon setup, baselines, WordPress-specific typing, and handling third-party plugin classes.
Rank No. 959 of 971
Installs Not listed yet
Runs in Claude, GitHub Copilot, Codex, Cursor
Length 506 words · 2 min
Files 7
License GPL-2.0-or-later Get this skill Download the skill folder (.zip, 15 KB) ↓ · SKILL.md only ↓
Agent prompt Paste into a coding agent with terminal access. Check the upstream requirements for the skill you’re installing.
Prompt Copy
Install the "wp-phpstan" Agent Skill by WordPress, from https://github.com/WordPress/agent-skills.
1. Fetch the whole folder skills/wp-phpstan — SKILL.md plus every script, reference, and asset beside it, not just SKILL.md. For example:
skill_checkout=$(mktemp -d)
git init "$skill_checkout"
git -C "$skill_checkout" fetch --depth 1 https://github.com/WordPress/agent-skills.git 7374e6f1c913b3b02b25465d266d9c0e0a04fc96
git -C "$skill_checkout" checkout --detach FETCH_HEAD
2. Copy it into your skills directory as a folder named "wp-phpstan":
- Claude Code: ~/.claude/skills/wp-phpstan/ (all projects) or .claude/skills/wp-phpstan/ (this project only)
- Another agent: the directory you load Agent Skills from (folders containing a SKILL.md)
3. Check that wp-phpstan/SKILL.md exists and its frontmatter says name: wp-phpstan.
4. Read SKILL.md, then tell me in two or three sentences what the skill does and when it will trigger, and list any dependencies it mentions (Python packages, npm packages, CLIs) that aren't installed yet. Don't install them without asking. skills CLI One command; the skills.sh installer detects your agents (Claude Code, Cursor, Codex, and more).
Terminal Copy
npx skills add https://github.com/WordPress/agent-skills/tree/7374e6f1c913b3b02b25465d266d9c0e0a04fc96/skills/wp-phpstan --skill wp-phpstan Claude.ai Upload the .zip as a custom skill.
In Settings → Capabilities, turn on “Code execution and file creation”. Download the .zip above. Go to Customize → Skills, click + → Create skill → Upload a skill, and choose it. Anthropic’s guide to using skills ↗ The skill, in full When to use
Use this skill when working on PHPStan in a WordPress codebase, for example:
setting up or updating phpstan.neon / phpstan.neon.dist
generating or updating phpstan-baseline.neon
fixing PHPStan errors via WordPress-friendly PHPDoc (REST requests, hooks, query results)
handling third-party plugin/theme classes safely (stubs/autoload/targeted ignores)
wp-project-triage output (run first if you haven’t)
Whether adding/updating Composer dev dependencies is allowed (stubs).
Whether changing the baseline is allowed for this task.
Procedure
0) Discover PHPStan entrypoints (deterministic)
Inspect PHPStan setup (config, baseline, scripts):
node skills/wp-phpstan/scripts/phpstan_inspect.mjs
Prefer the repo’s existing composer script (e.g. composer run phpstan) when present.
1) Ensure WordPress core stubs are loaded
szepeviktor/phpstan-wordpress or php-stubs/wordpress-stubs are effectively required for most WordPress plugin/theme repos. Without it, expect a high volume of errors about unknown WordPress core functions.
Confirm the package is installed (see composer.dependencies in the inspect report).
Ensure the PHPStan config references the stubs (see references/third-party-classes.md).
2) Ensure a sane phpstan.neon for WordPress projects
Keep paths focused on first-party code (plugin/theme directories).
Exclude generated and vendored code (vendor/, node_modules/, build artifacts, tests unless explicitly analyzed).
Keep ignoreErrors entries narrow and documented.
See:
references/configuration.md
3) Fix errors with WordPress-specific typing (preferred)
Prefer correcting types over ignoring errors. Common WP patterns that need help:
REST endpoints: type request parameters using WP_REST_Request<...>
Hook callbacks: add accurate @param types for callback args
Database results and iterables: use array shapes or object shapes for query results
Action Scheduler: type $args array shapes for job callbacks
See:
references/wordpress-annotations.md
4) Handle third-party plugin/theme classes (only when needed)
When integrating with plugins/themes not present in the analysis environment:
First, confirm the dependency is real (installed/required).
Prefer plugin-specific stubs already used in the repo (common examples: php-stubs/woocommerce-stubs, php-stubs/acf-pro-stubs).
If PHPStan still cannot resolve classes, add targeted ignoreErrors patterns for the specific vendor prefix.
See:
references/third-party-classes.md
Generate a baseline once for legacy code, then reduce it over time.
Do not “baseline” newly introduced errors.
See:
references/configuration.md
Verification
Run PHPStan using the discovered command (composer run ... or vendor/bin/phpstan analyse).
Confirm the baseline file (if used) is included and didn’t grow unexpectedly.
Re-run after changing ignoreErrors to ensure patterns are not masking unrelated issues.
Failure modes / debugging
“Class not found”:
confirm autoloading/stubs, or add a narrow ignore pattern
Huge error counts after enabling PHPStan:
reduce paths, add excludePaths, start at a lower level, then ratchet up
Inconsistent types around hooks / REST params:
add explicit PHPDoc (see references) rather than runtime guards
Escalation
If a type depends on a third-party plugin API you can’t confirm, ask for the dependency version or source before inventing types.
If fixing requires adding new Composer dependencies (stubs/extensions), confirm it with the user first.
More in Testing & Code Review Test-Driven Development tdd · Matt Pocock · 1,295,980 installs Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
Systematic Debugging systematic-debugging · Jesse Vincent · 352,283 installs Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Requesting Code Review requesting-code-review · Jesse Vincent · 296,051 installs Use when completing tasks, implementing major features, or before merging to verify work meets requirements
Test-Driven Development test-driven-development · Jesse Vincent · 295,845 installs Use when implementing any feature or bugfix, before writing implementation code
Verification Before Completion verification-before-completion · Jesse Vincent · 294,059 installs Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Receiving Code Review receiving-code-review · Jesse Vincent · 253,741 installs Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Browser Automation with playwright-cli playwright-cli · Microsoft Playwright · 230,963 installs Automate browser interactions, test web pages and work with Playwright tests.
Testing Web Apps webapp-testing · Anthropic · 216,969 installs Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
All Testing & Code Review skills → More from WordPress WordPress Playground Blueprints blueprint · WordPress Use when the deliverable is WordPress Playground Blueprint JSON or a Blueprint bundle, including creating, editing, reviewing, validating schema keys, choosing steps/resources, and debugging Blueprint files. For only running or sharing a Playground environment, use wp-playground.
WordPress Router wordpress-router · WordPress Use when the user asks about WordPress codebases (plugins, themes, block themes, Gutenberg blocks, WP core checkouts) and you need to quickly classify the repo and route to the correct workflow/skill (blocks, theme.json, REST API, WP-CLI, performance, security, testing, release packaging).
WP Abilities API wp-abilities-api · WordPress Use when working with the WordPress Abilities API (wp_register_ability, wp_register_ability_category, /wp-json/wp-abilities/v1/*, @wordpress/abilities) including defining abilities, categories, meta, REST exposure, and permissions checks for clients.
WP Abilities Audit wp-abilities-audit · WordPress Audit a WordPress plugin's REST surface and produce a standardized audit document proposing Abilities API registrations. Produces a markdown doc with a YAML schema and prose sections that humans and agents can both consume when planning a registration rollout. Works on any WP plugin.
WP Abilities Verify wp-abilities-verify · WordPress Verify a WordPress plugin's Abilities API registrations: enumerate abilities, check that callback behavior matches each annotation's claim (the adversarial readonly-but-writes detection), validate permissions and schemas, and validate audit documents produced by wp-abilities-audit.
WordPress Ability Development wp-ability-development · WordPress Use when designing, updating, or reviewing the schemas or behavior of a WordPress ability.
From WordPress/agent-skills at 7374e6f , GPL-2.0-or-later. Install counts from skills.sh .