wp-plugin-development
wordpress/agent-skills
Develop WordPress plugins with proper architecture, hooks, security, and lifecycle management.
What is wp-plugin-development?
This skill guides development of WordPress plugins, covering plugin structure, hooks/actions/filters, activation/deactivation/uninstall behavior, admin UI via Settings API, data storage, cron tasks, and security best practices (nonces, capabilities, sanitization, escaping). Use it when building or refactoring plugins for WordPress 7.0+ with PHP 7.4+.
- Detect plugin structure and entrypoints in WordPress projects
- Register and manage hooks, actions, and filters
- Implement activation, deactivation, and uninstall lifecycle hooks
- Build admin settings pages using WordPress Settings API
- Validate, sanitize, and escape user input securely
- Write SQL queries safely with prepared statements
How to install wp-plugin-development
npx skills add https://github.com/wordpress/agent-skills --skill wp-plugin-development- WordPress 7.0 or later
- PHP 7.4.0 or later
- Node.js (for detection scripts)
- WP-CLI (required for some workflows)
- Filesystem access to plugin directory
How to use wp-plugin-development
- 1.Run triage to detect WordPress project structure: node skills/wp-project-triage/scripts/detect_wp_project.mjs
- 2.Detect plugin headers and entrypoints: node skills/wp-plugin-development/scripts/detect_plugins.mjs
- 3.Identify the target plugin file and follow the predictable architecture guidelines in references/structure.md
- 4.Register activation/deactivation/uninstall hooks at top-level in the main plugin file
- 5.Implement admin UI using Settings API (register_setting, add_settings_section, add_settings_field)
- 6.Apply security baseline: validate/sanitize input early, escape output late, use nonces and capability checks
- 7.Use $wpdb->prepare() for all SQL queries to prevent injection
- 8.Test plugin activation, settings save/load, and uninstall behavior before release
Use cases
- Creating a new WordPress plugin from scratch with proper bootstrap and namespace structure
- Adding a custom settings page to an existing plugin using the Settings API
- Implementing CSRF protection and capability checks for admin forms
- Migrating plugin data during activation or version upgrades
- Setting up scheduled tasks (cron) that run idempotently
- WordPress plugin developers
- Full-stack developers building WordPress extensions
- DevOps engineers maintaining WordPress plugin codebases
- Security-focused developers hardening plugin code
wp-plugin-development FAQ
Activation hooks run when a plugin is first activated and are used for setup (creating tables, flushing rewrite rules). Uninstall hooks run when a plugin is deleted and should clean up all plugin data. Register both at top-level in the main plugin file, not inside other hooks.
Use WordPress nonces with wp_nonce_field() in your form and wp_verify_nonce() when processing POST data. Always pair nonce checks with capability checks (current_user_can()) to verify the user has permission.
Use WordPress options (get_option/update_option) for small configuration data. Create custom tables only if you need to store large amounts of structured data or frequently query complex relationships.
Validate input early using specific keys and types, sanitize using appropriate sanitize_* functions, and escape output late using esc_* functions. Never trust $_POST or $_GET directly; use wp_unslash() and specific array keys.
Ensure the plugin activates without fatals or notices, settings save and load correctly with nonce/capability enforcement, uninstall removes only intended data, and all repo lint/tests pass (PHPUnit, PHPCS, JS builds if applicable).
Full instructions (SKILL.md)
Source of truth, from wordpress/agent-skills.
name: wp-plugin-development description: "Use when developing WordPress plugins: architecture and hooks, activation/deactivation/uninstall, admin UI and Settings API, data storage, cron/tasks, security (nonces/capabilities/sanitization/escaping), and release packaging." compatibility: "Targets WordPress 7.0+ (PHP 7.4.0+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
WP Plugin Development
When to use
Use this skill for plugin work such as:
- creating or refactoring plugin structure (bootstrap, includes, namespaces/classes)
- adding hooks/actions/filters
- activation/deactivation/uninstall behavior and migrations
- adding settings pages / options / admin UI (Settings API)
- security fixes (nonces, capabilities, sanitization/escaping, SQL safety)
- packaging a release (build artifacts, readme, assets)
Inputs required
- Repo root + target plugin(s) (path to plugin main file if known).
- Where this plugin runs: single site vs multisite; WP.com conventions if applicable.
- Target WordPress + PHP versions (affects available APIs and placeholder support in
$wpdb->prepare()).
Procedure
0) Triage and locate plugin entrypoints
- Run triage:
node skills/wp-project-triage/scripts/detect_wp_project.mjs
- Detect plugin headers (deterministic scan):
node skills/wp-plugin-development/scripts/detect_plugins.mjs
If this is a full site repo, pick the specific plugin under wp-content/plugins/ or mu-plugins/ before changing code.
1) Follow a predictable architecture
Guidelines:
- Keep a single bootstrap (main plugin file with header).
- Avoid heavy side effects at file load time; load on hooks.
- Prefer a dedicated loader/class to register hooks.
- Keep admin-only code behind
is_admin()(or admin hooks) to reduce frontend overhead.
See:
references/structure.md
2) Hooks and lifecycle (activation/deactivation/uninstall)
Activation hooks are fragile; follow guardrails:
- register activation/deactivation hooks at top-level, not inside other hooks
- flush rewrite rules only when needed and only after registering CPTs/rules
- uninstall should be explicit and safe (
uninstall.phporregister_uninstall_hook)
See:
references/lifecycle.md
3) Settings and admin UI (Settings API)
Prefer Settings API for options:
register_setting(),add_settings_section(),add_settings_field()- sanitize via
sanitize_callback
See:
references/settings-api.md
4) Security baseline (always)
Before shipping:
- Validate/sanitize input early; escape output late.
- Use nonces to prevent CSRF and capability checks for authorization.
- Avoid directly trusting
$_POST/$_GET; usewp_unslash()and specific keys. - Use
$wpdb->prepare()for SQL; avoid building SQL with string concatenation.
See:
references/security.md
5) Data storage, cron, migrations (if needed)
- Prefer options for small config; custom tables only if necessary.
- For cron tasks, ensure idempotency and provide manual run paths (WP-CLI or admin).
- For schema changes, write upgrade routines and store schema version.
See:
references/data-and-cron.md
Verification
- Plugin activates with no fatals/notices.
- Settings save and read correctly (capability + nonce enforced).
- Uninstall removes intended data (and nothing else).
- Run repo lint/tests (PHPUnit/PHPCS if present) and any JS build steps if the plugin ships assets.
Failure modes / debugging
- Activation hook not firing:
- hook registered incorrectly (not in main file scope), wrong main file path, or plugin is network-activated
- Settings not saving:
- settings not registered, wrong option group, missing capability, nonce failure
- Security regressions:
- nonce present but missing capability checks; or sanitized input not escaped on output
See:
references/debugging.md
Escalation
For canonical detail, consult the Plugin Handbook and security guidelines before inventing patterns.
Related skills
More from wordpress/agent-skills and the wider catalog.

wp-plugin-directory-guidelines
Reference the 18 WordPress.org Plugin Directory guidelines for GPL compliance, licensing, naming, and submission requirements.

wp-project-triage
Deterministic WordPress repository inspection with structured JSON output for workflow guidance.

wp-rest-api
Build, extend, and debug WordPress REST API endpoints with schema validation, authentication, and custom fields.

wp-wpcli-and-ops
WordPress operations via WP-CLI: safe search-replace, database management, plugin/theme control, and automation.

wpds
Build WordPress UIs with the WordPress Design System (WPDS) components, tokens, and patterns.

workos
WorkOS authentication, identity, and access control integration reference for coding agents.