wp2next optimize
Runs review skills (performance, accessibility, SEO) and wp2next's own site-structure, redirect and content-model checks, then applies only safe or approved fixes on a branch, proven with Lighthouse before and after.
| Synopsis | wp2next optimize [all | <area> | <skill>] [--report-only] [--override-gate] [--cache-components] (Claude desktop and Claude Code plugin: /wp2next:optimize; Codex: $wp2next optimize; Cursor: /wp2next optimize) |
|---|---|
| Changes code | Yes, on branch wp2next/optimize-<date>, one approved fix per commit. Before parity sign-off it reports only by default |
| Touches outside services | Hosting changes ([infra] items such as Vercel settings) are listed with their exact setting and cost effect; each is a separate step with its own yes. It asks before pushing, before merging, and before adding Lighthouse tooling to the project |
| Reads | A local production build, wp2next.json, the migration's URL list and WordPress export, Search Console or analytics CSV exports if you provide them, Vercel production metrics (vercel area) |
| Writes | Commits on the branch, reports in .wp2next/optimize/, Lighthouse runs in .wp2next/lighthouse/, optimize.lastRun and lighthouse.lastRun in wp2next.json, departure entries |
What it does
Areas:
| Area | Uses | Looks at |
|---|---|---|
react | React best-practice companions | Waterfalls, server/client split, rerenders, component APIs |
bundle | Next bundle optimizer | Client JavaScript on first load, duplicate dependencies, scripts that can wait |
caching | Vercel caching review | Revalidate values, webhook coverage, static vs dynamic routes, headers |
design | Web design guidelines | Accessibility, focus, forms, images, typography, motion |
seo | Sanity's SEO/AEO skill | Metadata, Open Graph, sitemap, robots, JSON-LD. Full WordPress-vs-Next checks belong to seo |
vercel | Vercel optimize | Cost and performance from production metrics (needs a deployed site with traffic) |
ia | wp2next | Click depth, orphan, thin and duplicate pages, WordPress leftovers (date/author/attachment archives, tag sprawl, "Uncategorized"), nav vs traffic, slug hygiene |
redirects | wp2next | Chains, loops, temporary redirects, missing old slugs, legacy WordPress URLs (?p=, feeds, uploads), Search Console 404s, trailing-slash and case variants |
structure | wp2next | Repeated content that should be proper Sanity documents: team, locations, services, testimonials, FAQs, pricing, events, jobs |
all | Every area whose companion is installed, plus ia, redirects and structure |
A missing companion skill is never a blocker: it says how to install it and carries on with the other areas. See Companion skills.
How a run goes:
- Checks a clean git tree and a passing lint, typecheck and build; creates the branch.
- Baseline on a local production build: screenshots of every page and a Lighthouse run.
- Reviews run on the side, read-only, one per area.
- Triage with you: one merged table, sorted by expected gain. Each item is tagged
[safe](nothing visible changes),[visual],[content],[model](a Sanity model change that renders identically),[infra](a hosting setting) or[conflict](breaks a wp2next rule, so rejected). Rejected and deferred items are written down so later runs don't propose them again. - Applies approved items, one per commit.
- Proves it: a screenshot diff against the baseline (must pass for
[safe]items; any difference must match an approved[visual]item), the parity score against WordPress in pixel and faithful modes, and Lighthouse before and after. Any drop in Accessibility or SEO blocks the merge. - Summary, then you choose: merge all, some or none.
The parity gate:
| Site state | What optimize may do |
|---|---|
| Parity not signed off | Report only. With --override-gate and your yes, [safe] fixes that pass the screenshot diff; never [visual] |
| Parity signed off (pixel or faithful) | [safe] fixes after you OK the list; visible desktop changes are proposed departures, asked one by one |
| Facelift mode | No gate; visual findings are design decisions. Content, URL and metadata changes still need approval |
migrate offers optimize once when parity is first signed off.
Arguments and options
| Argument | Effect |
|---|---|
all | Every available area |
<area> | One of react, bundle, caching, design, seo, vercel, ia, redirects, structure |
<skill> | Run just that companion skill, for example web-design-guidelines |
--report-only | Report, change nothing (the default before parity sign-off) |
--override-gate | Before sign-off, allow [safe] fixes (asks for an explicit yes) |
--cache-components | Opt into Next's Cache Components. A departure from wp2next's caching pattern: asked first, recorded, run with full upgrade-style checks, never part of all |
Examples
For Claude desktop
/wp2next:optimize all/wp2next:optimize all$wp2next optimize all/wp2next optimize allwp2next optimize redirects: check old WordPress URLs and redirect chains (you can add a Search Console "Not found" CSV export).wp2next optimize ia: site structure and navigation vs traffic.wp2next optimize structure: propose turning repeated content into Sanity documents.wp2next optimize --report-only: a read-only look before sign-off.
Related
- Companion skills · SEO guide
seo·audit·upgrade- Scripts:
lighthouse.mjs,redirect-audit.mjs - Agent instructions:
references/commands/optimize.md (external site)