← All articles

WordPress Development

Cursor for WordPress: A Practical Guide to AI Coding Agents in the Admin

What an AI coding agent actually does, why WordPress is harder for agents than a local repo, how to prompt one well, and which safety gates must exist before it touches production.

Updated 8 min read Mark Ashton

  • snippet engineer
  • ai
  • wordpress
  • security
Abstract cover artwork for Cursor for WordPress: A Practical Guide to AI Coding Agents in the Admin

Cursor changed what developers expect from AI. It does not just answer with a code block — it reads the project, plans, edits several files, runs checks, and fixes its own mistakes before handing back a result.

WordPress developers want the same thing, and there are now several ways to get it. This guide explains what separates an agent from a chatbot, why WordPress is a harder environment for agents than a local repository, when to use a local agent versus one inside the admin, how to write prompts that produce good WordPress code, and which safety gates are non-negotiable before an agent touches a live site.

Agent vs chatbot: the loop is the product

A chatbot takes a question and returns text. An agent runs a loop:

  1. Read context — the files, hooks, and settings relevant to the task
  2. Plan — break the request into steps
  3. Act — write or edit code, often across several files
  4. Check — run something that can fail: a linter, a test, a request
  5. Correct — read the failure and try again
  6. Hand off — present a finished change for approval

Model quality matters, but the loop matters more. A strong model with no way to run and check its code produces plausible code that fails on the first request. A decent model inside a loop with real feedback produces code that has at least executed once.

Why WordPress is hard for AI agents

A local repository gives an agent everything it needs: files on disk, a test runner, a terminal. WordPress customization is different in three ways.

The context is at runtime, not in files. Which hooks fire, which plugins are active, what WooCommerce version is installed, what the checkout fields are called — much of that only exists in a running site. An agent reading your snippet files alone is guessing.

The target is production. Snippets usually run on live sites. A local agent's mistake breaks a branch; a snippet agent's mistake can break a checkout.

PHP failures are total. A JavaScript error breaks one widget. A PHP fatal in a snippet can white-screen the front end. Any agent writing PHP for WordPress needs a way to execute the code somewhere safe before it goes live.

Your options in 2026

A local agent against a WordPress repo

Cursor or another coding agent, pointed at a theme or plugin repository and a local environment such as WordPress Playground or wp-env.

  • Best for: real plugins and themes — large codebases with a build step, tests, and a repository.
  • Weak at: knowing what is on the client's live site, and anything that lives in snippets rather than the repo.

Chat assistants inside snippet plugins

Most snippet plugins now include a "generate with AI" button.

  • Best for: a quick first draft of a small snippet.
  • Weak at: everything after the draft. You copy, paste, test, debug, and deploy yourself. There is no loop.

WordPress core's AI building blocks

WordPress 7.0 added an AI Client and provider connectors, building on 6.9's Abilities API. These are infrastructure for plugins to build on, not a coding agent in themselves.

An agent inside the admin

An agent that lives where the snippets live, can read the running site's context, and deploys through the same pipeline as a human. That is what we built the Snippet Engineer to be.

A practical split: use Cursor for plugin and theme repositories, and an in-admin agent for snippet work. They complement each other; they are not competitors.

How the Snippet Engineer works

The Snippet Engineer is an agent inside SnipVault that writes PHP, CSS, and JavaScript snippets, tests them, audits them, and deploys with your approval.

Four modes

  • Agent — autonomous multi-step builds, from plan to deploy approval
  • Chat — conversational help; the agent can read and edit snippets in the conversation
  • Ask — read-only questions: which hooks does this snippet register, what does this function do
  • Plan — the agent proposes an approach and waits for your go-ahead before writing anything

Plan mode is underrated. For anything touching payments or user data, read the plan first — it is much cheaper to correct a plan than a finished snippet.

Precise context with @-mentions

Type @ in the composer to reference a snippet, project, hook, or plugin. The agent gets exactly that code instead of a vague description. This is the WordPress equivalent of @-mentioning a file in Cursor, and it matters because WordPress context is so easy to get wrong.

Parallel subagents for multi-file work

A request such as "add an admin settings page with a PHP handler, styles, and a small script" fans out into two to four focused subagents writing PHP, CSS, and JavaScript at the same time. Each file saves as its own snippet when finished, and a live activity card shows progress. With project workspaces, the agent also knows the active project's folder structure and can scaffold a whole workspace.

Multiple model providers

You can switch between Anthropic, OpenAI, xAI, and Google Gemini models from the composer — mid-conversation, without losing context.

A worked example

Prompt:

Add a free-shipping progress notice to the WooCommerce cart: "You're $X away from free shipping" when the subtotal is below the free-shipping minimum, and hide it once the minimum is reached. Use the minimum from the active free-shipping method, don't hardcode it.

