/drupal-ai-kit:create-drupal-service <ServiceName> in <module> — <purpose, dependencies, methods>from Drupal AI Kit
Generates a Drupal service class, registers it in services.yml, adds an interface for testability, and creates a unit test. Useful when adding custom business logic to a Drupal module.
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 service described here: $ARGUMENTS
The module is required — ask when it is missing. Infer missing dependencies and methods from the purpose and name what you inferred in the report.
The rules for the class are in ${CLAUDE_PLUGIN_ROOT}/instructions/drupal.md §5 and ${CLAUDE_PLUGIN_ROOT}/instructions/php.md; read both
first. This skill is the procedure.
Look at the module. Open <webroot>/modules/custom/<module>/<module>.services.yml and one class in
src/Service/. An existing registration style in the module wins over the default below.
Write the class at src/Service/<ServiceName>.php, namespace Drupal\<module>\Service:
final, dependencies as private readonly promoted constructor parameters typed by interface;@param, @return, @throws);Register it in <module>.services.yml — by class name with autowiring:
services:
Drupal\<module>\Service\<ServiceName>:
autowire: true
A dependency that autowiring cannot resolve from its type (a logger channel, a cache bin) takes an attribute on
the constructor parameter: #[Autowire(service: 'logger.channel.<module>')]. Register the logger channel when the
module has none (drupal.md §13).
Add an interface (src/Service/<ServiceName>Interface.php) when other classes will mock the service in
their unit tests: PHPUnit cannot mock a final class. Callers then type-hint the interface, and services.yml
aliases it: Drupal\<module>\Service\<ServiceName>Interface: '@Drupal\<module>\Service\<ServiceName>'.
Add a unit test at tests/src/Unit/Service/<ServiceName>Test.php covering each public method.
Verify.
ddev drush cr
ddev drush php:eval 'var_dump(\Drupal::service(\Drupal\<module>\Service\<ServiceName>::class) !== NULL);'
ddev exec vendor/bin/phpcs --standard=Drupal,DrupalPractice <files you created>
ddev exec vendor/bin/phpunit <test file>
Done when the container returns the service (bool(true)), phpcs reports nothing and the test passes.
Files created or changed, the service ID, 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-pluginCreate a Drupal plugin class (Block, FieldWidget, FieldFormatter, Condition, QueueWorker, etc.) in a custom module/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