WordPress Development AI Skill Guide
Overview & Engine Architecture
WordPress serves content via themes and plugins on a PHP + MySQL stack. Behavior is extended through actions/filters hooks, custom post types, and the REST API. WP-CLI handles admin tasks without the browser. Agents escape output, prepare SQL, keep plugins minimal, and never commit wp-config.php secrets.
Request
-> WordPress core
-> Active theme + plugins (hooks)
-> MySQL (posts, options, users)
REST / WP-CLI / cron -> same hook ecosystem
When to use this skill
- Building or reviewing custom themes and plugins
- Registering CPTs, taxonomies, and REST routes
- Automating installs and searches with WP-CLI
- Hardening sites against XSS, SQLi, and file abuse
Operational directives
- Escape on output (
esc_html, esc_attr, wp_kses_post); sanitize on input.
- Use
$wpdb->prepare for any dynamic SQL; prefer APIs (WP_Query) when possible.
- Enqueue scripts with
wp_enqueue_script; never hardcode admin jQuery hacks in random places.
- Check capabilities (
current_user_can) and nonces on every state-changing request.
- Keep WordPress core, themes, and plugins updated; remove unused plugins.
Plugin sketch
add_action('init', function () {
register_post_type('book', [
'public' => true,
'label' => 'Books',
'show_in_rest' => true,
]);
});
add_action('rest_api_init', function () {
register_rest_route('myplugin/v1', '/health', [
'methods' => 'GET',
'callback' => fn() => ['ok' => true],
'permission_callback' => '__return_true', // tighten for sensitive data
]);
});
WP-CLI sketches
wp plugin list --status=active
wp search-replace 'http://old.example' 'https://new.example' --all-tables --dry-run
wp cache flush
Common pitfalls
| Pitfall |
Result |
Fix |
Echoing unsanitized $_GET |
XSS |
Escape/sanitize appropriately |
| Direct SQL with string concat |
SQLi |
$wpdb->prepare |
Unlimited admin-ajax handlers |
Abuse / DoS |
Capability checks + rate limits |
| Editing core files |
Lost on upgrade |
Hooks / child theme / plugin |
Best practices
- Prefer block themes / modern block APIs for new UI work when compatible.
- Store config in environment or server config outside the web root when possible.
- Use object caching and careful transient TTLs on high-traffic sites.
- Disallow file editing in admin (
DISALLOW_FILE_EDIT) in production.
Limitations
- Hosting stacks (Apache/Nginx, multisite, Bedrock/Composer layouts) change paths and deploy flow.
- Page builders and heavy plugin stacks can conflict in unpredictable ways.
- This skill does not replace malware incident response for compromised sites.
Related skills
@php - language-level patterns
@nginx - fronting WordPress safely
@owasp-asvs - broader application security requirements
1---2name: wordpress3description: Operational skill for WordPress development: themes, plugins, hooks, WP-CLI, REST API, and hardening against common WP pitfalls.4---56# WordPress Development AI Skill Guide78## Overview & Engine Architecture910WordPress serves content via themes and plugins on a PHP + MySQL stack. Behavior is extended through actions/filters hooks, custom post types, and the REST API. WP-CLI handles admin tasks without the browser. Agents escape output, prepare SQL, keep plugins minimal, and never commit `wp-config.php` secrets.1112```13Request14 -> WordPress core15 -> Active theme + plugins (hooks)16 -> MySQL (posts, options, users)17REST / WP-CLI / cron -> same hook ecosystem18```1920## When to use this skill2122- Building or reviewing custom themes and plugins23- Registering CPTs, taxonomies, and REST routes24- Automating installs and searches with WP-CLI25- Hardening sites against XSS, SQLi, and file abuse2627## Operational directives28291. Escape on output (`esc_html`, `esc_attr`, `wp_kses_post`); sanitize on input.302. Use `$wpdb->prepare` for any dynamic SQL; prefer APIs (`WP_Query`) when possible.313. Enqueue scripts with `wp_enqueue_script`; never hardcode admin jQuery hacks in random places.324. Check capabilities (`current_user_can`) and nonces on every state-changing request.335. Keep WordPress core, themes, and plugins updated; remove unused plugins.3435## Plugin sketch3637```php38add_action('init', function () {39 register_post_type('book', [40 'public' => true,41 'label' => 'Books',42 'show_in_rest' => true,43 ]);44});4546add_action('rest_api_init', function () {47 register_rest_route('myplugin/v1', '/health', [48 'methods' => 'GET',49 'callback' => fn() => ['ok' => true],50 'permission_callback' => '__return_true', // tighten for sensitive data51 ]);52});53```5455## WP-CLI sketches5657```bash58wp plugin list --status=active59wp search-replace 'http://old.example' 'https://new.example' --all-tables --dry-run60wp cache flush61```6263## Common pitfalls6465| Pitfall | Result | Fix |66| --- | --- | --- |67| Echoing unsanitized `$_GET` | XSS | Escape/sanitize appropriately |68| Direct SQL with string concat | SQLi | `$wpdb->prepare` |69| Unlimited `admin-ajax` handlers | Abuse / DoS | Capability checks + rate limits |70| Editing core files | Lost on upgrade | Hooks / child theme / plugin |7172## Best practices7374- Prefer block themes / modern block APIs for new UI work when compatible.75- Store config in environment or server config outside the web root when possible.76- Use object caching and careful transient TTLs on high-traffic sites.77- Disallow file editing in admin (`DISALLOW_FILE_EDIT`) in production.7879## Limitations8081- Hosting stacks (Apache/Nginx, multisite, Bedrock/Composer layouts) change paths and deploy flow.82- Page builders and heavy plugin stacks can conflict in unpredictable ways.83- This skill does not replace malware incident response for compromised sites.8485## Related skills8687- `@php` - language-level patterns88- `@nginx` - fronting WordPress safely89- `@owasp-asvs` - broader application security requirements