refactor

Detect god classes and fat controllers in Drupal custom code.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Identifies over-engineering and anti-patterns in Drupal custom code to enable safer, clearer refactors and faster maintenance.

Core Features & Use Cases

  • Detect God Classes (large, multi-responsibility types) and Fat Controllers, suggesting focused services.
  • Detect Missing Interfaces and promote interface-driven design to improve testability and modularity.
  • Provide concrete before/after code examples and refactoring guidance applicable to Drupal components like services, hooks, and controllers.
  • Real-world use: review a custom module and generate a prioritized refactor plan with recommended changes.

Quick Start

Run a quick inline code review pass on a Drupal project to surface refactoring opportunities and run suggested modernization patterns.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I identify refactoring opportunities in Drupal custom modules?

To identify refactoring opportunities in Drupal custom modules, analyze the codebase for god classes, fat controllers, and missing interfaces. This process detects anti-patterns and suggests focused services to reduce coupling and improve maintainability.

What are common Drupal code anti-patterns that require refactoring?

Common Drupal code anti-patterns requiring refactoring include god classes with multiple responsibilities, fat controllers, and missing interfaces. Addressing these through service decomposition and single responsibility principle improves modularity and testability.

How do I refactor a fat controller in Drupal to use services?

To refactor a fat controller in Drupal, extract business logic into focused services. This service decomposition separates concerns, reduces coupling, and promotes interface-driven design, resulting in concrete before and after code examples for maintainability.

Does this refactoring approach work with custom Drupal hooks?

Yes, this refactoring approach works with custom Drupal hooks. It applies to codebases containing custom modules and hooks, outlining recommended patterns and modernization techniques to reduce coupling across Drupal components like services and controllers.

When should I not use interface-driven design in Drupal?

Interface-driven design in Drupal may be unnecessary for simple, single-responsibility modules where adding interfaces would cause over-engineering. Avoid forcing interface patterns if the component does not require testability or service decomposition for maintainability.