Skip to content
wp2next, home
Skip to the page

Scripts

The helper scripts in skills/wp2next/scripts/⁠ (external site). The runs them for you during each command; you can also run them yourself. Every one prints its own help with --help (secrets.py also with help or no arguments), and that help is the final word on options. All of them run the same way on macOS, Windows (PowerShell 7, Command Prompt or Git Bash) and Linux.

Your computer

Pick your computer's system. Steps that differ switch to it, and this browser remembers.

ScriptPurposeUsed by
config.pyRead and write the user config and wp2next.jsonalmost every command
secrets.pyOne interface over whichever secret store you picked (secrets.sh is a wrapper for it)migrate, handoff, seo, compliance, content, optimize, polish, upgrade, doctor
fsutil.pyCross-platform file helpers: copy a folder, replace text, read image sizes, random hex, open, whichmigrate, upgrade, optimize, handoff, status, init, doctor (wherever a step would otherwise need rsync, sed -i, sips or openssl)
version.pyInstalled version, install method, latest release, changeloginit, doctor, update, upgrade, changelog, uninstall, feedback, contribute
lighthouse.mjsLighthouse scores, mobile and desktop, median of several runsmigrate, optimize, seo, status, upgrade, doctor
seo-scan.mjsSEO extraction and the WordPress-vs-Next parity gateseo, migrate, doctor
redirect-audit.mjsFollows old URLs hop by hop on the new siteoptimize, seo, doctor
compliance-scan.mjsPrivacy, consent, accessibility, form and security gap scancompliance, migrate
content-audit.mjsContent audit and the "no new facts" check for rewritescontent, doctor
status-dashboard.pyOne-page HTML status report for a migrationstatus
scrub-check.pyBlocks client names and secrets in text that leaves your machinefeedback, contribute, report, migrate, upgrade
report.pyThe opt-in completion reportreport, migrate, doctor
check-noindex.mjsPrints the status and X-Robots-Tag of protected preview URLsmigrate (phase 11 checkpoint)

In the examples, <skill> is the folder that holds SKILL.md (where depends on how you installed wp2next; version.py locations lists every copy). Run the scripts from the site's root, where wp2next.json is found.

