wp_cli
Execute WP-CLI commands on configured WordPress sites, targeting local Docker containers or production environments via Terminus or SSH, with destructive command protection.
Instructions
Run a WP-CLI command against a configured WordPress site's local Docker container (default) or its remote production environment. Configuration is read from /.serena/wp-cli.conf, which may define one or MANY sites. Pass the WP-CLI command WITHOUT a leading 'wp' (e.g. args='plugin list --status=active'). When the conf defines multiple sites, pass 'site' = the site's top-level folder name; omit it to use the configured DEFAULT_SITE or the sole site. The production TRANSPORT is chosen by the site's conf: TERMINUS_SITE routes over terminus remote:wp (run on the host, Pantheon/Terminus); otherwise REMOTE_SSH routes over WP-CLI --ssh. For Terminus sites the environment is TERMINUS_ENV (conf default) unless overridden per-call with the 'env' arg. On production, destructive commands (db reset/import, post/user delete, search-replace without --dry-run, plugin/theme delete, etc.) are blocked unless confirm=true and the guard is enabled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | Terminus environment override (e.g. 'dev', 'test', 'live') for target='production' on a Terminus site. Omit to use the site's TERMINUS_ENV default. Ignored for SSH and local targets. | |
| args | Yes | The WP-CLI command and its flags, without the leading 'wp'. Example: 'option get blogname' or 'plugin list --status=active --format=json'. | |
| site | No | Which configured site to target — matches a [site:NAME] section in wp-cli.conf. Omit to use DEFAULT_SITE, or the sole site if only one is configured. | |
| target | No | Where to run. 'local' = Docker container (default). 'production' = remote environment; transport (Terminus vs WP-CLI --ssh) is chosen by the site's conf. | local |
| confirm | No | Required to run a destructive command on production when the guard is enabled. Default: false. |