tip if you're moving from cc to codex and miss the `--worktree` flag, here's a workaround name=$(grep -E '^[a-z]{4,10}$' /usr/share/dict/words | shuf -n 3 | paste -sd- -) && git worktree add -b "worktree-$name" ".codex/worktrees/$name" && codex -C ".codex/worktrees/$name" save it as a shortcut in your `.zshrc` and you've basically got the equivalent, minus the auto cleanup
and here's a flair of this command that lets you do something in codex that you CAN'T do with cc's `--worktree` it fences codex into the worktree so it doesn't get confused or try to run tests or write code outside it name=$(grep -E '^[a-z]{4,10}$' /usr/share/dict/words | shuf -n 3 | paste -sd- -) && wt=".codex/worktrees/$name" && git worktree add -b "worktree-$name" "$wt" && codex -C "$wt" -s workspace-write -a never -c 'sandbox_workspace_write.network_access=true' makes the new worktree the workspace root, keeps codex in `workspace-write`, disables approval prompts with `-a never`, and enables network access inside that sandbox
one more versions that can let codex handle git operations like commit/push/pr but keeps the worktree fence codex stays rooted in the new worktree as its workspace, can edit and run commands there, and can use network inside `workspace-write` because of the config override if a git action needs to step outside the workspace sandbox, like certain metadata writes or other protected operations, codex can stop and ask for approval instead of just failing name=$(grep -E '^[a-z]{4,10}$' /usr/share/dict/words | shuf -n 3 | paste -sd- -) && wt=".codex/worktrees/$name" && git worktree add -b "worktree-$name" "$wt" && codex -C "$wt" -s workspace-write -a on-request -c 'sandbox_workspace_write.network_access=true'
1.54K