Secure Plugin Development logo

Secure Plugin Development

Organization
wpultimatesecurity
secure-plugin-development

Use when starting a new WordPress plugin or theme, scaffolding a plugin file, wiring hooks, or adding any feature that handles requests, options, or output. Establishes the secure-by-default baseline — ABSPATH guard, the capability + nonce + sanitize + escape flow, prepared queries, and safe defaults — and routes to the focused security skills for each concern. Apply proactively at the start of any WordPress build.

Overview

Publisherwpultimatesecurity
RepositoryWordPress-Security-Skills
Skill namesecure-plugin-development
Stars
54
Forks
3
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wpultimatesecurity on GitHub. Read the source before you install it.

Installation

Install the Secure Plugin Development AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/secure-plugin-development
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wpultimatesecurity/WordPress-Security-Skills.git /tmp/WordPress-Security-Skills
mkdir -p .claude/skills
cp -r /tmp/WordPress-Security-Skills/skills/secure-plugin-development .claude/skills/secure-plugin-development
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Secure Plugin Development in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Secure Plugin Development on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Secure Plugin Development is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Secure plugin & theme development (baseline)

When to use this skill

Use this skill at the start of any WordPress development work and whenever you add a feature that crosses a trust boundary:

  • Creating a new plugin main file or theme functions.php addition.
  • Registering hooks (add_action / add_filter) that handle input or render output.
  • Adding admin pages, settings, shortcodes, blocks, widgets, or REST routes.
  • Reviewing an existing plugin to bring it up to a secure baseline.

This is the router skill. Follow the security decision tree: choose the entry path (browser/API, renderer, cron, or CLI), then add the relevant data and policy branches. It explains when to combine focused skills and when browser nonce checks do not apply; do not load every skill for every task.

Core principles (and why they matter)

  1. Never trust input; always escape output. Every value from $_GET, $_POST, $_REQUEST, $_COOKIE, the database, or a remote API is untrusted until sanitized, and untrusted again the moment it is echoed. These are two separate jobs.
  2. Block direct file access. Plugin files are reachable by URL. Without an ABSPATH guard, an attacker can execute them outside WordPress, bypassing all your checks.
  3. Separate authentication, CSRF, and authorization. Use a nonce for cookie-authenticated state changes and an appropriate capability/object check for privileged actions. REST API credentials, cron, and CLI have different trust models; follow the decision tree rather than adding browser checks everywhere.
  4. Use core APIs, not hand-rolled code. Prefer maintained sanitize/escape/DB/HTTP APIs, but choose the API and its arguments for the actual trust boundary.
  5. Least privilege by default. Default options to the safe value, scope capabilities tightly, and expose the minimum surface.
  6. Fail closed. On any failed check, stop and return an error — never fall through.

Step-by-step implementation

  1. Guard the file: defined( 'ABSPATH' ) || exit; at the top of every PHP file.
  2. Namespace everything: prefix functions, hooks, options, and globals (e.g. my_plugin_*) to avoid collisions and accidental overrides.
  3. Choose the handler trust model using the decision tree:
    1. Apply transport-appropriate authentication and CSRF protection.
    2. Check authority over the action and specific resource.
    3. Validate input shape/type, unslash WordPress-slashed request input, and sanitize.
    4. Use $wpdb->prepare() for dynamic values in custom queries.
    5. Escape at each output sink for its actual context.
  4. Set safe defaults for all options; validate on save and on read.
  5. Enqueue assets properly (wp_enqueue_script/style) and pass data via wp_localize_script() rather than inline-echoing PHP into JS.
  6. Keep secrets out of the repo and out of client-readable output.

Supporting references

ReferenceLoad when
Secure plugin baseline checklistBefore final verification of the secure plugin baseline controls.
Choose the security review pathSelecting focused skills for the entry point and all relevant data and risk branches.
Secure plugin skeletonImplementing a capability-gated plugin admin page and the full settings-save flow.

