Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

drupal-backend

БесплатноБез исполняемых скриптовНе проверен

Drupal Back End Specialist skill for custom module development, hooks, APIs, and PHP programming (Drupal 8-11+). Use when building custom modules…

Omediaот Omedia★ 28 звёзд на GitHub18 установок в других каталогах

Об этом скилле

Drupal Back End Development

Overview

Enable expert-level Drupal back end development capabilities. Provide comprehensive guidance for custom module development, PHP programming, API usage, hooks, plugins, services, and database operations for Drupal 8, 9, 10, and 11+.

When to Use This Skill

Invoke this skill when working with:

  • Custom module development: Creating new Drupal modules
  • Hooks: Implementing Drupal hooks to alter system behavior
  • Controllers & routing: Building custom pages and routes
  • Forms: Creating configuration or custom forms
  • Entities: Working with content entities or config entities
  • Plugins: Building blocks, field types, formatters, or other plugins
  • Services: Creating reusable business logic services
  • Database operations: Custom queries and schema definitions
  • APIs: Entity API, Form API, Database API, Plugin API

Core Capabilities

1. Custom Module Development

Create complete, standards-compliant Drupal modules:

Quick start workflow:

  1. Use module template from assets/module-template/
  2. Replace MODULENAME with machine name (lowercase, underscores)
  3. Replace MODULELABEL with human-readable name
  4. Implement functionality using Drupal APIs
  5. Enable module and test: ddev drush en mymodule -y

Module structure:

  • .info.yml - Module metadata and dependencies
  • .module - Hook implementations
  • .routing.yml - Route definitions
  • .services.yml - Service definitions
  • .permissions.yml - Custom permissions
  • src/ - PHP classes (PSR-4 autoloading)
  • config/ - Configuration files

Reference documentation:

  • references/module_structure.md - Complete module patterns
  • references/hooks.md - Hook implementations

2. Hooks System

Implement hooks to alter Drupal behavior:

Common hooks:

  • hook_entity_presave() - Modify entities before saving
  • hook_entity_insert/update/delete() - React to entity changes
  • hook_form_alter() - Modify any form
  • hook_node_access() - Control node access
  • hook_cron() - Perform periodic tasks
  • hook_install/uninstall() - Module installation tasks

Hook pattern:

function MODULENAME_hook_name($param1, &$param2) {
  // Implementation
}

Best practices:

  • Implement hooks in .module file only
  • Use proper type hints
  • Document with PHPDoc blocks
  • Check for entity types before processing
  • Be mindful of performance

3. Controllers & Routing

Create custom pages and endpoints:

Route definition (.routing.yml):

mymodule.example:
  path: '/example/{param}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\ExampleController::content'
    _title: 'Example Page'
  requirements:
    _permission: 'access content'
    param: \d+

Controller pattern:

namespace Drupal\mymodule\Controller;

use Drupal\Core\Controller\ControllerBase;

class ExampleController extends ControllerBase {
  public function content() {
    return ['#markup' => $this->t('Hello!')];
  }
}

With dependency injection:

public function __construct(EntityTypeManagerInterface $entity_type_manager) {
  $this->entityTypeManager = $entity_type_manager;
}

public static function create(ContainerInterface $container) {
  return new static($container->get('entity_type.manager'));
}

4. Forms API

Build configuration and custom forms:

Configuration form:

class SettingsForm extends ConfigFormBase {
  protected function getEditableConfigNames() {
    return ['mymodule.settings'];
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('mymodule.settings');
    
    $form['api_key'] = [
      '#type' => 'textfield',
      '#title' => $this->t('API Key'),
      '#default_value' => $config->get('api_key'),
    ];
    
    return parent::buildForm($form, $form_state);
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('mymodule.settings')
      ->set('api_key', $form_state->getValue('api_key'))
      ->save();
    parent::submitForm($form, $form_state);
  }
}

Form validation:

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (strlen($form_state->getValue('field')) < 5) {
    $form_state->setErrorByName('field', $this->t('Too short.'));
  }
}

5. Entity API

Work with content and configuration entities:

Loading entities:

// Load single entity
$node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);

// Load multiple entities
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple([1, 2, 3]);

// Load by properties
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([
  'type' => 'article',
  'status' => 1,
]);

Creating/saving entities:

$node = \Drupal::entityTypeManager()->getStorage('node')->create([
  'type' => 'article',
  'title' => 'My Article',
  'body' => ['value' => 'Content',
Полный SKILL.md на GitHub

Установить drupal-backend в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

assets/module-template/MODULENAME.info.ymlassets/module-template/MODULENAME.moduleassets/module-template/MODULENAME.routing.ymlassets/module-template/README.mdassets/module-template/src/Controller/ExampleController.phpreferences/hooks.mdreferences/module_structure.md

FAQ

Что делает скилл drupal-backend?

Drupal Back End Specialist skill for custom module development, hooks, APIs, and PHP programming (Drupal 8-11+). Use when building custom modules, implementing hooks, working with entities, forms, plugins, or services.

Как установить скилл drupal-backend?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл drupal-backend запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить drupal-backend с