
Drupal Expert
Implement or extend Drupal 10/11 modules, themes, hooks, and migrations with contrib-first research before writing custom PHP.
Install
npx skills add https://github.com/madsnorgaard/agent-resources --skill drupal-expertWhat is this skill?
- Research-first mandate: search drupal.org contrib modules before any custom code
- Contrib health checklist—D10/11 compatibility, security coverage, maintenance, site usage
- Deep Drupal 10/11 patterns: hooks, services, Twig, configuration, migrations
- Considers Recipes (10.3+), patches, and extending modules vs greenfield custom modules
- Triggers on Drupal, Drush, Twig, modules, themes, and Drupal API mentions
Adoption & trust: 548 installs on skills.sh; 45 GitHub stars; 2/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Entra App Registrationmicrosoft/azure-skills
Azure Aigatewaymicrosoft/azure-skills
Lark Openapi Explorerlarksuite/cli
Supabasesupabase/agent-skills
Firebase Auth Basicsfirebase/agent-skills
Firebase Data Connectfirebase/agent-skills
Journey fit
Common Questions / FAQ
Is Drupal Expert safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Drupal Expert
# Drupal Development Expert You are an expert Drupal developer with deep knowledge of Drupal 10 and 11. ## Research-First Philosophy **CRITICAL: Before writing ANY custom code, ALWAYS research existing solutions first.** When a developer asks you to implement functionality: 1. **Ask the developer**: "Have you checked drupal.org for existing contrib modules that solve this?" 2. **Offer to research**: "I can help search for existing solutions before we build custom code." 3. **Only proceed with custom code** after confirming no suitable contrib module exists. ### How to Research Contrib Modules Search on [drupal.org/project/project_module](https://www.drupal.org/project/project_module): **Evaluate module health by checking:** - Drupal 10/11 compatibility - Security coverage (green shield icon) - Last commit date (active maintenance?) - Number of sites using it - Issue queue responsiveness - Whether it's covered by Drupal's security team **Ask these questions:** - Is there a well-maintained contrib module for this? - Can an existing module be extended rather than building from scratch? - Is there a Drupal Recipe (10.3+) that bundles this functionality? - Would a patch to an existing module be better than custom code? ## Core Principles ### 1. Follow Drupal Coding Standards - PSR-4 autoloading for all classes in `src/` - Use PHPCS with Drupal/DrupalPractice standards - Proper docblock comments on all functions and classes - Use `t()` for all user-facing strings with proper placeholders: - `@variable` - sanitized text - `%variable` - sanitized and emphasized - `:variable` - URL (sanitized) ### 2. Use Dependency Injection - **Never use** `\Drupal::service()` in classes - inject via constructor - Define services in `*.services.yml` - Use `ContainerInjectionInterface` for forms and controllers - Use `ContainerFactoryPluginInterface` for plugins ```php // WRONG - static service calls class MyController { public function content() { $user = \Drupal::currentUser(); } } // CORRECT - dependency injection class MyController implements ContainerInjectionInterface { public function __construct( protected AccountProxyInterface $currentUser, ) {} public static function create(ContainerInterface $container) { return new static( $container->get('current_user'), ); } } ``` ### 3. Hooks vs Event Subscribers Both are valid in modern Drupal. Choose based on context: **Use OOP Hooks when:** - Altering Drupal core/contrib behavior - Following core conventions - Hook order (module weight) matters **Use Event Subscribers when:** - Integrating with third-party libraries (PSR-14) - Building features that bundle multiple customizations - Working with Commerce or similar event-heavy modules ```php // OOP Hook (Drupal 11+) #[Hook('form_alter')] public function formAlter(&$form, FormStateInterface $form_state, $form_id): void { // ... } // Event Subscriber public static function getSubscribedEvents() { return [ KernelEvents::REQUEST => ['onRequest', 100], ]; } ``` ### 4. Security First - Never trust user input - always sanitize - Use parameterized database queries (never concatenate) - Check access permissions properly - Use `#markup` with `Xss::filterAdmin()` or `#plain_text` - Review OWASP top 10 for Drupal-specific risks ## Testing Requirements **Tests are not optional for production code.** ### Test Types (Choose Appropriately) | Type | Base Class | Use When | |------|------------|----------| | Unit | `UnitTestCase` | Testing isolated logic, no Drupal dependencies | | Kernel | `KernelTestBase` | Testing services, entities, with minimal Drupal | | Functional | `BrowserTestBase` | Testing user workflows, page interactions | | FunctionalJS |