
drupal-frontend
Front-end skill for Drupal theming that covers Twig templates, preprocessing, and asset libraries.
- version
- 1.0.0
- GitHub stars
- 28
What it does
- Covers theme structure, Twig syntax and filters, template suggestions, and preprocessing functions
- Manages CSS and JS libraries, plus responsive design, breakpoints, and accessibility practices
- Includes a complete theming reference (
theming.md), a theme template scaffold, and Twig examples - Designed for Drupal 8 through 11 and later projects where custom themes or Twig templates are being built
Drupal Front End Specialist skill for theme development, Twig templates, and rendering system (Drupal 8-11+). Use when working with Drupal themes, Twig syntax, preprocessing, CSS/JS libraries, or template suggestions.
Add marketplace
/plugin marketplace add Omedia/drupal-skillRun it inside Claude Code once, then install the plugin below.
Install
/plugin install drupal-frontend@drupal-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceDrupal Front End Development
Overview
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+.
When to Use This Skill
Invoke this skill when working with:
- Theme development: Creating or customizing Drupal themes
- Twig templates: Writing or modifying .twig template files
- Preprocessing: Implementing preprocess functions for templates
- Template suggestions: Adding custom template naming patterns
- CSS/JS libraries: Managing theme assets and dependencies
- Responsive design: Implementing breakpoints and mobile-first design
- Rendering system: Understanding Drupal's rendering pipeline
- Theme hooks: Implementing theme-related hooks and alterations
Core Capabilities
1. Theme Development
Build complete, standards-compliant Drupal themes with proper structure:
Quick start workflow:
- Use theme template from
assets/theme-template/as starting point - Replace
THEMENAMEwith your theme's machine name - Replace
THEMELABELwith human-readable name - Customize templates, CSS, JS, and libraries
- Enable theme and configure via Appearance UI
Theme 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 files
Reference documentation:
references/theming.md- Complete theming guide with examples
2. Twig Template System
Master 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 sections
Drupal-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 fields
Common templates:
page.html.twig- Page layout structurenode.html.twig- Node displayblock.html.twig- Block renderingfield.html.twig- Field outputviews-view.html.twig- Views output
3. Preprocessing Functions
Modify 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 document
Best practices:
- Keep logic in preprocess, markup in templates
- Use dependency injection when possible
- Cache properly with cache contexts/tags
- Document complex preprocessing
4. Template Suggestions
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';
}
5. CSS & JavaScript Management
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:
- Global: Define in
.info.yml - Conditional: Use
attach_library()in templates - Preprocessed: Attach in preprocess functions
Best practices:
- Separate CSS into layers (base, layout, component, theme)
- Use CSS aggregation in production
- Minimize JavaScript dependencies
- Leverage Drupal's asset library system
6. Responsive Design
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:
- Design for smallest screens first
- Enhance for larger viewports
- Use responsive images
- Test across devices
- Follow accessibility standards (WCAG)
Development Workflow
Creating a New Theme
-
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:
- Edit
mytheme.info.yml- Set name, regions, base theme - Edit
mytheme.libraries.yml- Define CSS/JS libraries - Replace
THEMENAMEwith your machine name - Replace
THEMELABELwith your label
- Edit
-
Enable the theme:
ddev drush cr # Enable via UI at /admin/appearance or: ddev drush config:set system.theme default mytheme -y -
Enable Twig debugging:
- Copy
sites/default/default.services.ymltosites/default/services.yml - Set
twig.config.debug: true - Set
twig.config.auto_reload: true - Set
twig.config.cache: false - Run
ddev drush cr
- Copy
-
Develop and iterate:
- Modify templates in
templates/ - Update CSS in
css/ - Clear cache frequently:
ddev drush cr - Check browser console for errors
- Modify templates in
Standard Development Workflow
- Enable development settings (Twig debug, disable CSS/JS aggregation)
- Create/modify templates based on suggestions from Twig debug
- Implement preprocessing in
.themefile for complex data manipulation - Add CSS/JS via libraries system
- Test across browsers and devices
- Clear cache after changes:
ddev drush cr
Finding Template Names
With 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.
Common Patterns
Adding Custom Variables in Preprocess
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';
}
Template Inheritance
{# templates/page--article.html.twig #}
{% extends "page.html.twig" %}
{% block content %}
<div class="article-wrapper">
{{ parent() }}
</div>
{% endblock %}
Conditional Library Loading
function mytheme_preprocess_node(&$variables) {
if ($variables['node']->bundle() == 'article') {
$variables['#attached']['library'][] = 'mytheme/article-styles';
}
}
Accessing Field Values in Twig
{# 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 %}
Best Practices
Theme Development
- Base theme: Choose appropriate base (Olivero, Claro, or none)
- Structure: Organize CSS logically (base, layout, components, theme)
- Naming: Use BEM or similar CSS methodology
- Comments: Document complex Twig logic and preprocessing
- Performance: Optimize images, minimize CSS/JS, lazy load when possible
Twig Templates
- Logic: Keep complex logic in preprocess, not templates
- Filters: Use appropriate filters (|t, |clean_class, |safe_join)
- Whitespace: Use {% spaceless %} to control output
- Debugging: Enable Twig debugging during development only
- Suggestions: Use specific templates only when needed
Preprocessing
- Services: Use dependency injection in theme service subscribers
- Caching: Add proper cache contexts and tags
- Performance: Avoid heavy operations in frequently-called preprocessors
- Organization: Group related preprocessing logically
CSS & JavaScript
- Libraries: Group related assets into logical libraries
- Dependencies: Declare all library dependencies
- Loading: Load globally only when necessary
- Aggregation: Enable in production for performance
Accessibility
- Semantic HTML: Use proper elements (header, nav, main, etc.)
- ARIA: Add labels and roles when needed
- Keyboard: Ensure keyboard navigation works
- Contrast: Meet WCAG color contrast requirements
- Alt text: Provide for all images
Responsive Design
- Mobile-first: Design for small screens, enhance for large
- Breakpoints: Define logical breakpoints
- Images: Use responsive image styles
- Testing: Test across devices and screen sizes
- Performance: Optimize for mobile networks
Troubleshooting
Template Changes Not Showing
- Clear cache:
ddev drush cr - Verify file location and naming
- Check Twig debug for active template
- Ensure library is properly defined
CSS/JS Not Loading
- Check library definition in
.libraries.yml - Verify file paths are correct
- Ensure library is attached (globally or conditionally)
- Clear cache and check browser console
Variables Not Available in Template
- Check preprocess function naming
- Verify variables are being set correctly
- Use Twig debugging:
{{ dump() }} - Clear cache after preprocessing changes
Twig Debugging Not Working
- Verify
sites/default/services.ymlexists - Check
twig.config.debug: trueis set - Clear cache:
ddev drush cr - Check file permissions
Resources
Reference Documentation
references/theming.md- Comprehensive theming guide- Twig syntax and filters
- Template suggestions
- Preprocessing patterns
- Library management
- Responsive design
- Best practices
Asset Templates
assets/theme-template/- Complete theme scaffold.info.ymlwith regions and configuration.libraries.ymlwith CSS/JS examples.themewith preprocess examples- Page template
- CSS and JS starter files
Searching References
# 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/
Version Compatibility
Drupal 8 vs 9 vs 10 vs 11
- Twig syntax: Consistent across all versions
- Base themes: Some legacy themes removed in 10+
- Libraries: Same structure across versions
- jQuery: Drupal 9+ doesn't load jQuery by default
- Claro: Admin theme standard in 9+
- Olivero: Frontend theme standard in 10+
Migration Notes
- When upgrading, check for deprecated base themes
- Review jQuery dependencies
- Test with current Twig version
- Check for removed core templates
See Also
- drupal-backend - Module development, hooks, APIs
- drupal-tooling - DDEV and Drush development tools
- Drupal Theming Guide - Official documentation
- Twig Documentation - Twig syntax reference
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-frontend
- Author
- Drupal Skills Team
- Category
- Development
- License
- MIT
- Keywords
- drupal, theming, twig, frontend, css, javascript, templates, preprocessing, responsive-design, drupal-8, drupal-9, drupal-10, drupal-11
- Listed since
- Apr 7, 2026
More from Omedia/drupal-skill
All 3Similar to drupal-frontend
More Frontend & UI Code
drupal-backendOmedia/drupal-skill28 starsDrupal Back End Specialist skill for custom module development, hooks, APIs, and PHP programming (Drupal 8-11+). Use when building custom modules, implementing
drupal-themingtheodorosploumis/drupal-best-practices35 starsTheme development and frontend best practices for Drupal. Provides guidance on creating themes, using Twig templates, theme preprocessing, asset management, and
frontend-designshipshitdev/library39 starsCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill wh
frontend-skillsoikon48/cc-frontend-skills71 starsDistinctive frontend design skills and agents for professional UI implementation
frontend-developerrohitg00/awesome-claude-code-toolkit2.8K starsFrontend component development with accessibility and responsive design
shipshitdev-frontendshipshitdev/library39 starsFrontend development and design skills