Sometimes a WP-CLI command just stops with “Error establishing a database connection” or prints nothing. The global --debug flag shows what happened on the way.
Add it to any command:
wp plugin list --debug
Two things change. All PHP errors, warnings and notices are shown, also the ones WP_DEBUG would hide. And WP-CLI explains its own startup: which config files it read, which WordPress path it found, how long each step took. The extra lines start with Debug and go to standard error, so the normal output stays clean if you pipe it somewhere.
When the output is long, filter it:
wp plugin list --debug 2>&1 | grep -i -E 'warning|error|fatal'
I’d reach for it in three cases: WP-CLI picks up the wrong wp-cli.yml, a plugin throws a fatal error only on the command line, or a command is mysteriously slow and you want the timings.
There is a debug key for wp-cli.yml as well, but I would not leave that on. The noise drowns out real output, and notices from plugins can include file paths and values you don’t want in a log that others read.
Further reading: WP-CLI global parameters