Which command. The examples write python3. wp2next itself uses $PY: the first of python3, python and py -3 that actually runs (it tests each with -c 1, because on Windows python3 may be a Microsoft Store stub that exists but doesn't run). On Windows, type py where the examples say python3, and \ in paths if you like (/ works too):

Terminal
python3 <skill>/scripts/version.py locations

Requirements. Python scripts need Python 3.9 or newer and nothing else (standard library only). They read and write files as UTF-8 on every system, so text with accents, emoji or arrows is safe on Windows too. Node scripts target Node 24, the toolchain baseline. seo-scan.mjs, redirect-audit.mjs and content-audit.mjs need no packages; lighthouse.mjs and compliance-scan.mjs need the packages listed in their sections.

Read-only by default. The scans and audits never change a site: they fetch pages and write reports in the repo (.wp2next/…, .compliance/reports/). Only config.py set/unset/init-project, secrets.py put/env-file/push-vercel, fsutil.py copy-tree/replace and report.py send/record write anything outside a report folder.

config.py

Reads and writes the two config files, validates them, and refuses anything that looks like a . Key reference: Configuration reference.

Terminal
python3 <skill>/scripts/config.py {path,show,get,set,unset,validate,init-project,forms-config} ...
Sub-commandDoes
path [--project]Print the user config path, or the nearest wp2next.json
show [--scope merged|user|project|defaults] [--expand]Print the effective config as JSON. --expand fills {code}
get KEY [--expand] [--code CODE]Print one dotted key; exit 1 if unset
set KEY VALUE [--project] [--merge] [--force]Write one key (user config unless --project). VALUE is read as JSON when it parses, else as text. Validates first
unset KEY [--project]Remove one key
validate [--project FILE] [--user-only] [--no-migrate]Check both files against the schema; migrates pre-2.0 keys in place unless --no-migrate
init-project FILE|DIR --code CODE [--display-name …] [--domain …] [--local-slug …] [--mode …] [--legacy] [--repo …] [--vercel-project …] [--studio-host …] [--force]Create wp2next.json from your defaults. --legacy is for a repo built by wp2next 1.x
forms-config [--project] [--out FILE | --check FILE]Write apps/web/src/lib/forms/config.ts from the public form IDs in wp2next.json; --check exits 1 when it is out of date

Exit codes: 0 ok, 1 invalid or missing, 2 usage error. Environment: WP2NEXT_CONFIG, XDG_CONFIG_HOME (environment variables).

secrets.py

Stores and hands out secrets through the backend in secrets.backend (1Password, Keeper, Bitwarden, Doppler, Infisical, macOS Keychain, Vercel, or a plain dotenv file). Values never appear in output or on the , and there is no get verb on purpose (asking for one is refused with a pointer to run). Setup per backend: Secrets.

Terminal
python3 <skill>/scripts/secrets.py {put KEY | has KEY | list | run -- CMD [ARG…] | env-file PATH | push-vercel [KEY…] | info | help}
VerbDoes
put KEYStore KEY. The value comes from stdin, or a hidden prompt on a terminal; never as an argument. Trailing newlines (LF or CRLF) and a leading UTF-8 byte-order mark are dropped
has KEYExit 0 if stored, 1 if not. Prints nothing
listKey names, one per line. Never values
run -- CMD [ARG…]Run CMD with every project secret in its environment, and exit with CMD's exit code (on Windows too, so the scan gates run under run still fail when they should). Preferred over env-file
env-file PATHWrite the secrets to a dotenv file for tools that need one (apps/web/.env.local, apps/studio/.env). Mode 600 on macOS and Linux; on Windows the file relies on your user folder's permissions. Refuses if git would commit PATH
push-vercel [KEY…]Copy keys (default all) to the linked Vercel project: Secret type in Production and Preview, Config in Development and for NEXT_PUBLIC_*
infoBackend, namespace and where values live. No values. Works outside a project
helpThe usage text. Works anywhere

Platform notes:

  • keychain is macOS only. On Windows or Linux it stops with a clear error; info says the keychain isn't available on this system.
  • Piping a value in on Windows: use . Windows PowerShell 5.1 turns non-ASCII text into ? when piping; use the hidden prompt for such values instead.
  • secrets.sh is now a three-line wrapper that runs secrets.py with the first Python 3.9+ it finds (python3, python, py), kept so older instructions still work where bash exists.

Exit codes: 0 ok, 1 not found (has) or a write was refused (env-file), 2 usage or configuration error; run returns the command's own exit code. Settings: WP2NEXT_SECRETS_* and friends, listed in environment variables.

fsutil.py

File helpers that behave the same on macOS, Linux and Windows. They replace shell tools that differ between systems or are missing on Windows (rsync, sed -i, sips, openssl rand, open, which), so the agent can give one command everywhere.

Terminal
python3 <skill>/scripts/fsutil.py copy-tree SRC DST [--include GLOB …] [--exclude GLOB …] [--prune-empty] [--dry-run]
python3 <skill>/scripts/fsutil.py replace PATH OLD NEW [--glob GLOB …] [--regex] [--exclude-dir NAME …] [--dry-run] [--require]
python3 <skill>/scripts/fsutil.py image-size FILE [FILE …] [--json]
python3 <skill>/scripts/fsutil.py random-hex [NBYTES]
python3 <skill>/scripts/fsutil.py open PATH|URL
python3 <skill>/scripts/fsutil.py which TOOL [TOOL …]
Sub-commandReplacesDoes
copy-treersync -aCopies a folder, skipping files whose size and modification time are unchanged. --include keeps only matching files; --exclude wins over it and also skips whole folders. A pattern without / matches a name; with / it matches the path relative to SRC (written with / on every system). Case-sensitive. --prune-empty creates only folders that receive a file. A folder or file it can't read (for example past Windows' 260-character limit) is reported as a warning; --strict makes that exit 1
replacesed -iLiteral text replacement in one file, or every text file under a folder (--glob limits which). --regex for Python regular expressions. Skips .git, node_modules, binary and non-UTF-8 files; keeps line endings and a byte-order mark. --require exits 1 when nothing matched
image-sizesipsPrints WIDTH HEIGHT from the file header: PNG, JPEG, GIF, WebP, AVIF/HEIC, BMP, SVG. With several files, each line ends with a tab and the name; --json for JSON
random-hexopenssl rand -hexPrints NBYTES (default 32) random bytes as hex, for example a revalidation secret
openopen / start / xdg-openOpens a file or URL with the default app (also from WSL)
whichwhich / wherePrints where each tool is. On Windows it honors PATHEXT (so pnpm finds pnpm.cmd) and warns when a python or py it finds doesn't run (the Microsoft Store stub; the Python install manager's working aliases in the same folder are fine)

A leading ~ in a path argument is expanded, since PowerShell and quoted arguments pass it through unchanged.

Exit codes: 0 ok, 1 failure or not found, 2 usage error.

version.py

Read-only. Reports facts that update, changelog and uninstall act on. Output is JSON unless noted.

Terminal
python3 <skill>/scripts/version.py {check,installed,method,latest,locations,compare,changelog,projects,release-check} ...
Sub-commandDoes
check [--offline] [--text]Installed version, install method and latest release (the default)
installed, methodOne of those facts
latest [--offline] [--timeout S]Newest published version
locations [--project-dir DIR]Every wp2next copy for this user
compare A BPrints -1, 0 or 1
changelog [--latest] [--version V | --since V | --installed] [--json]Print CHANGELOG entries
projects [--dir DIR] [--depth N]Find wp2next.json files and the wp2next version each was built with
release-check [--repo-root DIR]Maintainers: check SKILL.md, plugin.json and CHANGELOG.md agree before tagging (see maintainers)

