Dries Buytaert Introduces AI-Generated Rector Rules for Drupal Upgrades
Automation of Drupal upgrade workflows is the focus of a new experiment by Dries Buytaert, who has introduced a system that uses artificial intelligence to generate Rector rules for Drupal API migrations automatically. In a recent post titled “AI-generated Rector rules for Drupal”, Dries describes how the system analyses Drupal Core commits, issue discussions, and related code changes to produce migration rules intended for use with Drupal Rector.
Drupal Rector is commonly used to automate parts of Drupal upgrade processes by rewriting deprecated code patterns into newer API implementations. Traditionally, Rector rules have been written manually, requiring contributors to review change records, study implementation edge cases, identify real-world usage patterns, and validate transformations across different environments. The new experiment explores whether large parts of that migration work can be automated through AI-generated rules.
According to Dries, the project extends Drupal Digests, a tool originally created to summarise important developments across the Drupal ecosystem. The system now also processes Drupal Core issue queues and associated commits to generate corresponding Rector rules whenever deprecated APIs or new coding patterns are introduced.
The system has generated more than 175 Rector rules during its first weeks of operation, with additional rules continuing to be added as more Drupal Core issues are processed. Dries notes that AI-generated code remains imperfect and may still contain bugs or miss implementation edge cases, but argues that broader testing across real Drupal projects will help improve reliability over time.
The article also acknowledges contributions from Björn Brala, co-maintainer of Drupal Rector, who assisted in testing and validating some of the generated migration rules after discovering the project. Dries describes that feedback process as important for identifying weaknesses in generated rules and improving practical upgrade reliability.
One example highlighted in the article involves Drupal 11.2’s deprecation of the $entity->original property. The generated Rector rule rewrites older property access patterns to use the newer getOriginal() and setOriginal() methods that will remain supported in Drupal 12.
The workflow allows developers to clone the Drupal Digests repository, run Rector against custom modules, and test generated migration rules locally using a provided configuration file. The project is positioned as a partial automation layer intended to reduce repetitive migration work rather than eliminate manual review entirely.
The experiment reflects broader interest within the Drupal ecosystem in using AI-assisted tooling to streamline maintenance, upgrade preparation, and long-term platform modernisation as Drupal Core continues evolving through regular API deprecations and architectural changes.