In Agent mode, the run looks like this:

  1. The agent plans: find the free-shipping minimum, hook into the cart, format the amount with WooCommerce's price helpers, escape the output.
  2. It writes a PHP snippet and a small CSS snippet in parallel.
  3. The PHP runs in an isolated sandbox request. If it fatals — say, it calls a WooCommerce function before WooCommerce has loaded — the agent reads the error and fixes it.
  4. The security audit scores the snippet. Unescaped output would raise the score; this one escapes it.
  5. You get an approval prompt with the plan, the code, the sandbox result, and the risk score. You approve, and it deploys.

The core of the PHP looks like what a careful developer would write:

<?php
defined( 'ABSPATH' ) || exit;

add_action( 'woocommerce_before_cart', function () {
	if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
		return;
	}

	$minimum = acme_free_shipping_minimum();
	if ( ! $minimum ) {
		return;
	}

	$remaining = $minimum - (float) WC()->cart->get_displayed_subtotal();
	if ( $remaining <= 0 ) {
		return;
	}

	printf(
		'<div class="acme-free-shipping-notice">%s</div>',
		wp_kses_post(
			sprintf(
				/* translators: %s: amount remaining */
				__( "You're %s away from free shipping.", 'acme' ),
				wc_price( $remaining )
			)
		)
	);
} );

The helper that reads the minimum from the configured shipping method lives in the same snippet. The point is not that the code is clever; it is that it has been executed, checked, and scored before you see it.

Writing prompts that produce good WordPress code

Agents get WordPress wrong in predictable ways: wrong hook, wrong scope, missing guards, hardcoded values. Good prompts head those off.

Name the outcome and the scope. "On the checkout page only, for logged-in wholesale customers" beats "add a checkout message."

Name the hook if you know it. "Use woocommerce_checkout_fields" saves a round of guessing. If you do not know it, ask in Ask mode first.

State what must not be hardcoded. Prices, IDs, thresholds, and emails should come from settings or options.

Say what else is on the site. "We use WooCommerce Subscriptions and a custom tax plugin" changes what is safe.

Reference existing code with @-mentions instead of describing it: "Follow the pattern in @woo-hide-company-field."

Ask for a plan on anything risky. Payments, user roles, email, and SQL deserve Plan mode.

A weak prompt: *"Make a discount."* A strong one: *"Give logged-in customers with the wholesale role 15% off cart items, excluding products in the gift-cards category. Show the discount as a separate cart fee line. Don't apply it to subscriptions."*

Reviewing what the agent wrote

An agent that sandboxes and audits its code is still not a reviewer. Before approving, check the things automated gates catch least reliably:

  • Is it scoped correctly? Code that should run on one page should not run on every request.
  • Capabilities and nonces on anything that changes data
  • Escaping on output and sanitization on input — the audit flags common misses, but read it anyway
  • Performance — no remote HTTP call or uncached query on every page load
  • Would you understand it in six months? If not, ask the agent to simplify and document it

The safety gates production needs

Cursor runs on your laptop against local files. A WordPress agent runs against production servers. That difference is why the gates below must be enforced on the server, not suggested in a prompt.

In the Snippet Engineer, every deploy must pass:

  • A sandbox probe — the code runs in an isolated request first, so fatal errors are caught before they reach visitors
  • A security risk score under the ceiling you configure — the agent cannot publish code that exceeds it
  • Human approval by default
  • Signed deploy tokens and an audit log for every write, deploy, rollback, and filesystem action
  • Filesystem path restrictions on what the agent can touch

If something breaks after a deploy, the change rolls back automatically. Autopilot mode removes the per-request approval prompt for lower-risk work, but the sandbox, risk ceiling, and audit log still apply.

Whatever tool you use, ask the same question: *can the agent publish code that failed a check?* If the answer is yes, the check is advice, not a gate.

Where an in-admin agent is the wrong tool

  • Large plugins or themes with a build process and tests belong in a repository, edited with a local agent and deployed through your normal pipeline.
  • Code that must be reviewed by a team before it exists anywhere should start in Git. Pair the agent with GitHub sync so its work lands in a branch and goes through a pull request.
  • Sites with strict change control may require that nothing is written on production at all. Run the agent on staging and promote through Git.

Getting started

  1. Start in Ask mode on an existing library: "Which snippets hook into checkout?" It is a low-risk way to see how the agent reads your site.
  2. Use Plan mode for your first real change, and read the plan critically.
  3. Set a conservative risk ceiling before you try Agent mode.
  4. Keep approvals on until you have a feel for its output. Consider autopilot only for low-risk CSS and content tweaks.

The Snippet Engineer is included in every SnipVault plan, and you can try it in the live demo without installing anything.

Next

Ready to upgrade your snippet workflow?

GitHub sync, the Snippet Engineer, and security auditing — in one WordPress plugin.