drupal-backend
Drupal back end skill that guides custom module, hook, entity, and service development.
- CCM score
- 38 of 100
- version
- 1.0.0
- GitHub stars
- 28
Own this plugin? Claim it
What it does
- Covers custom module development, the hooks system, controllers and routing, and the Forms API
- Includes entity API operations, plugins such as blocks and fields, services with dependency injection, and database queries
- Ships a hooks reference with examples, a module structure guide, and a module template scaffold
- Designed for building custom modules and working with entities, forms, plugins, or services in Drupal 8 through 11
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.
Add marketplace
/plugin marketplace add Omedia/drupal-skillRun it inside Claude Code once, then install the plugin below.
Install
/plugin install drupal-backend@drupal-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceDrupal 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:
- Use module template from
assets/module-template/ - Replace
MODULENAMEwith machine name (lowercase, underscores) - Replace
MODULELABELwith human-readable name - Implement functionality using Drupal APIs
- 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 permissionssrc/- PHP classes (PSR-4 autoloading)config/- Configuration files
Reference documentation:
references/module_structure.md- Complete module patternsreferences/hooks.md- Hook implementations
2. Hooks System
Implement hooks to alter Drupal behavior:
Common hooks:
hook_entity_presave()- Modify entities before savinghook_entity_insert/update/delete()- React to entity changeshook_form_alter()- Modify any formhook_node_access()- Control node accesshook_cron()- Perform periodic taskshook_install/uninstall()- Module installation tasks
Hook pattern:
function MODULENAME_hook_name($param1, &$param2) {
// Implementation
}
Best practices:
- Implement hooks in
.modulefile 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', 'format' => 'basic_html'],
]);
$node->save();
Entity queries:
$query = \Drupal::entityQuery('node')
->condition('type', 'article')
->condition('status', 1)
->accessCheck(TRUE)
->sort('created', 'DESC')
->range(0, 10);
$nids = $query->execute();
6. Plugin System
Create custom plugins (blocks, fields, etc.):
Block plugin:
/**
* @Block(
* id = "mymodule_custom_block",
* admin_label = @Translation("Custom Block"),
* )
*/
class CustomBlock extends BlockBase {
public function build() {
return ['#markup' => 'Block content'];
}
public function blockForm($form, FormStateInterface $form_state) {
$form['setting'] = [
'#type' => 'textfield',
'#title' => $this->t('Setting'),
'#default_value' => $this->configuration['setting'] ?? '',
];
return $form;
}
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['setting'] = $form_state->getValue('setting');
}
}
7. Services & Dependency Injection
Create reusable services:
Service definition (.services.yml):
services:
mymodule.custom_service:
class: Drupal\mymodule\Service\CustomService
arguments: ['@entity_type.manager', '@current_user']
Service class:
namespace Drupal\mymodule\Service;
class CustomService {
protected $entityTypeManager;
protected $currentUser;
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $current_user) {
$this->entityTypeManager = $entity_type_manager;
$this->currentUser = $current_user;
}
public function doSomething() {
// Business logic
}
}
8. Database Operations
Execute custom queries:
Using Database API:
$database = \Drupal::database();
// Select query
$query = $database->select('node_field_data', 'n')
->fields('n', ['nid', 'title'])
->condition('type', 'article')
->condition('status', 1)
->range(0, 10);
$results = $query->execute()->fetchAll();
// Insert
$database->insert('mymodule_table')
->fields(['name' => 'Example', 'value' => 123])
->execute();
// Update
$database->update('mymodule_table')
->fields(['value' => 456])
->condition('name', 'Example')
->execute();
Schema definition (.install file):
function mymodule_schema() {
$schema['mymodule_table'] = [
'fields' => [
'id' => ['type' => 'serial', 'not null' => TRUE],
'name' => ['type' => 'varchar', 'length' => 255, 'not null' => TRUE],
'value' => ['type' => 'int', 'not null' => TRUE, 'default' => 0],
],
'primary key' => ['id'],
'indexes' => ['name' => ['name']],
];
return $schema;
}
Development Workflow
Creating a Custom Module
-
Scaffold the module:
cp -r assets/module-template/ /path/to/drupal/modules/custom/mymodule/ cd /path/to/drupal/modules/custom/mymodule/ mv MODULENAME.info.yml mymodule.info.yml mv MODULENAME.module mymodule.module mv MODULENAME.routing.yml mymodule.routing.yml -
Update module files:
- Replace
MODULENAMEwith machine name - Replace
MODULELABELwith readable name - Update
.info.ymldependencies - Customize controller, routes, logic
- Replace
-
Enable and test:
ddev drush en mymodule -y ddev drush cr -
Develop iteratively:
- Implement functionality
- Clear cache:
ddev drush cr - Test thoroughly
- Check logs:
ddev drush watchdog:tail
Standard Development Workflow
- Plan: Identify what APIs/hooks you need
- Code: Implement using Drupal APIs
- Test: Enable module, clear cache, test functionality
- Debug: Check logs, use Xdebug if needed
- Refine: Optimize, add tests, improve code quality
Best Practices
Module Development
- PSR-4 autoloading: Follow namespace conventions
- Dependency injection: Use DI in classes
- Hooks: Implement only in
.modulefiles - Type hints: Use proper PHP type declarations
- Documentation: Add PHPDoc blocks
- Testing: Write automated tests
Code Quality
- Drupal coding standards: Follow PHPCS rules
- Security: Validate input, sanitize output, check permissions
- Performance: Cache when possible, optimize queries
- Accessibility: Ensure forms and pages are accessible
- Internationalization: Use
$this->t()for all strings
API Usage
- Entity API: Prefer entity operations over direct DB queries
- Configuration: Use Config API for settings
- State API: Use for temporary/non-exportable data
- Cache API: Implement caching for expensive operations
- Queue API: Use for long-running tasks
Common Patterns
Event Subscriber
class MyModuleSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [KernelEvents::REQUEST => ['onRequest', 0]];
}
public function onRequest(RequestEvent $event) {
// Handle event
}
}
Custom Permission
# mymodule.permissions.yml
administer mymodule:
title: 'Administer My Module'
restrict access: true
Custom Access Check
class CustomAccessCheck implements AccessInterface {
public function access(AccountInterface $account) {
return AccessResult::allowedIf($account->hasPermission('access content'));
}
}
Troubleshooting
Module Not Appearing
- Check
.info.ymlsyntax - Verify
core_version_requirement - Clear cache:
ddev drush cr
Hooks Not Working
- Verify hook name is correct
- Clear cache after adding hooks
- Check module weight if hook order matters
Class Not Found
- Verify PSR-4 namespace matches directory
- Clear cache to rebuild class registry
- Check autoloading with
composer dump-autoload
Database Errors
- Check schema definition syntax
- Run
ddev drush updbafter schema changes - Verify table/column names in queries
Resources
Reference Documentation
-
references/hooks.md- Common hooks with examples- Entity hooks
- Form hooks
- Node hooks
- Installation hooks
- Token hooks
-
references/module_structure.md- Module patterns- Controllers and routing
- Forms (config and custom)
- Plugins (blocks, fields, etc.)
- Services and DI
- Event subscribers
Asset Templates
assets/module-template/- Module scaffold.info.ymlmetadata.modulehook file.routing.ymlroutes- Example controller
Version Compatibility
Drupal 8 vs 9 vs 10 vs 11
- Core APIs: Largely consistent across versions
- PHP requirements: 8.x (7.0+), 9.x (7.3+), 10.x (8.1+), 11.x (8.3+)
- Deprecations: Check change records when upgrading
- Symfony: Different Symfony versions in each Drupal version
See Also
- drupal-frontend - Theme development, Twig templates
- drupal-tooling - DDEV and Drush development tools
- Drupal API - Official API documentation
From the Omedia/drupal-skill README
Drupal Development Skills for Claude Code
Comprehensive Drupal development skills for Claude Code, organized by specialization. Choose the skills you need for front-end development, back-end development, or development tooling for Drupal 8-11+.
Quick Start
Install from Marketplace
If this repository is hosted on GitHub or another git service:
# Add this marketplace
/plugin marketplace add Omedia/drupal-skill
# Install all three skills
/plugin install drupal-frontend
/plugin install drupal-backend
/plugin install drupal-tooling
# Or install just what you need
/plugin install drupal-frontend # For theme development
/plugin install drupal-backend # For module development
Install from Local Repository
For local development or testing:
# Add local marketplace
/plugin marketplace add /path/to/drupal-skill
# Install skills
/plugin install drupal-frontend
/plugin install drupal-backend
/plugin install drupal-tooling
Available Skills
drupal-frontend - Front End Specialist
Theme development, Twig templates, and Drupal's rendering system.
Features:
- Theme structure and configuration
- Twig templating syntax and filters
- Template suggestions and debugging
- Preprocessing functions
- CSS/JS library management
- Responsive design and breakpoints
- Accessibility best practices
Use when:
- Creating or customizing Drupal themes
- Working with Twig templates
- Implementing preprocessing functions
- Managing CSS/JS assets
- Building responsive, accessible designs
Includes:
- Complete theming reference (
theming.md) - Theme template scaffold
- Twig examples and patterns
drupal-backend - Back End Specialist
Custom module development, hooks, APIs, and PHP programming.
Features:
- Custom module development
- Drupal hooks system
- Controllers and routing
- Forms API (configuration and custom)
- Entity API operations
- Plugin system (blocks, fields, etc.)
- Services and dependency injection
- Database operations
Use when:
- Building custom modules
- Implementing hooks
- Working with entities, forms, or plugins
- Creating custom controllers or services
- Database operations and queries
Includes:
- Hooks reference with examples (
hooks.md) - Module structure patterns (
module_structure.md) - Module template scaffold
drupal-tooling - Development Tools
Development environment and command-line tools
DDEV Docker environments and Drush command-line operations.
Features:
- DDEV project setup and management
- Database import/export and snapshots
- Drush cache, configuration, and module commands
- Deployment workflows
- User management and debugging
- Performance optimization
Use when:
- Setting up local development environments
- Managing databases and configuration
- Running Drush commands
- Deploying configuration changes
- Debugging and troubleshooting
Includes:
- Complete DDEV reference (
ddev.md) - Complete Drush reference (
drush.md) - Workflow examples
Usage Examples
Once installed, Claude automatically invokes the appropriate skill:
# Frontend work (uses drupal-frontend)
"Create a custom theme with a two-column layout"
"Write a preprocess function to add custom variables"
"Create a Twig template for article nodes"
# Backend work (uses drupal-backend)
"Create a custom module that adds a new content entity"
"Write a hook_form_alter to modify the user registration form"
"Build a custom block plugin with configuration"
# Tooling work (uses drupal-tooling)
"Set up a new DDEV project for Drupal 10"
"Import this database and clear the cache"
"Export configuration using Drush"
Supported Drupal Versions
All skills support:
- Drupal 8.x
- Drupal 9.x
- Drupal 10.x
- Drupal 11.x
Requirements
- Claude Code installed
- For drupal-tooling: Docker and DDEV installed for local development
- For drupal-tooling: Drush 10+ for command-line operations
- For drupal-backend: PHP 7.0+ (version depends on Drupal version)
Repository Structure
drupal-skill/
├── .claude-plugin/
│ └── marketplace.json # Marketplace with all three skills
├── drupal-frontend/
│ ├── SKILL.md # Frontend skill instructions
│ ├── references/
│ │ └── theming.md
│ └── assets/
│ └── theme-template/
├── drupal-backend/
│ ├── SKILL.md # Backend skill instructions
│ ├── references/
│ │ ├── hooks.md
│ │ └── module_structure.md
│ └── assets/
│ └── module-template/
├── drupal-tooling/
│ ├── SKILL.md # Tooling skill instructions
│ └── references/
│ ├── ddev.md
│ └── drush.md
├── LICENSE
├── .gitignore
└── README.md # This file
Development
Testing Locally
- Clone this repository
- Add as local marketplace:
/plugin marketplace add ./drupal-skill - Install skills:
/plugin install drupal-frontend(or backend, tooling) - Test with Drupal development tasks
Contributing
Contributions are welcome! Please:
- Test changes thoroughly with multiple Drupal versions (8-11+)
- Update reference documentation as needed
- Follow existing code patterns and structure
- Update version numbers in marketplace.json
Why Three Separate Skills?
Focused Content: Each skill loads only relevant documentation and templates
Modular Installation: Install only what you need (frontend-only, backend-only, or both)
Better Performance: Smaller skills mean less context usage
Clear Separation: Frontend vs Backend vs Tooling mirrors real-world specializations
Support
For issues, questions, or contributions:
- Open an issue in this repository
- Check skill-specific SKILL.md files for detailed instructions
- Review reference documentation in each skill's
references/directory
Details
- Marketplace
- Omedia/drupal-skill
- Source
- drupal-backend
- Author
- Drupal Skills Team
- Category
- Development
- License
- MIT
- Keywords
- drupal, php, module-development, backend, hooks, entity-api, form-api, plugin-api, services, dependency-injection, drupal-8, drupal-9, drupal-10, drupal-11
- Listed since
- Apr 7, 2026
Questions
What does the drupal-backend plugin add to Claude Code?
The drupal-backend plugin is a Drupal Back End Specialist skill for custom module development, hooks, APIs and PHP programming on Drupal 8 through 11. It guides work on controllers and routing, forms, entities, plugins, services and database operations. It also includes a module structure reference and a module template scaffold.
How do I install the drupal-backend plugin?
Run /plugin marketplace add Omedia/drupal-skill first, then run /plugin install drupal-backend@drupal-skills inside Claude Code. The marketplace command adds the Drupal skills marketplace to Claude Code. The install command then adds the drupal-backend skill to your setup.
Which Drupal versions does drupal-backend support?
The plugin covers Drupal 8, 9, 10 and 11 and later, as its description and keywords state. It targets custom module development, hooks, entities, forms and services on those versions. Its guidance is written for PHP-based Drupal back end work.
Where does drupal-backend stand among Backend and API plugins?
It is listed in the Backend and APIs category on Claude Marketplaces, alongside ruflo-ddd, Prismic Automation, svix-automation and two agentic-bundle API builders. Those plugins cover different back end tools, while this one focuses on Drupal module and PHP development. It is the Drupal-specific choice in that category.
More from Omedia/drupal-skill
All 3Similar to drupal-backend
More Backend & APIsdrupal-frontendPluginOmedia/drupal-skill28 starsDrupal Front End Specialist skill for theme development, Twig templates, and rendering system (Drupal 8-11+). Use when working with Drupal themes, Twig syntax,
drupal-toolingPluginOmedia/drupal-skill28 starsDrupal development tooling skill for DDEV local environments and Drush command-line operations (Drupal 8-11+). Use when working with Docker-based development en
drupal-developmentSkillmindrally/skills971 installsExpert Drupal 10 module development guidance covering PHP 8+, SOLID principles, and Drupal coding standards.
plugin-devPluginanthropics/claude-code157K starsComprehensive toolkit for developing Claude Code plugins. Includes 7 expert skills covering hooks, MCP integration, commands, agents, and best practices. AI-ass
voltagent-core-devPluginVoltAgent/awesome-claude-code-subagents26.8K starsEssential development subagents for everyday coding tasks - backend, frontend, fullstack, mobile, and API design
engineering-advanced-skillsPluginborghei/Claude-Skills1.2K stars100 engineering skills: architecture, fullstack, DevOps, security, AI/ML, data engineering, and agent tooling