Building your own dev environment with AI (and why I stick with DDEV)

A few days ago I read a post by Randy Fay on the DDEV blog that basically asks whether it's worth building your own development environment with AI or just using DDEV: Vibe-Code Your Own Local Dev Environment, or Use DDEV?. Randy has skin in the game, and he says so himself. But what caught my attention wasn't his answer, which was pretty predictable. It was finding out how many people are building their environment from scratch because, with AI, "it's easy".

And Randy is fair to the other side too: he admits that if you work alone on similar PHP projects, a home-made setup might do the job. The trouble starts when that's not your case.

First, for anyone who isn't a developer. A local development environment is the copy of the website we developers work on: its web server, its PHP, its database... all set up on our own machine so we can break things without anyone noticing. DDEV is a free tool that sets all of that up for you with a couple of commands, using Docker containers. It's been in development for almost ten years and in the Drupal world it's, for lack of a better word, the de facto standard.

Setting it up is easy. Maintaining it is another story

And it is easy. You ask an agent to spin up a web server, PHP and a database, and in an afternoon you've got it running. That's not where the problem is. The problem shows up five months later.

When you've got ten projects and they all share the same database, on the same version. When someone new joins the team and has to redo the whole setup by hand, because the configuration lives on the computer of whoever built it. When a client has an old site that needs a different PHP version. Or when an operating system update breaks something first thing on a Monday and the only person who knows how to fix it is on holiday.

The post mentions one of these home-made tools: about 37,000 lines of code and a repository that was five days old. Five days. Look, I'm not saying it's badly built, it might be brilliant. But I can't picture a client with a public administration portal trusting something that didn't exist last week.

I already touched on this in The frog boiling in your repo: AI is incredibly fast at generating code, but it doesn't care who's going to maintain it afterwards. The same thing happens with a development environment. Cheap to set up, sure. Cheap to maintain, not even close.

What DDEV already has solved

If you're a project manager and your team suggests building their own environment with AI, this is the part you'll care about. Everything I described above, DDEV solves out of the box.

Each project is isolated, with its own services, so you can have ten sites running at once without them getting in each other's way. Each one with the PHP and database version it needs. Web addresses and HTTPS certificates are generated automatically. And most importantly for a team: the environment configuration is stored inside the project itself. Whoever joins downloads the project, runs one command and has exactly the same setup as everyone else, whether they're on Linux, Mac or Windows.

On top of that, it has over 300 add-ons for adding services (search engines, caches...) and a community behind it maintaining it. When a new PHP version comes out or something changes in Docker, it's not on you to fight with it.

My setup: everything on a server, nothing on the laptop

I work like this with all my clients' projects, with one twist: I don't have it on my laptop. I have it all on a server of my own, at home. It's still a local environment, because it's on my network and doesn't depend on anyone, but it doesn't live on the machine I'm typing on.

Specifically, it's a virtualized server inside Proxmox, running DDEV on Linux. I moved it there, as I explained in the 256 GB Frankenstein article, so my work doesn't depend on the laptop. The server isn't working 24 hours a day, but it's close. I can leave the agents with a task, head out or go to bed, and the work keeps running on the server unattended. If I've got the laptop switched off in my backpack, the task doesn't stop.

When they're done, they leave everything ready for me. And when I sit down to work, I open the laptop, look at what code they've changed and check that everything works as it should.

One copy of the project per branch

The structure is very simple. I have a projects folder, inside it one folder per client, and inside each client a main folder, "main", which is the reference version of the project with its DDEV.

/proyectos
└── cliente-a                                  ← client alias: "cla"
    ├── main                                   ← the main one
    ├── worktrees/                             ← client alias + branch
    │   ├── cla-feature-buscador               ← branch "feature-buscador"
    │   └── cla-fix-migracion                  ← branch "fix-migracion-usuarios-drupal7",
    │                                             with an alias to shorten it
    └── worktrees-tmp/                         ← temporary ones for the agents
        ├── cla-feature-buscador-claude-code   ← created and deleted automatically
        └── cla-feature-buscador-opencode

Next to the main one there's another folder, "worktrees", with a working copy for each branch I'm on. Simplifying a lot: a branch is a separate line of work (a new feature, a fix...) and a worktree is Git's way of having several branches of the same project open at once, each in its own folder. That way I don't have to keep switching branches and reinstalling everything every time.

The interesting part is how it fits with DDEV. If you don't give the project a fixed name in its configuration, DDEV takes it from the folder name. So each worktree automatically becomes an independent site, with its own address and its own database. Same project, several branches, all running at once without stepping on each other. I can have one with a half-finished migration, another reviewing a colleague's work and another with an urgent fix.

Watch out for one detail. Since DDEV takes the web address from the folder name, if two clients have a branch with the same name (and it happens more than you'd think), both sites would want the same address and they'd clash. That's why the folder isn't named after the branch alone: it has a client alias in front. And the script also lets me give the branch an alias, because web addresses have a character limit and, with a folder name that's too long, DDEV just throws an error.

To create them I use a script, a small file that does the steps for me. I give it the branch name and it creates the worktree, loads the main project's database into it (DDEV takes database "snapshots" with a single command), installs the dependencies and applies the configuration. A couple of minutes and it's ready to work.

There's nothing mysterious about it. I've tweaked mine to my liking, but if you want one, ask your AI of choice. This is where it's perfect: a small script on top of a tool that other people already maintain. Not a whole environment you'll then have to maintain yourself.

And on top of that, the agents

All of this connects with the DDEV add-ons I've published, the DDEV AI Workspace. They add Claude Code, OpenCode, a browser so the agents can test the site and a few more things to each project. Alongside it there's the repository of agents and skills for Drupal, drupal-ai-agents, also free. If you work with AI on Drupal, I'd recommend giving it a try. In my case, OpenCode also uses the local model running on that same server, and in the previous article I explain how I've configured it.

The nice thing is how it fits with the worktrees. Each worktree has its own agents, independent from the rest of the projects, and they can only touch that worktree's code and site. They work in isolation. If one messes up, the rest don't even notice.

The temporary ones, where the agents fight it out

There's a third folder, "worktrees-tmp", that I don't touch. Temporary worktrees get created and destroyed there automatically for complex tasks, the kind I don't trust to a single pass.

The idea is this: I take a task from a branch and give it to several agents with different models at the same time. For example, Claude Code in one temporary worktree and OpenCode in another, doing exactly the same thing. Each with its own site and its own database, without knowing anything about the other. It's what I call the arena, and I explained it in more detail in How I work with AI today.

When they finish, the changes are merged into a single branch with the best of each attempt, a regular worktree is created with that branch and the temporary ones disappear. What's left is my part: checking that everything works properly on that branch and making the commit. That, for now, I don't delegate.

What I'd do

If you ask me, work with DDEV. It makes your life easier. There's a ton already done, it works on Linux, Mac and Windows, and the configuration travels with the project. I use it on Linux because that's my thing, but that doesn't matter.

There's no need to reinvent the wheel. You just need to adapt a bit to the tool and build on top of it whatever you need, which in my case is a couple of scripts and a few add-ons. And the most flexible tool I know for that, right now, is DDEV.

I know what you're going to tell me: that in a year AI will set up and maintain these environments on its own, without anyone having to touch anything. Maybe so, I won't rule it out. But for now I'd rather spend my tokens on my clients' code and not on maintaining my own Docker.

Before it was a ticket. Now it's a prompt.

Does your Drupal leak?

Tell me what you are working on and what worries you. I'll reply personally and, if I'm not the right person, I'll tell you too.