원클릭으로
add-mu-plugin
Scaffold a new must-use plugin in packages/mu-plugins/ - either a simple utility or a service-class integration.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Scaffold a new must-use plugin in packages/mu-plugins/ - either a simple utility or a service-class integration.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Add a WordPress AJAX handler to a plugin, with nonce verification, input sanitisation, and JSON response.
Register a block pattern in a theme or plugin, using the WordPress 6.0+ file-based pattern system.
Add a new Gutenberg block to an existing plugin or theme.
Register a WP-CLI command in a plugin using a command class, following Dekode conventions.
Add a WordPress action or filter hook to a plugin or theme.
Register a custom post type (and optionally a taxonomy) in a theme or plugin, following Dekode conventions.
| name | add-mu-plugin |
| description | Scaffold a new must-use plugin in packages/mu-plugins/ - either a simple utility or a service-class integration. |
Scaffold a new must-use plugin under packages/mu-plugins/. MU-plugins are loaded automatically by WordPress before regular plugins and are used for site-wide utilities or third-party integrations that must always be active.
The following inputs are required. If any are missing from the request, ask for them before writing any code.
| Input | Required | Notes |
|---|---|---|
| Plugin slug | Yes | kebab-case, e.g. acme-utility or acme-crm |
| Plugin title | Yes | Human-readable name for the Plugin Name: header, e.g. Acme Utility or Acme CRM |
| PHP namespace | Yes | e.g. Acme\Utility or Acme\Crm |
| Type | Yes | utility (plain functions, no class) or service (singleton class, external API integration) |
| Description | No | One sentence for the Description: plugin header. Defaults to the plugin title. |
Create the directory: packages/mu-plugins/{plugin-slug}/
Create plugin.php:
<?php
/**
* Plugin Name: {Plugin Title}
* Description: {Description}
*
* @package {PhpNamespace}
*/
declare( strict_types=1 );
namespace {PhpNamespace};
/**
* {Describe what the function does.}
*
* @param mixed $value The value to process.
* @return void
*/
function utility_function( mixed $value ): void {
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
return;
}
// implementation
}
composer.json:{
"name": "dekode/{plugin-slug}",
"description": "{Description}",
"type": "wordpress-muplugin",
"require": {}
}
Create the directory: packages/mu-plugins/{plugin-slug}/
Create plugin.php - entry point that defines constants and requires class files:
<?php
/**
* Plugin Name: {Plugin Title}
* Description: {Description}
*
* @package {PhpNamespace}
*/
declare( strict_types=1 );
namespace {PhpNamespace};
define( '{PLUGIN_SLUG}_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( '{PLUGIN_SLUG}_PLUGIN_FILE', __FILE__ );
require_once __DIR__ . '/class-{plugin-slug}-service.php';
// Bootstrap
{PluginSlug}Service::get_instance();
class-{plugin-slug}-service.php:<?php
/**
* {Plugin Title}: Service class.
*
* @package {PhpNamespace}
*/
declare( strict_types=1 );
namespace {PhpNamespace};
/**
* {Plugin Title} service.
*/
class {PluginSlug}Service {
/**
* Singleton instance.
*/
private static ?self $instance = null;
/**
* Get or create the singleton instance.
*/
public static function get_instance(): self {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor - registers hooks.
*/
private function __construct() {
\add_action( 'init', [ $this, 'init' ] );
}
/**
* Initialise the service.
*/
public function init(): void {
// setup
}
/**
* Call the external API.
*
* @param string $endpoint API endpoint path.
* @param array<string, mixed> $body Request body.
* @return array{success: bool, data?: mixed, error?: string}
*/
public function call_api( string $endpoint, array $body ): array {
$url = \trailingslashit( \env( 'EXTERNAL_API_URL' ) ) . $endpoint;
$response = \wp_remote_post( $url, [
'headers' => [
'Authorization' => 'Bearer ' . \env( 'EXTERNAL_API_KEY' ),
'Content-Type' => 'application/json',
],
'body' => \wp_json_encode( $body ),
] );
if ( \is_wp_error( $response ) ) {
return [ 'success' => false, 'error' => $response->get_error_message() ];
}
$code = \wp_remote_retrieve_response_code( $response );
if ( ! \in_array( $code, [ 200, 201 ], true ) ) {
return [ 'success' => false, 'error' => __( 'Unexpected API response.', '{plugin-slug}' ) ];
}
return [ 'success' => true, 'data' => \json_decode( \wp_remote_retrieve_body( $response ), true ) ];
}
}
composer.json:{
"name": "dekode/{plugin-slug}",
"description": "{Description}",
"type": "wordpress-muplugin",
"require": {}
}
composer.json: add a path repository and require the package:"repositories": [
{ "type": "path", "url": "packages/mu-plugins/{plugin-slug}" }
],
"require": {
"dekode/{plugin-slug}": "*"
}
Install: composer install - Composer symlinks the plugin into public/content/mu-plugins/.
Lint:
composer lint
composer lint-fix # if needed
composer lint # re-run to confirm clean
\env( 'VAR_NAME' ) - never $_ENV, getenv(), or $_SERVERwp_remote_*() + is_wp_error() + response code checkget_transient / set_transient with false !== checkpackages/plugins/), not MU-pluginsUtility: plugin.php with namespaced helper functions. Auto-loaded by WordPress.
Service: plugin.php (bootstrap) + class-{plugin-slug}-service.php (singleton service). Registered in root composer.json, symlinked by Composer into public/content/mu-plugins/, and active on every page load without manual activation. Lint passes clean.