WP-CLI Integration – Inspect and Maintain Your Database from the Terminal
ADBC 4.3.0 lets administrators use its shared abilities catalog from WP-CLI. Inspect autoload health, read cleanup counts, review tables, manage supported settings and request maintenance from a terminal or controlled script.
Use this integration in an SSH session on your host, a local WordPress development environment or an authorized maintenance script. It requires shell access to WordPress and an explicitly selected administrator.
1. Requirements and activation
- ADBC 4.3.0 or later.
- WordPress 6.9+, PHP 8.2+ and the PHP OpenSSL extension.
- An administrator account; a super administrator on WordPress Multisite.
- In DB Cleaner → Settings → Developer integrations, turn on Expose plugin abilities to enable the WP-CLI integration. Changes save automatically.
- WP-CLI with the official
wp abilitycommands. Runwp help abilityto check your installation. If missing, follow the official ability-command installation instructions and check the package’s WP-CLI requirement. ADBC does not install this package.
2. Free, Pro and Premium availability
Free: actions marked All editions work with the features available in Free. Paid actions return an upgrade invitation instead of paid-feature results or making changes. All four SQL tools require Pro or Premium.
Pro and Premium: actions marked Pro + Premium work in both editions. Premium provides get-remote-scan-balance; Pro provides get-pro-scan-balance. Edition availability is shown with each action.
Use wp ability list to discover actions, wp ability get to inspect their schemas, and wp ability run to execute them. Approve a destructive preview with wp adbc confirm.
3. Read access, writes and confirmation
Select an administrator with --user for each command. Read actions return information; write actions change database content, settings or maintenance state. Destructive actions require a preview and terminal confirmation.
The action examples mark requests that need a Preview. Actions marked No preview, such as changing automatic counts or cancelling a job, run when requested.
- Request a destructive action to receive an impact preview.
- Review the targets, warning, available row counts and size. Counts can be estimated or unavailable; size does not guarantee reclaimed disk space.
- Run
wp adbc confirm <confirmation_request_id> --user=admin, review the displayed impact and typeyes. A reviewed non-interactive script can approve that specific preview with--yes. - Check the result. If it returns a job ID, poll
adbc/get-jobuntil the job finishes.
Previews expire after five minutes and can be used once. Use the same site and selected administrator for preview and confirmation. If authorization changes or a SQL snapshot is no longer current, request and approve a fresh preview. Eligible items in a category cleanup can change before execution.
Keep a database backup before maintenance. Review the stored impact before confirming, including when using --yes.
4. SQL, cleanup jobs and change logs
query-databaseaccepts SELECT only;explain-querytakes a SELECT statement and returns its ordinary EXPLAIN plan. ADBC adds EXPLAIN for you; do not include it in the input. SQL tools require Pro or Premium. Statements are limited to 32 KiB. SELECT returns 100 rows by default, up to 1,000; truncation of large values or results is reported.execute-sqlsupports single-table INSERT … VALUES, UPDATE … WHERE and DELETE … WHERE on supported InnoDB tables with primary keys, up to 1,000 targeted rows. Unsupported SQL receives an explanation.- Raw SQL bypasses WordPress hooks, ADBC retention rules and native core-item protection. Review the exact query and targets before approving it.
- SQL writes return their results immediately. Cleanup jobs run in batches; poll
adbc/get-jobfor final counts. Native cleanup follows applicable cleanup-method and retention settings. - Losing administrator permissions stops further execution. Changed cleanup settings can also stop a job. Cancelling a job does not undo completed changes. If an outcome is unknown, verify the database before retrying.
- Review executed maintenance in Info & logs → Database changes. A logging warning does not mean a completed database change failed.
5. Choosing the installation and reading results
Run commands in the WordPress root or supply --path=/path/to/wordpress. For Multisite, select the intended site with --url=https://site.example where appropriate and use a super administrator. Verify the site before maintenance.
The confirmation helper sends warnings and questions to STDERR and JSON results to STDOUT. Command errors reported by the confirmation helper return a nonzero exit code. A result such as an upgrade invitation or a failed background job can still arrive as JSON; scripts must also inspect structured success, edition-upgrade, job-status and unknown-outcome fields. A background job being accepted does not mean cleanup has finished.
Turning off Expose plugin abilities disables these CLI commands and stops queued CLI work.
6. Example actions and full catalog
These examples cover common WP-CLI actions. Read returns information; Write changes data or settings. Actions marked Preview require terminal confirmation. Job means follow the returned job ID.
| Action | Access | Confirmation | Edition / execution |
|---|---|---|---|
adbc/get-autoload-health |
Read | Not required | All editions
Immediate |
adbc/get-tables-list |
Read | Not required | All editions
Immediate |
adbc/get-options-list |
Read | Not required | All editions
Immediate |
adbc/purge-items |
Write | Preview | All editions
Job |
adbc/query-database |
Read | Not required | Pro + Premium
Immediate |
adbc/execute-sql |
Write | Preview | Pro + Premium
Immediate |
For example, read autoload health with:
wp ability run adbc/get-autoload-health --user=admin --input="{}"
WP-CLI uses the same adbc/… abilities. See the complete abilities catalog for every action, its access, confirmation requirements and edition availability.