Common AI mistakes / anti-patterns

Mistake 1 — No ABSPATH guard

php
// ❌ Insecure: file executes if requested directly over HTTP.
<?php
function my_plugin_init() { /* ... */ }
php
// ✅ Secure: bail unless loaded within WordPress.
<?php
defined( 'ABSPATH' ) || exit;

function my_plugin_init() { /* ... */ }

Mistake 2 — Doing the work before the security checks

php
// ❌ Insecure: option saved before anything is verified.
function my_plugin_save() {
    update_option( 'my_opt', $_POST['val'] );
    check_admin_referer( 'my_plugin_save' );
    current_user_can( 'manage_options' );
}
php
// ✅ Secure: verify, authorize, sanitize, THEN act.
function my_plugin_save() {
    check_admin_referer( 'my_plugin_save', 'my_plugin_nonce' );
    if ( ! current_user_can( 'manage_options' ) ) {
        wp_die( esc_html__( 'Forbidden', 'my-plugin' ), 403 );
    }
    $val = isset( $_POST['val'] ) ? sanitize_text_field( wp_unslash( $_POST['val'] ) ) : '';
    update_option( 'my_opt', $val );
}

Mistake 3 — Rolling your own instead of using core APIs

php
// ❌ Insecure: manual SQL, manual escaping, raw remote fetch.
$rows = $wpdb->get_results( "SELECT * FROM t WHERE id = " . $_GET['id'] );
echo "<a href=" . $_GET['url'] . ">x</a>";
$body = file_get_contents( $remote_url );
php
// ✅ Secure: prepared query, escaped output, HTTP API.
$id   = absint( $_GET['id'] ?? 0 );
$rows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}t WHERE id = %d", $id ) );
echo '<a href="' . esc_url( wp_unslash( $_GET['url'] ?? '' ) ) . '">x</a>';
$response = wp_remote_get( $remote_url );
$body     = is_wp_error( $response ) ? '' : wp_remote_retrieve_body( $response );

Mistake 4 — Unsafe defaults

php
// ❌ Insecure: feature ships enabled, capability defaults wide open.
add_option( 'my_plugin_allow_uploads', true );
php
// ✅ Secure: default to the safe value; opt-in to risk.
add_option( 'my_plugin_allow_uploads', false );

Correct code examples

A minimal but complete secure plugin skeleton — ABSPATH guard, an admin page behind a capability, and the full verify → authorize → sanitize → act → escape flow — lives in references/secure-plugin-skeleton.php.

Checklist

  • Every PHP file opens with defined( 'ABSPATH' ) || exit;.
  • Functions, hooks, and options are uniquely prefixed.
  • Each request handler verifies nonce, then capability, then sanitizes input.
  • All custom DB access uses $wpdb->prepare().
  • All dynamic output is escaped at the point of echo.
  • Options have safe defaults and are validated on save.
  • Remote requests use the WP HTTP API (wp_remote_*), not file_get_contents/cURL.
  • No secrets, keys, or credentials are hard-coded or sent to the browser.
  • Scripts are enqueued and given data via wp_localize_script().

Official references

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Secure Plugin Development AI skill do?

Use when starting a new WordPress plugin or theme, scaffolding a plugin file, wiring hooks, or adding any feature that handles requests, options, or output. Establishes the secure-by-default baseline — ABSPATH guard, the capability + nonce + sanitize + escape flow, prepared queries, and safe defaults — and routes to the focused security skills for each concern. Apply proactively at the start of any WordPress build.

Why use Secure Plugin Development on TypingMind?

Because you install it once and use it with any model. Secure Plugin Development is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Secure Plugin Development in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/secure-plugin-development. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Secure Plugin Development?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Secure Plugin Development?

As many as you like. As long as a model supports skills, you can use Secure Plugin Development with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Secure Plugin Development AI skill free?

Yes. It is published on GitHub by wpultimatesecurity under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