Exit codes: 0 ok (even when the latest version is unknown), 1 release-check failed, 2 usage error. Environment: WP2NEXT_REPO, WP2NEXT_BRANCH, WP2NEXT_OFFLINE.

lighthouse.mjs

Lab scores (performance, , best practices, SEO, plus LCP, CLS and TBT) for a list of pages, mobile and desktop, keeping the median of several runs. Used for the WordPress baseline in phase 4 and every later comparison.

Terminal
node <skill>/scripts/lighthouse.mjs --base https://acme.local --label wp            # WordPress baseline
node <skill>/scripts/lighthouse.mjs --base http://localhost:3000 --label next       # Next production build
node <skill>/scripts/lighthouse.mjs --base https://example.com --label next --psi   # + real-visitor field data

Main options: --pages-ts FILE or --urls FILE, --runs N (default 3), --form mobile,desktop, --out DIR (default .wp2next/lighthouse), --psi, --chrome PATH, --insecure, --include-404, --no-vercel-bypass, --dry-run. Writes <out>/<label>-<YYYY-MM-DD>.json.

Needs lighthouse and chrome-launcher in the project (pnpm add -D -w lighthouse chrome-launcher) and a Chrome or Chromium. Lab runs can't measure INP; --psi adds PageSpeed when the site is public (key: PSI_API_KEY, optional). Exit codes: 0 ok, 1 every page failed, 2 usage error, 3 dependencies or Chrome missing. More: references/lighthouse.md⁠ (external site).

seo-scan.mjs

Extracts head tags, , H1s, image alt coverage and status codes per URL. In --compare mode it is the SEO parity gate between WordPress and the Next build.

Terminal
node <skill>/scripts/seo-scan.mjs --extract --base <url> [--urls <file|sitemap url>] [--label next]
node <skill>/scripts/seo-scan.mjs --compare --wp-base <url> --next-base <url> [--urls <file|sitemap url>] [--prelaunch]

Main options: --site-url, --prelaunch (the Next site is deliberately before launch), --ai-policy, --allow <file> (approved departures), --insecure, --max (default 500), --header / --wp-header 'Name: env:VAR', --out (default .wp2next/seo), --config. Exit codes: 0 no blockers, 2 blockers present, 1 failed. See SEO.

redirect-audit.mjs

Checks that old URLs still land somewhere sensible: follows one hop at a time and reports chains, loops, 404s, 5xx errors and trailing-slash or upper-case variants. With --crawl it also checks click depth, orphan pages and broken internal links.

Terminal
node <skill>/scripts/redirect-audit.mjs --base <url> [--urls f] [--gsc f.csv] [--redirects f.csv] \
  [--wp-patterns [--wp-export export.json]] [--old-slugs f.csv] [--out dir] [--label x] [--crawl] \
  [--no-variants] [--follow-host h] [--header 'Name: env:VAR'] [--ignore-https-errors] [--list-only]

Inputs can mix a URL list, a CSV export, a CSV of expected redirects and legacy WordPress URL patterns generated from the export. Default output folder: .wp2next/optimize. Exit codes: 0 no blocker or high findings, 2 blocker or high findings, 1 audit failed. The full option list is in the comment at the top of the file (--help only prints the summary).

compliance-scan.mjs

Automated gap scan for privacy, consent, accessibility (axe), form consent and security hygiene. It loads pages in a headless browser and never clicks or submits forms.

Terminal
node <skill>/scripts/compliance-scan.mjs --base <url> [--urls <file|sitemap url>] [--regions us,eu-uk] \
  [--industry health] [--label baseline] [--ignore-https-errors] [--modules <dir>]

Main options: --out (default .compliance/reports), --max (default 25), --privacy-pages (default 5), --config, --timeout, --settle, --no-axe, --header, --no-vercel-bypass, --site-env production|preview|development, --no-internal-routes. Regions and industry default to compliance.regions and compliance.industry in wp2next.json.

Needs playwright and @axe-core/playwright (in a wp2next repo, devDependencies of apps/web, plus playwright install chromium). Before a repo exists, install them in a scratch folder and pass --modules <that folder>.

content-audit.mjs

Read-only content checks over a or a Sanity export: stale and thin pages, duplicates, missing alt text, readability, old legal pages and phrases that often mark generated copy (a hint for an editor, never proof). The facts mode lists numbers, prices, names and links that appear in a rewrite but not in the original, so nothing invented gets saved.

