I have updated my Playground Step Library (which I had written about before)–the tool that allows you to use more advanced steps in WordPress Playground–so that it can now also be used programmatically: It is now an npm package: playground-step-library.
Behind the scenes this actually dominoed into migrating it to TypeScript and restructuring the code so that it now both powers the Web UI and the npm package.
Having those custom steps available now makes even more sense that the Playground CLI is production ready and you can use it for things like testing your WordPress plugin with Playwright, see this presentation Building Automated Tests with WordPress Playground from WordCamp Europe 2025 by my colleague Berislav “Bero” Grigicak.
In this example you can see a blueprint JSON that contains steps setSiteName
and addPage
that don’t exist in the library of steps of Playground. At the time of writing there are 36 custom steps with the goal of making it easier to do things that can be done with a blueprint already but need some complexity. See in the example below how creating a page can be done with runPHP
and wp_insert_post
but it’s visually easier with a step addPage
.
import PlaygroundStepLibrary from 'playground-step-library';
const compiler = new PlaygroundStepLibrary();
const blueprint = {
steps: [
{
step: 'setSiteName',
sitename: 'My Site',
tagline: 'A WordPress Playground demo'
},
{
step: 'addPage',
title: 'Welcome',
content: '<p>Welcome to my site!</p>'
}
]
};
const compiledBlueprint = compiler.compile(blueprint);
console.log(compiledBlueprint);
Which turns this into a valid blueprint:
{
"steps": [
{
"step": "setSiteOptions",
"options": {
"blogname": "My Site",
"blogdescription": "A WordPress Playground demo"
}
},
{
"step": "runPHP",
"code": "\n<?php require_once '/wordpress/wp-load.php';\n$page_args = array(\n\t'post_type' => 'page',\n\t'post_status' => 'publish',\n\t'post_title' => 'Welcome',\n\t'post_content' => '<p>Welcome to my site!</p>',\n);\n$page_id = wp_insert_post( $page_args );"
}
]
}
You can then pass this blueprint to playground CLI to run it (see other demos by my colleague Fellyph):
import { runCLI, RunCLIServer } from '@wp-playground/cli';
await runCLI({
command: 'server',
login: true,
blueprint: compiledBlueprint
});
You can also conveniently try it out in WordPress Playground with this link (and also view in the Step Library UI).
Finally, in the repo there are a number of examples that you can browse and I created a little screen recording of a few of them:

Happy coding!