Back/Engineering/Codex
IntermediateEngineeringCodex

How to Manage Parallel Development with AI using Git Worktrees and Codex

Avoid merge conflicts and work on multiple features simultaneously by using OpenAI Codex to manage Git worktrees. This workflow lets you run parallel, isolated development tasks directly from your terminal.

From How I AI

How I AI: 3 Advanced Codex Workflows for Faster, Smarter Development with OpenAI's Alex Embiricos

with Claire Vo

How to Manage Parallel Development with AI using Git Worktrees and Codex

Tools Used

Codex

OpenAI's cloud-based AI software engineering agent that can execute code, run tests, and handle complex multi-file tasks autonomously.

Step-by-Step Guide

1

Let Codex Create Your Worktrees

A git worktree lets you have multiple working copies of your codebase checked out to different branches at the same time. Instead of memorizing the commands, use Codex directly in your terminal to create them for you. This lowers the cognitive load of using advanced Git features.

Prompt:
Codex in here, create two new work trees off the main branch, one called French and one called German.
2

Run Parallel Tasks in Isolated Environments

With your worktrees created, you can now assign tasks to Codex in parallel without them interfering. Open a separate terminal tab for each worktree, navigate into the respective directory, and give Codex a distinct task in each one. This allows you to test and develop conflicting ideas simultaneously.

Prompt:
# In the first terminal tab, after navigating to the 'French' directory:
translate the input field placeholder strings to French

# In the second terminal tab, after navigating to the 'German' directory:
translate the input placeholder string to German
3

Review and Merge Changes Independently

Because each task runs in an isolated branch and directory, you can review, test, and merge the resulting changes independently. Once you are satisfied with the changes in one worktree, you can merge its branch into main without affecting the other ongoing work.

Become a 10x PM.
For just $5 / month.

We've made ChatPRD affordable so everyone from engineers to founders to Chief Product Officers can benefit from an AI PM.