Terminal
node <skill>/scripts/content-audit.mjs audit --input content/wordpress-site/export.json [--out report.md] [--json report.json]
node <skill>/scripts/content-audit.mjs audit --input sanity-export.tar.gz [--include-drafts]
node <skill>/scripts/content-audit.mjs facts --before original.txt --after rewrite.txt [--json out.json]

Audit options: --today, --stale-months (default 24), --legal-months (default 12), --thin-words (default 150), --grade (default 10), --site-host, --include-drafts, --types. Exit codes: 0 ok, 2 usage or input error, 3 (facts only) new facts found. See Content.

status-dashboard.py

Builds one self-contained HTML page for a migration from wp2next.json and the reports in the repo (, parity, compliance, SEO, content, brand sign-off, git). Missing data shows as "not run yet". Read-only except for the output file.

Terminal
python3 <skill>/scripts/status-dashboard.py [--project FILE] [--root DIR] [--out FILE] [--open] \
  [--before-label LABEL] [--after-label LABEL]

Default output: <repo>/.wp2next/status.html. Used by wp2next status --dashboard.

scrub-check.py

Checks text that is about to leave your machine (a feedback issue, a pull request, the completion report) for anything that identifies a client or leaks a secret: values from wp2next.json and your user config, email addresses, phone numbers, public IP addresses, token formats, home-folder paths, real-looking tag IDs and .local host names. Matches are masked in the output.

Terminal
python3 <skill>/scripts/scrub-check.py PATH [PATH …] [--project FILE|DIR] [--no-project] \
  [--user-config FILE] [--no-user-config] [--extra TERM] [--extra-file FILE] [--allow TERM] [--json] [--redact]
python3 <skill>/scripts/scrub-check.py --self-test

PATH may be a file, a folder or - for stdin. --redact (one input) prints the text with each finding replaced by a placeholder; run the check again on the result. Exit codes: 0 clean, 1 findings, 2 usage error.

report.py

The opt-in count of completed migrations (wp2next report). Nothing is sent automatically: you see the exact draft first, and send needs --yes.

Terminal
python3 <skill>/scripts/report.py check  [--project [FILE]] [--json]
python3 <skill>/scripts/report.py draft  [--project [FILE]] [--showcase --client-permission] [--source-type T] [--agent A] [--out DIR]
python3 <skill>/scripts/report.py send   [--project [FILE]] [--showcase --client-permission] [--resend] [--dry-run | --yes] [--via auto|gh|endpoint|print]
python3 <skill>/scripts/report.py record --status not-asked|declined|pending|sent [--mode anonymous|showcase] [--issue-url URL]
Sub-commandDoes
checkIs the migration complete? Phases 1–12 done, the production domain answers (not a *.vercel.app preview), parity signed off (or facelift mode), and the newest SEO parity report has no blockers
draftBuilds the payload and runs scrub-check.py on it. Anonymous fields only (wp2next version, mode, source type, page-count bucket, AI tool, month, random report ID). --showcase adds the site name and domain, and only with --client-permission
sendcheck + draft, then posts to report.endpoint (anonymous only), opens a GitHub issue with gh, or prints the body and a link. Refuses in CI, when already sent (use --resend), and without --yes or --dry-run
recordWrites report.status (and mode, issue URL) to wp2next.json

Exit codes: 0 ok, 1 check or scrub failed or refused, 2 usage error, 3 sending failed.

Other helpers

Some helpers live in skills/wp2next/references/⁠ (external site) because they are copied into each site's repo, not run from the . The main ones:

FilePurpose
gtm-container.pyWrites the Google Tag Manager import file and its setup checklist (docs/analytics/); used by tracking. --list-tags prints every tag key
export-wp.pyExports the WordPress content a port needs from Local's database into content/wordpress-site/export.json. Finds the connection itself: Local's socket on macOS and Linux when it exists, otherwise TCP on the port from the site's Database tab (read from Local's site config when possible; always TCP on Windows; in WSL it reads Local's config from the Windows side, /mnt/c/Users/<you>/AppData/Roaming/Local). The SQL goes to mysql on stdin, so big sites don't hit Windows' command-line length limit. Override with --host, --port, --socket, --mysql (the client; Local bundles one, mysql.exe on Windows), --user, --database, --local-data. --print-connection shows what it would use
capture.ts, parity.ts, compare.py, probe-diff.pyScreenshots and measurements for the pixel-parity checks
seed-upsert.tsWrites content into Sanity (needs SANITY_DEV_API_TOKEN, run under secrets.py run)
check-styles.mjsStyling guard that runs inside pnpm lint

scripts/check-noindex.mjs URL … (run from the skill, under secrets.py run --) prints <status> <X-Robots-Tag> <url> for each URL, sending the Vercel protection-bypass secret only to that URL's own host. It replaces a node -e one-liner so no quotes or || reach the command line.