WordPress WP-CLI and Ops Skill
Overview
Systematic review guidance for WordPress operational workflows centered on WP-CLI. Core principle: operational commands should be explicit about scope, environment, and side effects before they touch data or execute production work. Review covers custom CLI commands, search-replace plans, multisite targeting, cron and cache operations, maintenance scripts, and deployment-time automation.
When to Use
Use when:
- Reviewing custom WP-CLI commands or command classes
- Auditing shell scripts or docs that run
wp commands
- Planning safe search-replace or migration operations
- Checking multisite or network-wide operational steps
- Reviewing cron, cache, export, import, or maintenance workflows
Don't use for:
- General plugin architecture with no operational surface
- Performance tuning without an ops workflow
- Playground-only setup flows (use wp-playground-development)
- Static analysis configuration (use wp-phpstan-review)
Code Review Workflow
Identify the operational surface
- Custom
WP_CLI::add_command() registrations
- Project docs with
wp command examples
- Deployment scripts, CI jobs, or maintenance scripts
- Multisite runbooks or migration plans
Check scope and targeting first
- Is the command site-specific, network-wide, or environment-dependent?
- Are
--url, --path, or explicit table targets needed?
- Does the workflow rely on assumptions about the current install?
Review safety and reversibility
- Dry-run support where possible
- Confirmation or logging for destructive steps
- Backup/export step before high-risk mutations
- Clear distinction between inspection and mutation commands
Review command implementation
- Input validation and argument handling
- Reasonable defaults
- Useful success/error output
- No hidden writes during read-only commands
Classify findings
- CRITICAL: destructive operation without safeguards, wrong multisite scope, production-hostile search-replace, unvalidated CLI input causing data loss
- WARNING: ambiguous environment targeting, brittle shell examples, missing dry run, weak logging, long-running tasks without chunking
- INFO: could document aliases, improve command UX, or separate read vs write commands
File-Type Specific Checks
Custom WP-CLI Commands
- CRITICAL: Write commands with no argument validation or capability/context checks
- WARNING: Command names or synopsis do not communicate side effects
- WARNING: Command mixes read-only inspection with mutation
- INFO: Could return structured output or clearer status messages
Search-Replace and DB Operations
- CRITICAL:
wp search-replace examples without --dry-run or scope limits
- CRITICAL: Network-wide replace with no explicit
--network review or table targeting
- WARNING: No
--skip-columns=guid when replacing URLs
- WARNING: Regex search-replace used casually without performance warning
Multisite Ops
- CRITICAL: Commands assume current site while touching network-wide state
- WARNING: Missing
--url for site-specific tasks in multisite
- WARNING: Site creation/deletion workflows without rollback notes
- INFO: Could document
wp site / wp super-admin implications more clearly
Automation and Maintenance Scripts
- WARNING: Uses
wp eval/wp eval-file where a custom command would be safer
- WARNING: Long maintenance job with no batching or progress output
- INFO: Could split inspection, export, and mutation into separate steps
Search Patterns for Quick Detection (OPS-21)
Use these rg commands to locate WP-CLI and ops workflows fast.
Command Discovery
rg -n "WP_CLI::add_command|class .* extends WP_CLI_Command" . -g '*.php'
rg -n "\bwp [a-z0-9:-]+" . -g '*.{md,sh,yml,yaml,json}'
High-Risk Mutations
rg -n "wp search-replace|wp db reset|wp db drop|wp site delete|wp plugin deactivate" . -g '*.{md,sh,yml,yaml}'
rg -n "wp eval|wp eval-file" . -g '*.{md,sh,yml,yaml}'
Multisite and Scheduling
rg -n "wp site|wp super-admin|--network|--url=" . -g '*.{md,sh,php,yml,yaml}'
rg -n "wp cron|wp cache|wp transient" . -g '*.{md,sh,php,yml,yaml}'
Reference Files
references/command-patterns.md - Custom command design, argument handling, and operational UX
references/multisite-and-search-replace.md - Multisite scope, wp site, and safe wp search-replace usage
references/automation-and-safety.md - Deployment scripts, maintenance jobs, batching, and rollback thinking
references/sample-wp-cli-command.php - Sample custom command with validation, dry run, and batching
references/sample-maintenance-runbook.md - Sample runbook with inspect, dry run, execute, and verify stages
Output Format (OPS-23)
For each finding include:
- Severity:
CRITICAL, WARNING, or INFO
- File and line number
- Operational risk summary
- Why it matters for WP-CLI or runtime operations
- Recommended safer pattern
If no issues are found, say so clearly and mention any residual operational gaps such as missing dry runs, weak logging, or limited rollback documentation.
1---2name: wp-wpcli-and-ops-23description: WordPress WP-CLI and operations review guidance. Use when reviewing WP-CLI commands, search-replace plans, multisite operations, cron or cache maintenance, deployment scripts, operational runbooks, CLI automation, or when user mentions "WP-CLI", "search-replace", "multisite ops", "wp cron", "wp db", "deployment script", "maintenance task", "CLI command", or "ops review". Helps review command safety, environment targeting, multisite scope, automation reliability, and operational blast radius in WordPress codebases and runbooks.4---56# WordPress WP-CLI and Ops Skill78## Overview910Systematic review guidance for WordPress operational workflows centered on WP-CLI. **Core principle:** operational commands should be explicit about scope, environment, and side effects before they touch data or execute production work. Review covers custom CLI commands, search-replace plans, multisite targeting, cron and cache operations, maintenance scripts, and deployment-time automation.1112## When to Use1314**Use when:**15- Reviewing custom WP-CLI commands or command classes16- Auditing shell scripts or docs that run `wp` commands17- Planning safe search-replace or migration operations18- Checking multisite or network-wide operational steps19- Reviewing cron, cache, export, import, or maintenance workflows2021**Don't use for:**22- General plugin architecture with no operational surface23- Performance tuning without an ops workflow24- Playground-only setup flows (use wp-playground-development)25- Static analysis configuration (use wp-phpstan-review)2627## Code Review Workflow28291. **Identify the operational surface**30 - Custom `WP_CLI::add_command()` registrations31 - Project docs with `wp` command examples32 - Deployment scripts, CI jobs, or maintenance scripts33 - Multisite runbooks or migration plans34352. **Check scope and targeting first**36 - Is the command site-specific, network-wide, or environment-dependent?37 - Are `--url`, `--path`, or explicit table targets needed?38 - Does the workflow rely on assumptions about the current install?39403. **Review safety and reversibility**41 - Dry-run support where possible42 - Confirmation or logging for destructive steps43 - Backup/export step before high-risk mutations44 - Clear distinction between inspection and mutation commands45464. **Review command implementation**47 - Input validation and argument handling48 - Reasonable defaults49 - Useful success/error output50 - No hidden writes during read-only commands51525. **Classify findings**53 - **CRITICAL:** destructive operation without safeguards, wrong multisite scope, production-hostile search-replace, unvalidated CLI input causing data loss54 - **WARNING:** ambiguous environment targeting, brittle shell examples, missing dry run, weak logging, long-running tasks without chunking55 - **INFO:** could document aliases, improve command UX, or separate read vs write commands5657## File-Type Specific Checks5859### Custom WP-CLI Commands6061- CRITICAL: Write commands with no argument validation or capability/context checks62- WARNING: Command names or synopsis do not communicate side effects63- WARNING: Command mixes read-only inspection with mutation64- INFO: Could return structured output or clearer status messages6566### Search-Replace and DB Operations6768- CRITICAL: `wp search-replace` examples without `--dry-run` or scope limits69- CRITICAL: Network-wide replace with no explicit `--network` review or table targeting70- WARNING: No `--skip-columns=guid` when replacing URLs71- WARNING: Regex search-replace used casually without performance warning7273### Multisite Ops7475- CRITICAL: Commands assume current site while touching network-wide state76- WARNING: Missing `--url` for site-specific tasks in multisite77- WARNING: Site creation/deletion workflows without rollback notes78- INFO: Could document `wp site` / `wp super-admin` implications more clearly7980### Automation and Maintenance Scripts8182- WARNING: Uses `wp eval`/`wp eval-file` where a custom command would be safer83- WARNING: Long maintenance job with no batching or progress output84- INFO: Could split inspection, export, and mutation into separate steps8586## Search Patterns for Quick Detection (OPS-21)8788Use these `rg` commands to locate WP-CLI and ops workflows fast.8990### Command Discovery9192```bash93rg -n "WP_CLI::add_command|class .* extends WP_CLI_Command" . -g '*.php'94rg -n "\bwp [a-z0-9:-]+" . -g '*.{md,sh,yml,yaml,json}'95```9697### High-Risk Mutations9899```bash100rg -n "wp search-replace|wp db reset|wp db drop|wp site delete|wp plugin deactivate" . -g '*.{md,sh,yml,yaml}'101rg -n "wp eval|wp eval-file" . -g '*.{md,sh,yml,yaml}'102```103104### Multisite and Scheduling105106```bash107rg -n "wp site|wp super-admin|--network|--url=" . -g '*.{md,sh,php,yml,yaml}'108rg -n "wp cron|wp cache|wp transient" . -g '*.{md,sh,php,yml,yaml}'109```110111## Reference Files112113- `references/command-patterns.md` - Custom command design, argument handling, and operational UX114- `references/multisite-and-search-replace.md` - Multisite scope, `wp site`, and safe `wp search-replace` usage115- `references/automation-and-safety.md` - Deployment scripts, maintenance jobs, batching, and rollback thinking116- `references/sample-wp-cli-command.php` - Sample custom command with validation, dry run, and batching117- `references/sample-maintenance-runbook.md` - Sample runbook with inspect, dry run, execute, and verify stages118119## Output Format (OPS-23)120121For each finding include:1221231. Severity: `CRITICAL`, `WARNING`, or `INFO`1242. File and line number1253. Operational risk summary1264. Why it matters for WP-CLI or runtime operations1275. Recommended safer pattern128129If no issues are found, say so clearly and mention any residual operational gaps such as missing dry runs, weak logging, or limited rollback documentation.