No php/wp-cli.php
encontramos estas linhas:
// Can be used by plugins/themes to check if WP-CLI is running or not
define( 'WP_CLI', true );
define( 'WP_CLI_VERSION', trim( file_get_contents( WP_CLI_ROOT . '/VERSION' ) ) );
define( 'WP_CLI_START_MICROTIME', microtime( true ) );
para que você possa verificar se WP_CLI
ou WP_CLI_VERSION
estão definidos.