These days I use agents that write code often.
When I am trying to build a new feature, I first write a markdown spec, then point the agent at it and send it on its way.
There are a lot of tools and choices today in the agent space.
I regularly use 3-4 different ones, and I expect that number to continue to vary.
When you send an agent off to write code, you need to wait.
If you have more work to do, especially work that is unrelated to the current changes the agent is making, it would be nice to unblock that work as well.
Git worktree makes this possible
A git repository can support multiple working trees, allowing you to check out more than one branch at a time.
— https://git-scm.com/docs/git-worktree
We’re going to ask an agent to write a CLI to call the web server, supporting arguments, the input parameters, and dealing with the different HTTP methods for us.
This is a pretty contrived and even ill-defined task.
In my head, a successful outcome could be something like a hybrid between rails routes and curl.
But also, I’m not too worried about the outcome.
I just needed an excuse to use a worktree.
Write a generic CLI that can call the web server. The CLI should inspect the server route and input args to determine the inputs and flags to call the server.
It should automatically extend to future routes added with no additional modification required, supporting optional and required arguments and enforcing type constraints.
For example, based on the existing main.py, the CLI should support
We’ve just created a new folder at the same level as our original project.
Now let’s send claude-code off to work with the prompt above.
These days, I paste my prompts or specs into a specs folder, then prompt the agent with something like “Implement @specs/cli.md”
I’ve been meaning to try OpenAI’s Codex, so let’s create another worktree and send it off on the same task.
Terminal window
gitworktreeadd../openai-codex
cd../openai-codex
OpenAI sent me a email because they noticed I hadn’t tried the gpt-4.1 model.
I’m not sure I want to reward that behavior and give them a conversion, mostly because it just means I’ll get more emails but I digress.
I launched codex and set it on its way
Terminal window
codex-mgpt-4.1
I sent it the same prompt as claude-code, referencing the spec file I wrote.
codex and gpt-4.1 seemed to have a pretty hard time with this ask.
The agent spent most of its time checking dependency installation, trying to run the web server, and looking around the project.
I started over, ensuring I had the dependencies installed and the virtualenv activated.
This second attempt, I tried with o4-mini.
It felt noticeably slower than gpt-4.1, but it did eventually write the CLI.
For both models with codex, it was kind of hard to understand what the agent was intending to accomplish.
codex prompts you to approve the commands it runs at each step but doesn’t provide much context on why it wants to run them.
You can read them to ensure they are safe, but it’s hard to assess whether the agent is on the right path — something that in my experience is pretty critical to getting good results.
Git worktrees provide a straightforward primitive to working on multiple independent tasks within a project at the same time using agents.
I don’t feel like my work here actually benefitted from using worktrees mostly because the agents didn’t actually take that much time to write the code relative to me figuring out how to make worktrees.
That said, with a larger task or test suite that I could point the agent at as a goal, I could see worktrees being highly useful for longer agent runs, if you set up and task scope allow for it.