A development environment an agent can drive
A Local WordPress the Agent Can Reach
Three ways to give an agent a WordPress it can run commands against, the wp-config.php detail that breaks WP-CLI, and the official skill built for exactly this.
The previous module ended with a rules file telling the agent not to guess. This lesson gives it something better than a rule: an installation it can query. The difference shows up in the first minute of a real task. Without an install, an agent asked to check a hook has two options, and it takes the second one. It reasons from training data, or it writes a stub and tests against the stub.
That failure is documented rather than theoretical. In a recorded agent run, the agent
wrote its own implementations of wp_kses_post(),
get_block_wrapper_attributes() and esc_attr__(), tested its plugin
against them, and reported green. Its summary admitted the WP-CLI command could not be run
because no WordPress was present. The stubs happened to be right that time. The method cannot
tell you when they are wrong, which is the only thing verification is for.
An agent tests what it can execute
Give the agent an install and the loop changes shape. It can call
function_exists() for an API it is unsure about. It can activate the plugin and
read what WordPress says. It can query a post table to confirm the block attribute persisted.
It can fetch a front-end URL and look for its own markup in the response.
Those four checks are not sophisticated. They are the same checks you would run, and they have the property that matters: they can fail. A stub harness written by the model cannot fail in a way that teaches the model anything, because the stub and the belief behind it are the same artifact.
What was actually verified for this lesson
The commands in this lesson were run against a live WordPress 7.1.3 with
WP-CLI 2.12.0 on PHP 8.5.6 and Node 24.11.1. This course
targets the WordPress 7.0.x line, so treat version-specific output as reproducible on 7.1.x
and check anything narrower against your own install. Playground CLI requirements come from
the published wp-playground skill, not from a run here.
Three ways to get an install, and when each is right
Playground CLI runs WordPress in WebAssembly with SQLite, so there is no
database server and no Docker daemon to install. The official wp-playground skill
states its requirements plainly: WordPress 7.0 or newer, PHP 7.4 or newer, and Node.js 20.18 or
newer for the CLI. On launch it detects where your current code should live and mounts a plugin
into wp-content/plugins or a theme into wp-content/themes by
recognising plugin headers or a theme's style.css. That detection is the feature
that matters for agent work: the agent can run one command from inside your plugin directory
and get a working site with the plugin mounted.
wp-env is the WordPress-developer standard. It runs WordPress
and a database in Docker from a JSON configuration file, which makes it the right choice when
you need a database server you can connect to with a client, or when you want the site's PHP
version pinned to match production. Gutenberg's own AGENTS.md uses it and gives the
instruction that matters for an agent: check status first and only start the
environment if it is not already running.
A manual install is what you already have if you develop locally, and it is usually the fastest path to an agent that can run WP-CLI. It also has the sharpest edges, covered next.
| Option | What it needs | Best for | Main cost |
|---|---|---|---|
| Playground CLI | Node.js 20.18+, nothing else | Mount a plugin or theme and re-run a check in seconds | SQLite, disposable by design, not your production stack |
wp-env |
Docker, plus the config file | Real database, pinned PHP and WordPress versions, repeatable for a team | Docker resource use, per-project containers |
| Manual install | PHP, a database, WP-CLI | Existing local development; anything that uses production-shaped data | Its failure modes are yours to fix, and WP-CLI's errors are terse |
WP-CLI is the agent's interface to WordPress
An agent does not need a browser to verify most of what you will ask it to do. WP-CLI gives it a command for nearly everything, and the commands are stable and scriptable. The ones worth giving the agent in its rules file or its prompt are the boring ones:
wp core version # what am I actually running
wp plugin activate acme-notice # does it activate
wp plugin list --fields=name,status # what is active right now
wp eval 'var_dump( function_exists( "wp_kses_post" ) );'
wp post list --post_type=page --fields=ID,post_title
wp option get siteurl # which site am I pointed at
The wp eval line is the one to internalise, because it answers the exact
question an agent gets wrong most often. An agent that is unsure whether
get_block_wrapper_attributes() exists can ask WordPress instead of its own memory,
and the answer is a boolean from the running site. In the live install used for this lesson,
that check returns:
$ wp eval 'var_dump( function_exists( "wp_kses_post" ), function_exists( "get_block_wrapper_attributes" ) );'
bool(true)
bool(true)
Point the same check at a function that does not exist and the output is the same shape,
which is what makes it a usable gate: function_exists( "acme_sanitize_notice_message" )
returns false on that install. A stub cannot lie to you about that. WordPress can.
WP-CLI fails loudly, and the messages are worth knowing
Two failures show up in almost every local WordPress setup, and both look like something else.
A wp-config.php that never loads WordPress. WP-CLI bootstraps
WordPress by including your config file and expecting it to include WordPress in turn. If yours
defines the database constants and stops, WP-CLI reports a strange config file and refuses to
proceed. The fix is the last line of the sample config that people delete when they write their
own: require_once ABSPATH . 'wp-settings.php';.
Nothing works until WordPress is installed. Both
wp scaffold plugin and wp scaffold _s refuse to run against an
uninstalled tree, which kills the plan of scaffolding now and installing later. Run the install
first. While you are there, note that wp scaffold _s emits a classic PHP-template
theme with no theme.json and a style.css header still declaring
"Tested up to: 5.4" — a trap for module 3, but one worth knowing before you let an agent run
the command and call the result modern.
There is also environmental noise you should expect and tell the agent to ignore. On the
machine used here, WP-CLI 2.12.0 running on PHP 8.5.6 prints a deprecation notice from a
bundled library before every command. An agent that treats that notice as its failure signal
will chase a bug that is not there, so the rules file should name the noise or the agent should
be told to filter it with --quiet or an error-reporting level.
The official skill exists because this is the hard part
WordPress publishes an agent skill for exactly this job. The wp-playground
skill, in the WordPress/agent-skills repository, is documented as "a new AI agent
skill designed to run WordPress via the Playground CLI, giving agents a fast, repeatable way to
run WordPress and verify their work as they iterate". Its author's stated reason is the clearest
statement of the problem in this course: agents work better when they have a clear feedback
loop.
The skill also documents behaviour that matters for a real loop. Agents in testing
alternated between curl and Playwright to interact with the site, verify results,
apply fixes and re-verify. Helper scripts cut the time to a testable WordPress from about a
minute to a few seconds, and the Playground CLI can log in automatically for WP-Admin testing.
It ships with a guardrail worth repeating to your agent verbatim: Playground instances are
disposable and SQLite-backed, so never point them at production data.
The same repository carries a wp-env skill for the Docker path and a
wp-wpcli-and-ops skill whose opening procedure is to confirm the environment and
the blast radius before running anything that writes.
What the agent needs to be able to reach
Having an install is not the same as the agent being able to use it. Three specific constraints cause most of the failures.
Working directory. WP-CLI resolves the site from its current directory or a
--path argument. An agent running commands from your plugin's repository will not
find the site unless it is told where it is. Put the path in the rules file rather than in each
prompt.
Network. A sandboxed agent that cannot reach the network cannot run
wp plugin install, install Composer dependencies, or fetch the WordPress download.
Check the sandbox's allowed hosts before assuming a command failed for a code reason.
Database credentials. The database user needs to exist and the credentials in the config file need to be right, because the resulting error message rarely says "credentials". An agent will happily interpret a connection failure as a plugin bug and start editing your code. Giving it a known-good baseline is part of setup.
Build a WordPress your agent can reach, then prove it with output rather than with a configuration claim.
- Pick one of the three options. If you have no local WordPress, use Playground CLI.
- Write the site root and the installed version into a file at the top of your plugin
repository, in a form the agent will read. Add a line to
AGENTS.mdnaming the--pathto use. - Run these three checks yourself first, so you know what correct output looks like:
wp core version,wp plugin list --fields=name,status, and awp evalthat printsfunction_existsfor two functions you are confident exist. - Now ask the agent, in a session, to report the WordPress version, the active plugins, and whether three named functions exist. Then ask it which commands it ran and paste its answer into a file.
- Deliberately break the site's
wp-config.phpby removing therequire_once ABSPATH . 'wp-settings.php';line, ask the agent what is wrong, and restore the line afterwards.
Show the expected transcript, the diagnosis, and the reasoning
A working setup produces output like this, which is the real transcript from the install used for this lesson.
$ wp core version
7.1.3
$ wp plugin list --fields=name,status
name status
acme-blocks inactive
acme-notice active
akismet inactive
hello inactive
$ wp eval 'var_dump( function_exists( "wp_kses_post" ) );'
bool(true)
Step 4 is the test that tells you whether the environment is doing any work. An agent with
a reachable install answers with a version number and a plugin table, and its stated commands
match the output. An agent without one produces a version number it believes is current, a
plugin list invented from the repository's own files, and answers about
function_exists that are guesses wearing the costume of facts. Both answers read
the same in the chat window. Only one of them can be checked, which is why the lab asks for
the commands as well as the conclusions.
Step 5 is the diagnosis exercise, and the expected answer is specific. WP-CLI does not
treat your config file as a settings document; it treats it as the bootstrap and expects it to
load WordPress. When require_once ABSPATH . 'wp-settings.php'; is missing, the
command reports that this does not seem to be a WordPress installation, and WordPress never
loads. Everything downstream fails, which is why the message is confusing: it sounds like a
path or permissions problem when it is one deleted line.
The reasoning behind testing the agent rather than the environment is worth stating
plainly. You already know whether wp core version works, because you ran it.
What you do not know is whether the agent can reach it, and the difference between those two
facts is the entire premise of this module. A sandbox that blocks the network, a shell that
starts in the wrong directory, a PATH that lacks wp, and a
permission prompt the agent answers by giving up all produce the same observable behaviour in
the conversation: a confident answer and no trace of the command that produced it.
One trade-off worth naming. Playground and wp-env give you a disposable site
and the confidence to let an agent destroy it, which makes them the better choice when the
agent is exploring. Your existing local install is better when the task depends on real data,
plugin interactions, or a page builder's saved content. Neither is wrong; the mistake is
having no install at all and calling the result a workflow.
Official reference
The WordPress developer reference for what this lesson uses.
Progress
Mark this lesson done and it stays marked in this browser.