wp-cli –require to load a file before the command

A one-off maintenance script usually gets written as a file and run with wp eval-file, which works until it needs to define a class or register a command of its own.

wp --require=tools/shop-commands.php shop reindex --all

# or permanently, in wp-cli.yml
# require:
#   - tools/shop-commands.php

--require loads the file after WordPress has booted and before the command runs, which is where a custom command class has to be defined. Putting it in wp-cli.yml at the project root makes the commands available to everyone without a flag, and keeps them out of a plugin — which matters because a maintenance command is usually not something a site should carry in production.