Use when investigating or improving WordPress performance (backend-only agent): profiling and measurement (WP-CLI profile/doctor, Server-Timing, Query Monitor via REST headers), database/query optimization, autoloaded options, object caching, cron, HTTP API calls, and safe verification.
Add this skill
npx mdskills install WordPress/wp-performanceComprehensive backend profiling workflow with WP-CLI, Query Monitor, and actionable optimization paths
1---2name: wp-performance3description: "Use when investigating or improving WordPress performance (backend-only agent): profiling and measurement (WP-CLI profile/doctor, Server-Timing, Query Monitor via REST headers), database/query optimization, autoloaded options, object caching, cron, HTTP API calls, and safe verification."4compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Backend-only agent; prefers WP-CLI (doctor/profile) when available."5---67# WP Performance (backend-only)89## When to use1011Use this skill when:1213- a WordPress site/page/endpoint is slow (frontend TTFB, admin, REST, WP-Cron)14- you need a profiling plan and tooling recommendations (WP-CLI profile/doctor, Query Monitor, Xdebug/XHProf, APMs)15- you’re optimizing DB queries, autoloaded options, object caching, cron tasks, or remote HTTP calls1617This skill assumes the agent cannot use a browser UI. Prefer WP-CLI, logs, and HTTP requests.1819## Inputs required2021- Environment and safety: dev/staging/prod, any restrictions (no writes, no plugin installs).22- How to target the install:23 - WP root `--path=<path>`24 - (multisite/site targeting) `--url=<url>`25- The performance symptom and scope:26 - which URL/REST route/admin screen27 - when it happens (always vs sporadic; logged-in vs logged-out)2829## Procedure3031### 0) Guardrails: measure first, avoid risky ops32331. Confirm whether you may run write operations (plugin installs, config changes, cache flush).342. Pick a reproducible target (URL or REST route) and capture a baseline:35 - TTFB/time with `curl` if possible36 - WP-CLI profiling if available3738Read:39- `references/measurement.md`4041### 1) Generate a backend-only performance report (deterministic)4243Run:4445- `node skills/wp-performance/scripts/perf_inspect.mjs --path=<path> [--url=<url>]`4647This detects:4849- WP-CLI availability and core version50- whether `wp doctor` / `wp profile` are available51- autoloaded options size (if possible)52- object-cache drop-in presence5354### 2) Fast wins: run diagnostics before deep profiling5556If you have WP-CLI access, prefer:5758- `wp doctor check`5960It catches common production foot-guns (autoload bloat, SAVEQUERIES/WP_DEBUG, plugin counts, updates).6162Read:63- `references/wp-cli-doctor.md`6465### 3) Deep profiling (no browser required)6667Preferred order:68691. `wp profile stage` to see where time goes (bootstrap/main_query/template).702. `wp profile hook` (optionally with `--url=`) to find slow hooks/callbacks.713. `wp profile eval` for targeted code paths.7273Read:74- `references/wp-cli-profile.md`7576### 4) Query Monitor (backend-only usage)7778Query Monitor is normally UI-driven, but it can be used headlessly via REST API response headers and `_envelope` responses:7980- Authenticate (nonce or Application Password).81- Request REST responses and inspect headers (`x-qm-*`) and/or the `qm` property when using `?_envelope`.8283Read:84- `references/query-monitor-headless.md`8586### 5) Fix by category (choose the dominant bottleneck)8788Use the profile output to pick *one* primary bottleneck category:8990- **DB queries** → reduce query count, fix N+1 patterns, improve indexes, avoid expensive meta queries.91 - `references/database.md`92- **Autoloaded options** → identify the biggest autoloaded options and stop autoloading large blobs.93 - `references/autoload-options.md`94- **Object cache misses** → introduce caching or fix cache key/group usage; add persistent object cache where appropriate.95 - `references/object-cache.md`96- **Remote HTTP calls** → add timeouts, caching, batching; avoid calling remote APIs on every request.97 - `references/http-api.md`98- **Cron** → reduce due-now spikes, de-duplicate events, move heavy tasks out of request paths.99 - `references/cron.md`100101### 6) Verify (repeat the same measurement)102103- Re-run the same `wp profile` / `wp doctor` / REST request.104- Confirm the performance delta and that behavior is unchanged.105- If the fix is risky, ship behind a feature flag or staged rollout when possible.106107## WordPress 6.9 performance improvements108109Be aware of these 6.9 changes when profiling:110111**On-demand CSS for classic themes:**112- Classic themes now get on-demand CSS loading (previously only block themes had this).113- Reduces CSS payload by 30-65% by only loading styles for blocks actually used on the page.114- If you're profiling a classic theme, this should already be helping.115116**Block themes with no render-blocking resources:**117- Block themes that don't define custom stylesheets (like Twenty Twenty-Three/Four) can now load with zero render-blocking CSS.118- Styles come from global styles (theme.json) and separate block styles, all inlined.119- This significantly improves LCP (Largest Contentful Paint).120121**Inline CSS limit increased:**122- The threshold for inlining small stylesheets has been raised, reducing render-blocking resources.123124Reference: https://make.wordpress.org/core/2025/11/18/wordpress-6-9-frontend-performance-field-guide/125126## Verification127128- Baseline vs after numbers are captured (same environment, same URL/route).129- `wp doctor check` is clean (or improved) when applicable.130- No new PHP errors or warnings in logs.131- No cache flush is required for correctness (cache flush should be last resort).132133## Failure modes / debugging134135- “No change” after code changes:136 - you measured a different URL/site (`--url` mismatch), caches masked results, or opcode cache is stale137- Profiling data is noisy:138 - eliminate background tasks, test with warmed caches, run multiple samples139- `SAVEQUERIES`/Query Monitor causes overhead:140 - don’t run in production unless explicitly approved141142## Escalation143144- If this is production and you don’t have explicit approval, do not:145 - install plugins, enable `SAVEQUERIES`, run load tests, or flush caches during traffic146- If you need system-level profiling (APM, PHP profiler extensions), coordinate with ops/hosting.147
Full transparency — inspect the skill content before installing.