Take Away:
At Tag1, we believe in proving AI within our own work before recommending it to clients. This post is part of our AI Applied series, where team members share real stories of how they're using AI and the insights and lessons they learn along the way. Here, Mauricio Dinarte, inspired by a video by Dries Buytaert, explores using Claude Code to add a graphical user interface to a contributed Drupal module previously available only via the command line.
Background
Earlier this year I watched a video by Dries Buytaert, Drupal project founder. The video is a live demo of using Claude Code for building new features and updating custom code to leverage newer Drupal and PHP APIs. It was quite impressive. I remember doing some of those tasks myself and seeing how Artificial Intelligence (AI) could do the same in a fraction of time ignited my interest in AI-assisted development.
This inspired me to try out Claude Code to improve usability of Drupal's AUTO_INCREMENT Alter module. One use case is to prevent entity ID conflicts when performing Drupal upgrades. Previously, users were required to execute Drush commands or manually call services to perform various database operations. To enhance the module for users not comfortable with the command line, I decided to use AI to create an administration interface that provided feature parity to the functionality already available via CLI tools.
Manually building an administration interface for this module did not seem like a complex task, but I wanted to prove a hypothesis: whether I could accomplish similar results in less time by leveraging AI. Do developers need to write every line of code manually? In my humble opinion, no. Consider how Drush generators and Rector rules can speed up the process of writing and updating Drupal code, respectively. AI can be another tool at your disposal to reduce development time.
Set up
Before getting started, I installed a fresh Drupal 11 project using DDEV. I added the ddev-claude-code add-on by FreelyGive to use Claude Code inside the DDEV container. This approach is useful if you do not have (or do not want) Node.js installed on your host machine.
FreelyGive also maintains the Claude Code module. At the moment it only adds a CLAUDE.md file to provide Drupal-specific context about the project. It is helpful to indicate the version of Drupal, PHP, and the database server being used. You can also provide instructions about adhering to coding standards, writing tests, documenting the generated code, and more. I did not add the module to my project, but used its CLAUDE.md file as a reference. I updated its content with tips from this article on AI assisted development by Jacob Rockowitz, maintainer of the Webform module.
Begin With the End in Mind
To make effective use of AI you need to have a clear idea of what you want to build and translate requirements into descriptive prompts. Before starting with Claude Code I took the time to plan how the interface should look and behave. Then, I created prompts with enough technical details to guide the AI tool in writing a solution aligned to my requirements. For instance, in my initial prompt I explicitly said that I wanted to reuse existing services already present in the module. My goal was to build an alternative to the Drush commands, not to start from scratch.
Below is a slightly modified version of the initial prompt used to work on one of the issues:
This is a Drupal 11 project. We are going to make improvements to the auto_increment_alter module located at web/modules/contrib/auto_increment_alter. Review the module's code in depth. Pay particular attention to the services the module provides. We want to leverage those services to create an administration interface for the auto_increment_alter module.
- Create a new permission "administer auto_increment table values"
- The permission's title should be "Administer AUTO_INCREMENT table values"
- The permission's description should be "Read and alter AUTO_INCREMENT values for tables."
- The new permission should have restricted access.
- Create the "auto_increment_alter.list" route
- The route path will be "/admin/config/development/auto-increment-alter"
- The route title will be "AUTO_INCREMENT table values"
- The route will be accessible only to users with the "administer auto_increment table values" permission
- The route should appear in the "Development" section of Drupal's configuration interface located at "/admin/config"
- When placed in the "Development" section, the title of the menu link should be "AUTO_INCREMENT table values"
- When placed in the "Development" section, the description of the menu link should be "Read and alter AUTO_INCREMENT values for tables."
- When visiting the "auto_increment_alter.list" route, I want to show a table of all Drupal's database tables.
- For each Drupal database table, I want to present the name and the current AUTO_INCREMENT value for that table.
- Implement "hook_help" to provide the following text in the "auto_increment_alter.list" route: "This list shows all tables and their AUTO_INCREMENT value."
In the prompt I mention specific classes and methods. I provide the exact machine names and labels that I want to use. Generally speaking, I aim to provide a technically accurate description of what I need. This level of detail proved to be useful in getting better and faster results. That said, as part of the experiment I occasionally provided loose requirements to see what Claude Code would come up with. Doing so I learned about parts of Drupal’s API I had not explored before. I also learned that AI can fail spectacularly.
Navigating PHP Fatal Errors and AI Hallucinations
Think of AI like a vehicle with autopilot: The driver-assistance system is able to navigate the streets, but ultimately you are in control. For coding tasks, AI can expedite the time to implement a feature, but the developer is responsible for the delivered code. It is imperative to understand the generated code to make sure it achieves the task while meeting functional, performance, and security requirements.
In this project I created five administration pages. For three of them, the initial prompt was enough to get a working interface. For the other two I needed to provide additional prompts to make things work as intended. A couple of times the generated code produced PHP fatal errors. After nudging Claude Code in the right direction, it was able to correct its course and fix the errors.
One of the PHP fatal errors happened because the generated code was redeclaring a property that was already present in the base class. In the next try, Claude Code not only identified and fixed the error, but also leveraged a method available in the base class instead of calling an injected service directly. This is great because leveraging Drupal’s API reduces the amount of custom code that needs to be written and maintained.
Sometimes AI-generated code goes completely off track, producing fatal errors one after another. Or even worse, no apparent error is thrown, but the resulting feature does not work at all. AI can also get stuck in loops repeating the same mistakes again and again. While you can provide follow up prompts (or refine your initial prompts) to improve the generated code, do not hesitate to take back control and update the code yourself. Tools like Claude Code understand outside changes and are able to take them into account on future prompts.
Speaking of PHP fatal errors, have you noticed how creative these AI tools can be? Out of thin air they come up with services, classes, and functions that do not even exist! Or they suggest code that might have worked a decade ago, but not in the current project. For example, using a Drupal 7 function, that was never ported, in a Drupal 11 project. Or leveraging deprecated code removed from the current API a long time ago. What I find most amusing is the confidence AI demonstrates when providing responses that are outright wrong. AI hallucinations can be funny, confusing, and frustrating all at the same time. The moral of the story is to not trust AI blindly. Instead, trust your own coding skills and do not hesitate in taking back control when things go off the rails.
The results
Despite some issues along the way, AI got a lot of things right. It was able to understand a complex codebase, follow technical prompts, respect coding preferences, and ultimately complete that task at hand. Did I prove my hypothesis? Yes, AI-assisted development can save time when working on development tasks. You can see the results in version 1.0.0-alpha5 of the AUTO_INCREMENT Alter module. The new administration interface should make it easier for users to adopt the module in future projects.
As an example, below is one of the three administration interfaces that was created:

Overview page listing current AUTO_INCREMENT values for all tables.

Alter multiple tables based on settings value.

Alter a single content entity by entering new values manually.
Lessons learned
This project was a nice experiment to understand how AI can assist in development tasks. To wrap up this post, I would like to be share some of the lessons I learned along the way:
- Plan before writing the first line of code. Measure twice, cut once.
- Provide project-specific context, including guidelines that should be followed when generating code.
- Be specific with the requirements. Do not let AI tools “think” on your behalf.
- Include technical details in your prompts. The more the merrier.
- Understand the generated code. Do not deliver any code if you do not know what it does.
- Audit for performance and security. You are responsible for the optimal operation of your project and safeguarding its users.
- Remember that you are in control. Do not hesitate to stop the AI when it starts hallucinating.
AI is a powerful and versatile tool that can boost developer efficiency. It can be used to learn new skills, review existing work, or create novel features. It can also be a hindrance when used improperly. As Uncle Ben would say, with great power comes great responsibility. I invite you to explore AI-assisted development on your own to better understand its benefits, limitations, and ethical considerations.
This post is part of Tag1’s AI Applied series, where we share how we're using AI inside our own work before bringing it to clients. Our goal is to be transparent about what works, what doesn’t, and what we are still figuring out, so that together, we can build a more practical, responsible path for AI adoption.