Complete WP-CLI Command Reference (Cache, Preload, Object Cache, DB & MCP)
Automate cache purges, URL diagnostics, bounded sitemap preloads, 7-driver object cache probes, dry-run database cleanups, and MCP token/checkpoint operations from SSH or CI/CD.
- Provides 8 complete
wp kadicachecommand families (status,purge,repair,diagnose,preload,object-cache,db, andmcp) sharing the exact same safety guards as WP Admin. - Every command supports
--format=jsonwith deterministic exit codes (0on success,1viaWP_CLI::halt(1)on error)—built for GitHub Actions, GitLab CI, Deployer, Trellis, and cron scripts. - Supports WordPress Multisite (
--url=<subsite>and--networkflags onstatus,purge --network --all,repair --network, andobject-cache flush --blog=<id>). - Enforces capability checks (
manage_options/manage_network_options) when--useris passed and checks cache directory ownership (cache_directory_ownership) before mutating local storage.
Automating KadiCache in SSH, Composer/Bedrock & CI/CD Pipelines#
DevOps engineers, managed-hosting SREs, and agencies deploying WordPress updates via GitHub Actions or Deployer need deterministic CLI commands that never trigger HTML redirects, never swallow failures with exit code 0, and never corrupt file ownership when invoked under the wrong Linux user.
KadiCache registers all CLI commands inside Plugin.php across five dedicated classes (CacheCli.php, PreloadCli.php, ObjectCacheCli.php, DatabaseCli.php, and McpCli.php). Every command outputs human-friendly tables by default and machine-parseable JSON when --format=json is passed.
1. Core Cache Status, Purge, Repair & URL Diagnosis (CacheCli.php)#
| Command & Flags | Purpose & Exact Behavior |
|---|---|
wp kadicache status [--network] [--page=<n>] [--search=<q>] [--format=json] | Reports enabled, owner (local vs host), early_cache readiness, early_reason, disk storage usage, preload queue counts, active integrations (multilingual, cloudflare, varnish, host), visits_24h, and runtime_reasons. With --network, lists Multisite subsites! |
wp kadicache purge --all [--format=json] | Purges the entire current site across local FileCache, Cloudflare, Varnish, and host bridges (verifying cache_directory_ownership first so root SSH runs never break PHP-FPM permissions!) |
wp kadicache purge <url>... [--format=json] | Surgically purges one or more same-site URLs (wp kadicache purge https://example.com/ https://example.com/shop/) |
wp kadicache purge --network --all [--format=json] | Queues a network-wide Multisite purge (NetworkLifecycle::start('purge')) |
wp kadicache repair [--network] [--format=json] | Re-verifies and repairs wp-content/advanced-cache.php, early-config.php, WP_CACHE, or network routing maps (PostSettings::repairManually()) |
wp kadicache diagnose <url> [--format=json] | Runs the full PageDiagnostic inspector on a same-site URL—returning Desktop & Mobile cache states, anonymous loopback HTTP headers, cookies, and script advice! |
2. Sitemap Preload & Warmup Queue Commands (PreloadCli.php)#
# Inspect queue counts (queued, warmed, skipped, failed) and lock state
wp kadicache preload status --format=json
# Start, pause, or resume background Action Scheduler warmup
wp kadicache preload start
wp kadicache preload pause
wp kadicache preload resume
# Execute one bounded warmup batch immediately in the current CLI process
wp kadicache preload run --url=https://example.com --format=json3. Persistent Object Cache & Autoload Bloat Analyzer (ObjectCacheCli.php)#
| Command & Flags | Purpose & Exact Behavior |
|---|---|
wp kadicache object-cache status [--format=table|json] | Displays dropin_state, provider, connected, driver, serializer, compression, prefetch, split_alloptions, and live hit_ratio |
wp kadicache object-cache info [--format=table|json] | Runs a live backend latency probe (ms) and runs AutoloadAnalyzer::inspect() to list your largest autoloaded wp_options rows by byte size and plugin source! |
wp kadicache object-cache enable [--driver=<driver>] [--force-takeover] [--format=json] | Probes backend and atomically installs wp-content/object-cache.php (driver: auto, relay, phpredis, redis-socket, memcached, apcu, sqlite, file) |
wp kadicache object-cache flush [--blog=<id>] | Performs an O(1) epoch flush—or flushes only a single Multisite subsite (--blog=3) without evicting sibling sites! |
wp kadicache object-cache disable | Safely removes wp-content/object-cache.php (only if owned by KadiCache) |
4. Safe Database Cleanup & Dry-Run Inspection (DatabaseCli.php)#
# Show candidate counts across all 8 categories without deleting anything
wp kadicache db status --format=table
# Preview exact counts for specific categories (--dry-run queues zero deletions)
wp kadicache db clean --items=revisions,auto_drafts,trash_posts,trash_comments,spam_comments,transients,actions,orphans --dry-run
# Queue bounded background cleanup using saved selection or explicit --items
wp kadicache db clean --items=revisions,transients,actions --format=json5. AI MCP Token, Audit & Checkpoint Commands (McpCli.php)#
# Show MCP endpoint URL, HTTPS readiness, token count, and checkpoint count
wp kadicache mcp status --format=json
# Mint a scoped SHA-256 token expiring in 30 days and print Claude CLI snippet
wp kadicache mcp mint --label="CI Deploy Bot" --scopes=read,operate --days=30
# List active tokens & OAuth grants, view audit logs, revoke, or roll back!
wp kadicache mcp tokens --format=table
wp kadicache mcp activity --limit=25
wp kadicache mcp rollback latest
wp kadicache mcp revoke <token_id_or_og_grant_id>
wp kadicache mcp disconnect-allProduction Post-Deploy Hook Example (GitHub Actions / Deployer)#
#!/usr/bin/env bash
set -euo pipefail
# Always execute as the web/PHP-FPM user (e.g. www-data) so cache file ownership stays clean
wp kadicache repair --format=json
wp kadicache purge --all --format=json
wp kadicache preload start --format=json
wp kadicache diagnose "$(wp option get home)/" --format=jsonMultisite Fleet Maintenance & Cron Automation Examples#
When managing a 40-subsite WordPress Multisite installation or running scheduled nightly verification from system systemd timers / cron:
- Network-Wide Health Table (
--network): Runwp kadicache status --network --page=1to view a clean ASCII table (blog_id,url,state,enabled,early,updated_at) across your subsites, or pass--format=jsonto pipe straight intojq/ Datadog / Prometheus. - Targeted Single-Subsite Object Cache Flush (
--blog=<id>): Runningwp kadicache object-cache flush --blog=7bumps only Subsite#7’s cache epoch without evicting cached database queries on the other 39 subsites! - Impersonating Specific Admin Roles (
--user=<login>): When a deployment script passes--user=editor_jane,CacheCli::authorize()enforces real WordPress capability checks (manage_optionson single-site;manage_network_optionson--network) so least-privilege automation stays airtight.
Frequently Asked Operational Questions
Do KadiCache WP-CLI commands return non-zero exit codes when an operation fails?
How do I target a specific subsite on WordPress Multisite via WP-CLI?
Does wp kadicache purge --all also clear Cloudflare and Varnish?
Can I safely test wp kadicache db clean without deleting any database rows?
Why does wp kadicache mcp mint only display the raw token string once?
Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.