How to Run ADBC Commands with WP-CLI
Inspect autoload health from the terminal, prepare a cleanup preview, and approve it with ADBC’s terminal helper. Run these commands in the WordPress root or add --path=/path/to/wordpress. The examples with single-quoted JSON are for Bash or PowerShell. A Windows Command Prompt alternative is provided below.
1. Enable the integration
- Check ADBC 4.3.0+, WordPress 6.9+, PHP 8.2+ and OpenSSL. The CLI PHP installation must also meet the requirements.
- In DB Cleaner → Settings → Developer integrations, enable Expose plugin abilities.
- Run
wp help ability. If unavailable, follow the official ability-command installation instructions and check its WP-CLI requirement. The commands may need a separate package or a nightly WP-CLI build; updating a stable installation alone may not add them. ADBC does not install this package. - Select an administrator with
--user=admin, replacing admin with your login or ID. Multisite requires a super administrator; use--urlto select the intended site.
2. Discover actions and schemas
wp ability list --category=adbc --user=admin
wp ability get adbc/get-autoload-health --user=admin
Inspect the chosen ability’s input schema, then use its full name, such as adbc/get-options-list, with wp ability run.
3. Run a read-only check
wp ability run adbc/get-autoload-health --user=admin --input="{}"
Example response:
{
"success": true,
"message": "",
"data": {
"autoloaded_size": "7.54 KB",
"autoload_health": "good",
"autoload_limit": "781.25 KB"
}
}
Your values depend on the site and its configured threshold.
Other read-only examples:
wp ability run adbc/get-general-data --user=admin --input="{}"
wp ability run adbc/get-tables-list --user=admin --input="{}"
wp ability run adbc/get-options-list --user=admin --input='{"search":"my_plugin","searchIn":"name"}'
Windows Command Prompt: for JSON containing quoted field names, pass the input through stdin instead of using the single-quoted examples. This read-only example searches options:
echo {"search":"my_plugin","searchIn":"name"} | wp ability run adbc/get-options-list --user=admin --input=-
For larger inputs or other actions, save the exact JSON in a local file and use wp ability run adbc/ACTION --user=admin --input=- < input.json in Command Prompt. Replace adbc/ACTION with the chosen ability and review the file first.
4. Preview a cleanup
Purging expired transients can permanently remove matching data. Keep a backup and start on staging. Running the following command creates a preview only.
wp ability run adbc/purge-items --user=admin --input='{"itemsType":"expired_transients"}'
Example preview response:
{
"success": true,
"preview": true,
"targets": {
"itemsType": "expired_transients",
"affected_rows": 3,
"total_size": "236 B"
},
"approval_status": "awaiting_terminal_confirmation",
"confirmation_request_id": "ID_FROM_THE_PREVIEW",
"expires_in_seconds": 300
}
No deletion was confirmed or executed.
Read the targets, available counts, size, warning and confirmation_request_id. Counts may be estimates or unavailable, and size is not guaranteed reclaimed disk space. Use the ID returned by your own request instead of the placeholder above. It expires after five minutes and can be used once.
5. Confirm in the terminal
wp adbc confirm ID_FROM_YOUR_PREVIEW --user=admin
The helper displays the stored impact and asks you to type yes. Any other reply declines. Use the same administrator and selected site that created the preview.
A reviewed non-interactive script can explicitly approve its specific preview with:
wp adbc confirm ID_FROM_YOUR_REVIEWED_PREVIEW --user=admin --yes
--yes is approval of that specific stored preview. Do not use it in an unattended loop that blindly approves every action. It does not bypass expiry, edition checks or target validation.
6. Poll a returned job
wp ability run adbc/get-job --user=admin --input='{"id":"JOB_ID_FROM_RESULT"}'
Read its state and known counts until it finishes. To stop future work, use adbc/cancel-job with the same ID. A job being accepted is not a completed cleanup. Completed changes remain permanent after cancellation, and ADBC rechecks the initiating user’s authorization between units.
Executed maintenance appears in Info & logs → Database changes. A read-only check or preview does not create a maintenance change entry.
7. SQL examples in Pro/Premium
These read-only SQL tools require Pro or Premium:
wp ability run adbc/get-database-context --user=admin --input="{}"
wp ability run adbc/query-database --user=admin --input='{"sql":"SELECT 1 AS result","row_limit":1}'
wp ability run adbc/explain-query --user=admin --input='{"sql":"SELECT 1 AS result"}'
Pass SELECT SQL to adbc/explain-query; ADBC adds EXPLAIN. It describes how the database plans to run the SELECT and does not modify data.
An adbc/execute-sql request creates a write preview and uses the same terminal helper. SQL writes have a 1,000-row cap and require supported InnoDB tables with primary keys. They bypass WordPress hooks and ADBC retention/core-item rules; inspect tables and their structures before composing a write.
Troubleshooting
- Select an administrator explicitly: provide
--user; ADBC never chooses an administrator automatically. - Unknown ability or adbc command: check the plugin, switch, minimum versions, selected site and availability of
wp ability. - Preview expired or used: create a fresh preview, review it and confirm the new ID.
- JSON error: follow the schema’s names and types. Quoting differs between Bash, PowerShell and Command Prompt.
- Upgrade invitation: inspect structured results. Free’s paid-tool response performs no action.
- Unknown execution outcome: verify the database before retrying. Losing a connection does not prove rollback.