Use when working with WP-CLI (wp) for WordPress operations: safe search-replace, db export/import, plugin/theme/user/content management, cron, cache flushing, multisite, and scripting/automation with wp-cli.yml.
Add this skill
npx mdskills install WordPress/wp-wpcli-and-opsComprehensive WP-CLI operations guide with strong safety guardrails and clear workflows
1---2name: wp-wpcli-and-ops3description: "Use when working with WP-CLI (wp) for WordPress operations: safe search-replace, db export/import, plugin/theme/user/content management, cron, cache flushing, multisite, and scripting/automation with wp-cli.yml."4compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Requires WP-CLI in the execution environment."5---67# WP-CLI and Ops89## When to use1011Use this skill when the task involves WordPress operational work via WP-CLI, including:1213- `wp search-replace` (URL changes, domain migrations, protocol switch)14- DB export/import, resets, and inspections (`wp db *`)15- plugin/theme install/activate/update, language packs16- cron event listing/running17- cache/rewrite flushing18- multisite operations (`wp site *`, `--url`, `--network`)19- building repeatable scripts (`wp-cli.yml`, shell scripts, CI jobs)2021## Inputs required2223- Where WP-CLI will run (local dev, staging, production) and whether it’s safe to run.24- How to target the correct site root:25 - `--path=<wordpress-root>` and (multisite) `--url=<site-url>`26- Whether this is multisite and whether commands should run network-wide.27- Any constraints (no downtime, no DB writes, maintenance window).2829## Procedure3031### 0) Guardrails: confirm environment and blast radius3233WP-CLI commands can be destructive. Before running anything that writes:34351. Confirm environment (dev/staging/prod).362. Confirm targeting (path/url) so you don’t hit the wrong site.373. Make a backup when performing risky operations.3839Read:40- `references/safety.md`4142### 1) Inspect WP-CLI and site targeting (deterministic)4344Run the inspector:4546- `node skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs --path=<path> [--url=<url>]`4748If WP-CLI isn’t available, fall back to installing it via the project’s documented tooling (Composer, container, or system package), or ask for the expected execution environment.4950### 2) Choose the right workflow5152#### A) Safe URL/domain migration (`search-replace`)5354Follow a safe sequence:55561. `wp db export` (backup)572. `wp search-replace --dry-run` (review impact)583. Run the real replace with appropriate flags594. Flush caches/rewrite if needed6061Read:62- `references/search-replace.md`6364#### B) Plugin/theme operations6566Use `wp plugin *` / `wp theme *` and confirm you’re acting on the intended site (and network) first.6768Read:69- `references/packages-and-updates.md`7071#### C) Cron and queues7273Inspect cron state and run individual events for debugging rather than “run everything blindly”.7475Read:76- `references/cron-and-cache.md`7778#### D) Multisite operations7980Multisite changes can affect many sites. Always decide whether you’re operating:8182- on a single site (`--url=`), or83- network-wide (`--network` / iterating sites)8485Read:86- `references/multisite.md`8788### 3) Automation patterns (scripts + wp-cli.yml)8990For repeatable ops, prefer:9192- `wp-cli.yml` for defaults (path/url, PHP memory limits)93- shell scripts that log commands and stop on error94- CI jobs that run read-only checks by default9596Read:97- `references/automation.md`9899## Verification100101- Re-run `wpcli_inspect` after changes that could affect targeting or config.102- Confirm intended side effects:103 - correct URLs updated104 - plugins/themes in expected state105 - cron/caches flushed where needed106- If there’s a health check endpoint or smoke test suite, run it after ops changes.107108## Failure modes / debugging109110- “Error: This does not seem to be a WordPress installation.”111 - wrong `--path`, wrong container, or missing `wp-config.php`112- Multisite commands affecting the wrong site113 - missing `--url` or wrong URL114- Search-replace causes unexpected serialization issues115 - wrong flags or changing serialized data unsafely116117See:118- `references/debugging.md`119120## Escalation121122- If you cannot confirm environment safety, do not run write operations.123- If the repo uses containerized tooling (Docker/wp-env) but you can’t access it, ask for the intended command runner or CI job.124
Full transparency — inspect the skill content before installing.