Introduction
There is a subtle bait-and-switch here: I am going to talk about my experience coding with AI in Python, but the lessons learned apply to Drupal and the broader challenges developers face when coding with AI.
Over the past few months, AIs have begun to understand and write code for Drupal, and I want to understand how AI can help me with my Drupal projects. I would be the first to say “Vibe Coding” sounds like something invented in a hipster cafe, but it is here to stay, just like the Frappuccino.
As a Drupal Developer who has written a lot of PHP code over the years, I welcome the opportunity to write less and think more. Call me old-fashioned, but I am a self-taught developer who learned by reading books, even though AI moves so fast that books on the topic are out of date within a year. I decided to look for a book to help with this journey.
A search for “Coding Drupal with AI” yields very few results, yet it is notable that a post titled “Claude Code meets Drupal” by Dries Buytaert, the creator of Drupal, appears on the first screen of results. Sometimes, when learning something new or facing a new challenge, I like to work around the challenge.
For example, when I first started learning Drupal 8 as an experienced Drupal 6/7 developer, I was stumped by Symfony and the OOP patterns being introduced into Drupal, so I spent a few weeks building a Symfony application and then dove deep into Drupal 8. So I decided to approach AI coding in Python because it is a popular programming language that I was curious to learn. I chose to read Coding with AI: Examples in Python by Jeremy Morgan because it focuses first on AI and secondarily on using Python.
My Goals
My goals for this exploration were to understand the potential and limitations of agentic coding and experience what it is like to “Vibe Code” with only prompts. Along the journey, I expected to shift how I plan and create code. By choosing an unfamiliar programming language, I could begin to understand what it is like to be a junior developer in the age of AI-driven development.
How AI is impacting recent college graduates is concerning. Personally, my kids are in college, facing an uncertain employment future. In the Drupal community, we recognize that our contributors are aging, and we need to mentor the next generation of Drupal developers and contributors. Collectively, junior and senior developers need to figure out how to approach this shift and what it means to build software with AI.
My Approach
My approach was to read the book from beginning to end and let AI teach me along the way. I have a solid understanding of building applications. Still, I was sure there would be code examples or AI-generated code I wouldn’t immediately understand, so I ended up asking the AI a lot of questions.
Needing to ask more questions is one of my most common critiques of junior developers. AI and humans alike yield the best outcomes by fully understanding the problem through questioning and research.
My Process
Because I was unfamiliar with Python’s nuances, I would be vibing a little blind. To compensate, I downloaded the author’s final product for the application, which we would be vibe coding. Their final application gave me a working example with some general understanding of how the final code should be wired together.
AI is learning very fast, which was immediately noticeable because the iterative prompts in the book returned the desired solution on the first prompt. Maybe the LLM read the book, or it’s getting better and better at writing code. Occasionally, it returned code that felt a little magical.
For example, the statement below, for connecting to and reading records from a database, completely baffled me:
with DatabaseConnection(DATABASE_PATH) as cursor:
I asked AI what the heck was going on, and it immediately responded that this is a context manager pattern in Python.
First off, that is a really cool pattern. Second, I wanted to make sure I wouldn’t forget it, so I asked the AI to add its response as a comment above this code in my application. This experience led me to realize that the AI could accelerate my learning by taking notes and generating documentation. The idea that AI could help me better understand the code and remember what I learned is a game-changer for me.
One of my favorite prompts during this exploration was to ask the AI to create a PYTHON.md file in the project root that documented all the common language paradigms and patterns used by the application, and it did so perfectly. I followed up on the prompt by asking AI to include PHP equivalents to the Python examples. This single document became my quick, personalized Python cheatsheet, drawing on my PHP expertise. Yes, I’ve searched the web and gathered multiple resources before to create a similar document manually, but that took several hours rather than a few minutes.
Lastly, I know that at any time I can ask a different AI to review my cheatsheet and refine it with the latest Python language improvements and patterns. As a junior developer learning Drupal, I could ask an AI to highlight Drupal’s specific design patterns. I knew that AI could write code faster than a human, but I now see that it can help me understand code and build better applications.
My Outcome
After two weeks, the Python code is okay, but I am afraid to share it publicly because it is definitely not production-ready. Still, I was impressed by the level of documentation I embedded in the code to ensure I understood how the system worked. For example, in a few months, I am confident I could reopen this code and continue improving the application.
While developing my Python application, I didn’t experience any remarkable ah-ha moments, as I wasn’t working on anything particularly complex. Separately, while playing with AI, it has figured out complex Drupal bugs that had befuddled me for an hour in just a few seconds, leading me to an audible ah-ha moment.
My Conclusion
I am over the fear that AI will replace me, but it will change how I build software and impact my career. The argument that AI writes “bad code” seems ridiculous because developers are letting it write bad code and not giving it “good code” examples. Recognizing AI’s potential to help us improve and learn might be how I can help junior developers become senior developers.
My Next Steps
I recognize that “vibe coding” is a significant shift in software development that I need to explore further. For now, I'll circle back on how to code in Drupal with AI, as it is a big shift for our community. Personally, I want to explore how AI can deepen my understanding of things rather than just build them faster. My goal might be as simple as “Learn more and do less.”
My Takeaways
Below are my thoughts and takeaways for the Drupal community.
More senior developers in the Drupal community should share their agentic Drupal coding workflows so we can learn from one another.
To avoid “AI slop” from polluting our code, we need to provide code examples and documentation to LLMs. Hence, why I am for the core having an AGENTS.md file.
It is possible to leverage AI to mentor new contributor developers, and this is an opportunity we should be open to.
If, as a community, we put our thoughts and passion into this challenge of coding Drupal with AI, we can improve our software and community.
Some Quotes
It helps anyone starting this journey into coding Drupal with AI to search, browse, ask questions, and take notes. I am including several of my references, but I still think it helps to include a few quotes from the referenced blog posts to reinforce why we need to start this journey.
“We’ve opened the door internally for more experimentation with IDEs, models, and other tools that don’t replace the developer but augment his or her ability to deliver features faster.”
-- Ryan Szrama
https://www.centarro.io/blog/exploring-ai-accelerate-drupal-commerce-development
“Despite these limitations, AI capabilities are improving rapidly. Future versions will likely offer increased context windows, better judgment, and reduced hallucinations. Organizations that learn to effectively integrate AI into their Drupal development workflows now will be well-positioned for the increasingly AI-assisted future of web development.”
-- Josh Estep
https://www.prometsource.com/blog/exploring-ai-drupal-development-1
“I should be honest about where I stand. I’ve been writing software with AI tools for over a year now. I’ve had real successes. I’ve also seen some of our most experienced contributors become dramatically more productive, doing things they simply couldn’t do before. That view comes from experience, not hype.”
-- Dries Buytaert
https://dri.es/ai-creates-asymmetric-pressure-on-open-source
References
Book
Modules
Blog posts
- Exploring AI to accelerate Drupal Commerce development | Centarro
- AI-Powered Custom Drupal Module Development | Promet Source
- AI creates asymmetric pressure on Open Source | Dries Buytaert
- Back to the basics: Learning how to build a Drupal module using AI | Jacob Rockowitz
Videos/Presentations
- Claude Code meets Drupal | Dries Buytaert
- Quickly get started using AI to write Drupal modules with Claude Code and a new Drupal Project
- David van 't Westende - Vibe Coding: Drupal Theming in the Age of AI
- Drupal Module Development with AI
- The Future of Drupal Theming: AI, Experience Builder, and Beyond
Main image was generated using Gemini Nano Banana based on the Drupal logo