WordPress AI Prompt Builder
Get WordPress code that escapes its output, uses hooks and does not touch core. Pick what you are building, describe the behaviour, and this writes the prompt with the conventions an AI otherwise ignores.
Your prompt
Read what comes back before you run it. An AI that does not know your site will guess at hook names and table prefixes.
Why WordPress code from an AI needs watching
Ask any model for “WordPress code” and it will write something that runs. It will also, more often than not, echo a variable straight into the page without escaping it, reach for jQuery because most of its training data did, suggest editing a plugin file directly, and write a hook callback with no default on its second parameter.
None of that is incompetence. It is an average of fifteen years of tutorials, and a lot of those tutorials were wrong. Naming the rules in the prompt is what moves the output from average to current.
The rules this prompt enforces
- Escape at the point of output, with the right function for the context rather than esc_html on everything.
- Sanitise, nonce and check capability before acting on any input.
- No jQuery. It is still loaded on a lot of sites, which is not a reason to add to it.
- Never edit core or a parent theme, because the next update silently undoes it.
- Translatable strings with the right text domain.
- Defaults on every callback parameter. This theme has lost an activation to a hook called with fewer arguments than its callback expected; a default costs nothing and prevents a white screen.
Ask for the hooks before the code
The prompt ends by asking which hooks it chose and why, and what it assumed about your site. That is the part worth reading. Code that works on a single site and breaks under an object cache or on multisite usually fails at an assumption, not at a line.
Where this fits
It is a drafting tool, not a review. Read what comes back, and if it touches payments, user data or anything you cannot roll back, have somebody who knows WordPress read it too. We do that as part of WordPress development, and most of the hacked sites we clean got there through code somebody pasted in without reading.
For the plugin side of the same question, is there one plugin that does everything is the honest answer.
Which AI is best for WordPress code?
Claude and ChatGPT both do well with a specific prompt. The difference between models matters far less than the difference between a vague prompt and a constrained one.
Is it safe to run code an AI wrote?
Not without reading it. Check the escaping, check it is not writing to the database directly, and test it somewhere that is not your live site.
Why does the prompt insist on default parameters?
Because a WordPress hook can call your callback with fewer arguments than you declared, and in PHP 8 that is a fatal error rather than a notice. A default turns a white screen into nothing happening.
Does this work for WooCommerce?
Yes, it is one of the task options. WooCommerce has its own hooks and its own ways of being broken, so describe the behaviour precisely.
Code came back and you are not sure about it?
Send it over. We will tell you what it does, what it misses and whether it is safe to run.