A new command landed in WP-CLI a few days ago, called shell. It was inspired by an older project called wpshell.

When you run wp shell, a REPL will start, in which you can run any WordPress function.

The major advantage over wp eval and wp eval-file is that it’s interactive: you immediately see the result of the previous command; it’s also stored in the special $_ variable, which you can use in the next command and so on.

Here’s a contrived example session:

scribu@air:~/wp/core$ wp shell
Type "exit" to close session.
wp> get_bloginfo('wpurl')
wp> $_ . '/feed/'
wp> exit

wp shell will be available in the 0.7 release of WP-CLI, but if you want to try it out right now, clone the latest version from github. If you have suggestions for making it better, don’t hesitate to open issues and pull requests.