Knowledges 4 min

ZAF 01 - Claude Code vs Codex - Worktree

Claude Code and Codex both support worktrees, but where they put the worktree folders breaks the relative paths in CLAUDE.md/AGENTS.md. Here's why, and how I fixed it with the /ak:worktree skill.

Also in: Tiếng Việt · 中文 · 한국어 · 日本語

ZAF 01 - Claude Code vs Codex - Worktree

Anyone here using worktrees? I only learned about worktrees about a year ago myself, around when Claude Code picked them up.

What is a worktree?

Roughly speaking, a "worktree" is a copy of some branch in your git repo. Creating a new worktree is like doing git clone <repo-url> and then git checkout <branch>.

That way you can work in parallel in 2 different folders on 2 different git branches, and when you're done, just open a PR to merge into the shared branch.

Worktrees in Claude Code & Codex

Okay, both Claude Code & Codex support worktrees now, and when you start a new session there's always a "worktree" option. But the two of them set up worktrees a little differently: where the worktree folders live.

1. Claude Code

In the terminal you can start Claude Code with claude -w <name>. In the Claude desktop app, just tick the "worktree" checkbox and pick the branch to fork from.

By default Claude puts worktree folders with random names right inside the project: .claude/worktrees/<random-name>/

These random names are pretty annoying, because when you need to clean up or find something again, the folder name tells you nothing about what that worktree is doing... Also, when I open the project in an IDE (like VSCode) with a bunch of unfinished worktrees, git just lags (partly because my crappy M1 Pro Mac is weak).

2. Codex

In the terminal, open codex and use natural language to create a worktree (there's no built-in command/skill), e.g. "create a worktree from branch origin/dev". In the Codex desktop app it works like Claude: tick worktree when starting a new session and you're done.

Locked section: Time to complain

Locked section: The fix: the /ak:worktree skill

The rest is for Knowledges members

Plus 2 more sections (about 2 min) for members

You are reading roughly the first third. Knowledges, Combo and Community plans unlock paid articles in full; the Zuey AI plan reads previews only.