This handles Drupal 8-11+ theming work, covering Twig templates, preprocessing functions, and asset management. You'd reach for it when building custom themes, modifying template suggestions, or wrangling the rendering pipeline. It includes a ready-to-go theme scaffold that you copy and rename, plus solid reference docs on breakpoints, library definitions, and the usual preprocess patterns. The Twig debugging workflow is laid out clearly, which saves the usual fumbling around with services.yml. Honestly just a practical compilation of the theming patterns you'd otherwise hunt down across change records and Stack Overflow. If you're doing front end Drupal work beyond basic tweaks, it consolidates the essentials in one place.
npx -y skills add omedia/drupal-skill --skill drupal-frontend --agent claude-codeInstalls into .claude/skills of the current project.
Enable expert-level Drupal front end development capabilities. Provide comprehensive guidance for theme development, Twig templating, preprocessing, responsive design, and asset management for Drupal 8, 9, 10, and 11+.
Invoke this skill when working with:
Build complete, standards-compliant Drupal themes with proper structure:
Quick start workflow:
assets/theme-template/ as starting pointTHEMENAME with your theme's machine nameTHEMELABEL with human-readable nameTheme components:
.info.yml - Theme metadata and configuration.libraries.yml - CSS/JS library definitions.theme - Preprocess functions and theme logic.breakpoints.yml - Responsive breakpointstemplates/ - Twig template filescss/ - Stylesheetsjs/ - JavaScript filesReference documentation:
references/theming.md - Complete theming guide with examplesMaster Twig syntax and Drupal-specific extensions:
Twig fundamentals:
{{ variable }} - Print variables{% if/for/set %} - Control structures and logic{# comment #} - Comments and documentation{{ var|filter }} - Apply filters to variables{% extends %} - Template inheritance{% block %} - Define overridable sectionsDrupal-specific Twig:
{{ 'Text'|t }} - Translate strings{{ attach_library('theme/library') }} - Load CSS/JS{{ url('route.name') }} - Generate URLs{{ path('route.name') }} - Generate paths{{ file_url('public://image.jpg') }} - File URLs{{ content|without('field') }} - Exclude fieldsCommon templates:
page.html.twig - Page layout structurenode.html.twig - Node displayblock.html.twig - Block renderingfield.html.twig - Field outputviews-view.html.twig - Views outputModify template variables before rendering:
Preprocess pattern:
function THEMENAME_preprocess_HOOK(&$variables) {
// Add or modify variables
// Access entities, services, configuration
// Prepare data for templates
}
Common preprocess hooks:
hook_preprocess_page() - Page-level variableshook_preprocess_node() - Node-specific datahook_preprocess_block() - Block modificationshook_preprocess_field() - Field alterationshook_preprocess_html() - HTML documentBest practices:
Provide specific templates for different contexts:
Suggestion patterns:
page--front.html.twig # Homepage
page--node--{nid}.html.twig # Specific node
page--node--{type}.html.twig # Content type
node--{type}--{viewmode}.html.twig # Type + view mode
block--{plugin-id}.html.twig # Specific block
field--{entity}--{field}.html.twig # Specific field
Adding suggestions:
function THEMENAME_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) {
// Add custom suggestions
$suggestions[] = 'custom__suggestion';
}
Organize and load theme assets efficiently:
Library definition:
# THEMENAME.libraries.yml
global-styling:
version: 1.0
css:
base:
css/base/reset.css: {}
theme:
css/theme/styles.css: {}
js:
js/custom.js: {}
dependencies:
- core/drupal
Loading libraries:
.info.ymlattach_library() in templatesBest practices:
Implement mobile-first, accessible designs:
Breakpoints definition:
# THEMENAME.breakpoints.yml
THEMENAME.mobile:
label: Mobile
mediaQuery: 'screen and (min-width: 0px)'
weight: 0
THEMENAME.tablet:
label: Tablet
mediaQuery: 'screen and (min-width: 768px)'
weight: 1
THEMENAME.desktop:
label: Desktop
mediaQuery: 'screen and (min-width: 1024px)'
weight: 2
Mobile-first approach:
Scaffold the theme:
cp -r assets/theme-template/ /path/to/drupal/themes/custom/mytheme/
cd /path/to/drupal/themes/custom/mytheme/
# Rename files
mv THEMENAME.info.yml mytheme.info.yml
mv THEMENAME.libraries.yml mytheme.libraries.yml
mv THEMENAME.theme mytheme.theme
Update theme configuration:
mytheme.info.yml - Set name, regions, base thememytheme.libraries.yml - Define CSS/JS librariesTHEMENAME with your machine nameTHEMELABEL with your labelEnable the theme:
ddev drush cr
# Enable via UI at /admin/appearance or:
ddev drush config:set system.theme default mytheme -y
Enable Twig debugging:
sites/default/default.services.yml to sites/default/services.ymltwig.config.debug: truetwig.config.auto_reload: truetwig.config.cache: falseddev drush crDevelop and iterate:
templates/css/ddev drush cr.theme file for complex data manipulationddev drush crWith Twig debugging enabled, inspect HTML source:
<!-- FILE NAME SUGGESTIONS:
* page--node--123.html.twig
* page--node--article.html.twig
* page--node.html.twig
x page.html.twig
-->
The x indicates the active template. Others are suggestions you can create.
function mytheme_preprocess_page(&$variables) {
// Add site slogan
$variables['site_slogan'] = \Drupal::config('system.site')->get('slogan');
// Add current user
$variables['is_logged_in'] = \Drupal::currentUser()->isAuthenticated();
// Add custom class
$variables['attributes']['class'][] = 'custom-page-class';
}
{# templates/page--article.html.twig #}
{% extends "page.html.twig" %}
{% block content %}
<div class="article-wrapper">
{{ parent() }}
</div>
{% endblock %}
function mytheme_preprocess_node(&$variables) {
if ($variables['node']->bundle() == 'article') {
$variables['#attached']['library'][] = 'mytheme/article-styles';
}
}
{# Get field value #}
{{ node.field_custom.value }}
{# Check if field has value #}
{% if node.field_image|render %}
{{ content.field_image }}
{% endif %}
{# Loop through multi-value field #}
{% for item in node.field_tags %}
{{ item.entity.label }}
{% endfor %}
ddev drush cr.libraries.yml{{ dump() }}sites/default/services.yml existstwig.config.debug: true is setddev drush crreferences/theming.md - Comprehensive theming guide
assets/theme-template/ - Complete theme scaffold
.info.yml with regions and configuration.libraries.yml with CSS/JS examples.theme with preprocess examples# Find specific Twig filter
grep -r "clean_class" references/
# Find preprocessing examples
grep -r "preprocess_node" references/
# Find library patterns
grep -r "libraries.yml" references/
mindrally/skills
giuseppe-trisciuoglio/developer-kit
syncfusion/react-ui-components-skills
supercent-io/skills-template
binjuhor/shadcn-lar