drupal-plugins-blocks

Generate Drupal block plugins and custom plugin types with dependency injection.

1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-plugins-blocks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-plugins-blocks
Source: https://github.com/proofoftom/drupal-skills/tree/main/skills/drupal-plugins-blocks
Command: npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-plugins-blocks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the creation of custom block plugins and reusable plugin types within Drupal, ensuring correct dependency injection and adherence to Drupal's plugin system best practices.

Core Features & Use Cases

  • Block Plugin Creation: Scaffold new block plugins with annotations (D10) or attributes (D11).
  • Configuration Forms: Implement forms for block configuration, including default values, validation, and submission handling.
  • Custom Plugin Types: Define and manage custom plugin managers, interfaces, and annotations/attributes for extensible Drupal modules.
  • Dependency Injection: Correctly inject services into plugins using the ContainerFactoryPluginInterface and the 4-parameter create() method.
  • Use Case: Develop a custom block that displays recent blog posts, allowing administrators to configure the number of posts to show and the cache duration via a dedicated form.

Quick Start

Create a Drupal block plugin for a Drupal 11 site that displays a simple message and uses dependency injection.

Frequently Asked Questions about drupal-plugins-blocks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a custom Drupal block with dependency injection?

To create a custom Drupal block with dependency injection, implement the ContainerFactoryPluginInterface and use the 4-parameter create() method to inject required services directly into your block plugin class.

What's the difference between Drupal 10 and Drupal 11 plugin discovery?

Drupal 10 plugin discovery relies on annotations, whereas Drupal 11 utilizes native PHP 8 attributes to define block plugins and custom types, both fully supporting dependency injection patterns.

How do I add a configuration form to a Drupal block plugin?

Add a configuration form to a Drupal block plugin by implementing the form methods that handle default values, user input validation, and submission processing, letting administrators customize block behavior.

How do I build a custom plugin type and manager in Drupal?

Build a custom Drupal plugin type by defining a dedicated plugin manager, interface, and annotation or attribute classes, ensuring your custom module follows Drupal's core plugin system architecture.

Does this approach support configurable blocks for Drupal sites?

Yes, this approach supports configurable blocks by generating the required configuration form methods, enabling administrators to set variables like display limits and cache durations directly.