/drupal-ai-kit:create-drupal-plugin <type> <plugin_id> in <module> — <purpose>from Drupal AI Kit
Generates Drupal plugin classes (Block, FieldWidget, FieldFormatter, Condition, QueueWorker, etc.) in custom modules, following core conventions for attributes, base classes, and service injection.
Ships in Drupal AI Kit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Create the plugin described here: $ARGUMENTS
The module and the plugin type are required — ask when either is missing. Infer the rest from the purpose and name what you inferred in the report.
The rules for the class are in ${CLAUDE_PLUGIN_ROOT}/instructions/drupal.md §9 and ${CLAUDE_PLUGIN_ROOT}/instructions/php.md; read both
first. This skill is the procedure.
Find the plugin type's contract in core, not from memory: its attribute class, base class and directory. Open an existing core plugin of the same type and copy its shape.
| Type | Attribute | Base class | Directory |
|---|---|---|---|
| Block | Drupal\Core\Block\Attribute\Block | BlockBase | src/Plugin/Block/ |
| Field widget | Drupal\Core\Field\Attribute\FieldWidget | WidgetBase | src/Plugin/Field/FieldWidget/ |
| Field formatter | Drupal\Core\Field\Attribute\FieldFormatter | FormatterBase | src/Plugin/Field/FieldFormatter/ |
| Condition | Drupal\Core\Condition\Attribute\Condition | ConditionPluginBase | src/Plugin/Condition/ |
| Queue worker | Drupal\Core\Queue\Attribute\QueueWorker | QueueWorkerBase | src/Plugin/QueueWorker/ |
Any other type: locate its plugin manager (grep -r "DefaultPluginManager" <webroot>/core <webroot>/modules) and
read the attribute and subdirectory from the manager's constructor.
Write the class in that directory:
new TranslatableMarkup('…'). Core plugin types are
discovered by attribute on Drupal 10.3+; write a docblock annotation only when the type has no attribute class
yet;final, extending the type's base class and implementing every abstract method;ContainerFactoryPluginInterface: the constructor takes the base class's own constructor
arguments followed by the services and passes the former to parent::__construct(); a static create() builds
it. Field widgets and formatters have more base arguments than ($configuration, $plugin_id, $plugin_definition) — copy them from the base class. Give injected properties names the base class does not
use (drupal.md §5, "Inherited properties").Configuration. A plugin with settings implements defaultConfiguration() and its form methods, and gets a
schema entry in config/schema/<module>.schema.yml (block.settings.<plugin_id>, field.widget.settings.<id>,
field.formatter.settings.<id>, condition.plugin.<id>). Config without schema fails config validation and
kernel tests.
Output. A block or formatter that renders markup returns a render array with #theme and #cache
(tags, contexts, max-age) and gets a Twig template registered through hook_theme() (twig.md §2). Blocks expose
cache metadata through getCacheTags(), getCacheContexts() and getCacheMaxAge().
Verify.
ddev drush cr
ddev drush php:eval 'var_dump(\Drupal::service("<manager>")->hasDefinition("<plugin_id>"));'
ddev exec vendor/bin/phpcs --standard=Drupal,DrupalPractice <files you created>
<manager> is the type's plugin manager service: plugin.manager.block, plugin.manager.field.widget,
plugin.manager.field.formatter, plugin.manager.condition, plugin.manager.queue_worker.
Done when the plugin manager reports the definition (bool(true)) and phpcs reports nothing.
Files created or changed, the plugin ID, where the plugin is used in the UI (block layout, field display, …), anything inferred from an incomplete request, and the result of each verify command.
What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/create-drupal-serviceCreate a Drupal service class in a custom module and register it in the module's services.yml/drupal-performance-reviewReview Drupal code for performance issues (queries, caching, rendering)/drupal-refactor-to-diRefactor Drupal code from static \Drupal:: calls to dependency injection/git-commitGenerate a commit message in the project format (#329: Description.)npx claudepluginhub slivorezka/drupal-ai-kit --plugin drupal-ai-kitOther plugins' skills for the same job