CodeGraph Maps Drupal's Hidden Dependencies for AI Coding Assistants
The open-source code analysis tool CodeGraph has expanded its Drupal support to help AI coding assistants trace dependencies that are not expressed through direct function or method calls. The integration recognises relationships established through Drupal's routing, hook, service and plugin systems.
CodeGraph builds and maintains a local index of a project's source code for AI coding tools such as Claude Code and Codex. Drupal presents a particular challenge for conventional code analysis because its modules interact through naming conventions, configuration files and framework discovery mechanisms. Searching for direct callers of a method may therefore overlook parts of the application that depend on it.
Drupal developer Marcelo Vani demonstrates this problem in a Medium article documenting his experience with CodeGraph on a Drupal 11 headless backend. A computed field retrieves its value through a service identified by its service ID. Without Drupal-specific dependency resolution, the graph showed no callers for the service method. The expanded integration identified the connection between the method and the computed field, providing context that an AI coding assistant could otherwise miss when assessing whether the method is still needed.
What Changes When the Graph Understands Drupal
Without Drupal-aware mapping
\Drupal::service('my_module.example')->getValue()Result: an assistant could wrongly treat the method as unused
With Drupal-aware mapping
\Drupal::service('my_module.example')->getValue()Result: the assistant can see the dependency before proposing changes
Building Drupal-Aware Dependency Maps
Marcelo proposed Drupal support in May 2026. His initial implementation introduced route extraction, procedural hook detection and support for indexing Drupal-specific PHP files, including .module, .install, .theme and .inc files.
CodeGraph maintainer Colby McHenry subsequently expanded the Drupal resolver, incorporating approaches from contributions by Mike Damoiseau and Marcelo. The implementation, merged on 30 October 2026 and included in the 17 November release of CodeGraph 1.6.3, added service-container relationships, plugin discovery and attribute-based hook recognition. It also enabled the graph to trace method calls made through service identifiers to their corresponding PHP classes.
Marcelo reports that CodeGraph identified 730 Drupal-specific relationships across approximately 1,600 files and 17 custom modules in the Drupal 11 backend. These include 188 service definitions linked to their classes, 76 plugins, 13 routes and 134 method calls resolved through the service container. The figures describe one Drupal implementation and do not establish the tool's accuracy or performance across other projects.
Where Dependency Mapping Remains Incomplete
The same implementation exposes several limitations. CodeGraph currently requires hook definitions to be present in the index to establish the corresponding relationships. Marcelo's backend contains 185 attribute-based hook implementations, but the graph linked only 37 to their definitions because Drupal core was not indexed. He documents this limitation in a GitHub issue. A separate issue records the absence of dependency extraction from within Twig templates. He also identifies calls on injected interfaces, which do not reach the implementing class, as the biggest remaining gap in Drupal code. In addition, getSubscribedEvents() is not linked to the methods it lists.
GitHub contributor AdityaxDeore opened three pull requests on 2 December 2026 proposing corrections to procedural hook self-references, event subscriber method resolution and PHP interface method resolution. All three were open and unmerged when checked on 3 December 2026. The proposals are not released fixes.
The project's 1.6.7 release, published on 30 November, also introduces optional prompt-hook integration for Codex CLI, allowing the assistant to receive relevant indexed code before selecting its first tool.
Framework-aware dependency mapping can provide additional context for AI-assisted refactoring and code navigation. However, the unresolved Drupal-specific limitations mean that an apparent absence of callers in the graph is not sufficient evidence that a method is unused. Runtime behaviour and the consequences of proposed changes still require verification.


