CodeGraph Maps Drupal's Hidden Dependencies for AI Coding Assistants

Framework-Aware Code Navigation and the Limits of Static Dependency Analysis
Discover Drupal graphic saying grep misses pieces of Drupal code, with CodeGraph 1.6.3's resolver tracing service, route, hook and plugin links so AI assistants get context before touching a method. A subtitle credits Marcelo Vani's Drupal 11 backend. A photo of Marcelo Vani fades into the right of the frame.

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

A computed field asks for a value\Drupal::service('my_module.example')->getValue()
✕ The trail stops at the service ID
The graph cannot tell which class answersNo link from the ID to PHP code
 
The service method looks isolatedgetValue(): no callers identified

Result: an assistant could wrongly treat the method as unused

With Drupal-aware mapping

A computed field asks for a value\Drupal::service('my_module.example')->getValue()
↓ The ID is matched in *.services.yml
The service definition names its classmy_module.example points to a PHP class
↓ The call is linked to that class
The graph identifies a callergetValue() is linked to the computed field

Result: the assistant can see the dependency before proposing changes

Conceptual illustration based on the computed-field example reported by Marcelo Vani. Service and method names are placeholders; this is not CodeGraph output or an independently reproduced test.

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.

Disclosure: This content is produced with the assistance of AI.

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please reach out to us at #thedroptimes channel on Drupal Slack and we will try to address the issue as best we can.

Related People

Upcoming Events

Latest Opportunities