WP Debug Toolkit Pro includes a WP-CLI integration under the wp dbtk command group — debug settings, query logging and recording, REST API discovery, endpoint calling, performance profiling, persistent endpoint annotations, and license management, all from the terminal.
Every command returns structured JSON that you can pipe, diff, save, or parse programmatically. This makes it useful in workflows where a browser-based debug panel isn’t practical: headless WordPress setups, scripted performance comparisons, CI pipelines, and AI-assisted development where your coding agent needs to profile or inspect endpoints on your behalf.
Toggle WordPress debug constants and read the debug log without editing wp-config.php:
$ wp dbtk debug status
Setting Value
WP_DEBUG ON
WP_DEBUG_LOG ON
WP_DEBUG_DISPLAY OFF
SAVEQUERIES OFF
Enhanced logging OFF
Log path /path/to/wp-content/debug.log
wp dbtk debug on # Enable WP_DEBUG + WP_DEBUG_LOG
wp dbtk debug off # Disable all debug constants
wp dbtk log read --level=error,fatal --since=1h # Read and filter debug.log entries
wp dbtk log read --plugin=woocommerce --format=json
wp dbtk log clear # Clear the debug.log file
wp dbtk log stats # Show file size and last modified time
Scan and search all registered REST routes across plugins, themes, and WordPress core:
$ wp dbtk api discover
Success: Discovered 690 routes across 17 sources.
$ wp dbtk api search "product" --format=table
Source Route Methods Description
wc /wc/v3/products GET, POST
wc /wc/v3/products/(?P<id>[\d]+) GET, POST, PUT, PATCH, DELETE
wc /wc/v3/products/categories GET, POST
wc /wc/v3/products/(?P<product_id>[\d]+)/variations GET, POST
...
Call any REST endpoint and optionally profile its performance. The --profile flag adds execution time, memory usage, query count, duplicate detection, and per-plugin attribution:
$ wp dbtk api call GET /wc/v3/products --params='{"per_page":3}' --profile
{
"status": 200,
"data": [ ... ],
"headers": {
"X-WP-Total": 20,
"X-WP-TotalPages": 7
},
"profile": {
"execution_time_ms": 19.63,
"memory": {
"delta_mb": 0.18,
"peak_mb": 117.79
},
"queries": {
"total": 22,
"slow": 0,
"duplicates": 12,
"by_type": { "SELECT": 22 },
"total_time_ms": 18.67,
"by_component": {
"wordpress-core": 19,
"woocommerce": 3
},
"slowest": []
},
"php_errors": []
}
}
Three profiling modes are available:
| Flag | What it captures |
|---|---|
| –profile or –profile=full | Timing, memory, full query analysis, PHP errors |
| –profile=queries | Timing, memory, query analysis (no PHP error capture) |
| –profile=summary | Timing, memory, query count only |
Query analysis works regardless of how SAVEQUERIES is defined at WP-CLI bootstrap — 1.2.0 captures queries through a filter-based mechanism instead of relying on SAVEQUERIES.
api discover captures structure — parameter names, types, methods. It doesn’t capture behavior. api edit lets you attach durable, method-level notes to any route: description, safety classification (read-only, mutates-data, destructive, unknown), auth notes, return shape, tags, and a verification marker. Annotations are stored separately from the discovered schema, so running discover again never wipes them.
wp dbtk api edit /wc/v3/orders --method=POST \
--description="Create a new order" \
--safety=mutates-data \
--auth-note="Requires shop_manager or administrator" \
--returns="Created order object with id and status"
wp dbtk api list --annotated-only # Only routes with saved annotations
wp dbtk api list --tag=orders # Filter by annotation tag
Three commands turn annotations into a portable knowledge base your agent can inherit across sessions or sites:
wp dbtk api bootstrap --source=woocommerce # Markdown brief for a fresh agent session
wp dbtk api export --source=woocommerce --annotated-only > wc-annotations.json
wp dbtk api import wc-annotations.json # Merge into another site (or --mode=replace-source)
Profiling captures a single endpoint call. Recording captures every database query across multiple page loads — useful when you need to test a full user flow in the browser:
wp dbtk query-log start --tag=checkout-test # Until stopped (auto-stops after 1h)
# Browse the site, test checkout, interact with pages...
wp dbtk query-log stop # Stop recording
wp dbtk query-log read --tag=checkout-test --summary # Per-page overview: queries, timing, memory, score
wp dbtk query-log read --tag=checkout-test --memory # Memory usage per page
wp dbtk query-log read --tag=checkout-test --component=my-plugin --slow
You can also enable always-on query logging directly:
wp dbtk query-log on # Install db.php drop-in and enable capture
wp dbtk query-log stats # Show enabled status, log path, size, entry count
wp dbtk query-log clear # Clear the query log
wp dbtk query-log off # Disable and remove db.php drop-in
Install and manage the standalone log viewer from the terminal:
wp dbtk viewer setup --password=MySecurePass123
wp dbtk viewer status
wp dbtk viewer remove
Activate, check, and deactivate your license from the terminal:
wp dbtk license activate XXXX-XXXX-XXXX-XXXX
wp dbtk license status
wp dbtk license deactivate
Using an AI coding assistant? You can ask your agent to run these commands for you. Install the skill with npx skills add WP-Debug-Toolkit/wpdt-cli and see the AI Assistant Guide.