Utilities for creating Git worktrees and launching Codex in the new worktree context.
create-worktree-codex.sh: creates a worktree and launches Codex.install-codextree.sh: installs the script to~/.local/binand adds aliascodextreeto~/.zshrc.- Worktree folder naming format:
<repo-folder>-<worktree-name>.- This helps Codex thread names follow the same format.
- macOS or Linux shell with
bash gitzsh(for alias install flow)- Codex CLI (
codex) for best desktop launch behavior
From this project directory:
./install-codextree.sh
source ~/.zshrcAfter install, use:
codextree --helpcodextree [--app|--cli] <name> [base-ref]name: Worktree and branch name (example:feature-login)base-ref(optional): ref to branch from (default:HEAD)
--app: open Codex desktop app for the new worktree--cli: open Codex CLI in the new worktree (default)-h, --help: show help
Create from current HEAD and open desktop app:
codextree --app feature-authCreate from origin/main and open CLI:
codextree --cli feature-billing origin/mainCreate only, skip launch:
CODEX_NO_LAUNCH=1 codextree feature-refactorCustom worktree parent directory:
WORKTREE_ROOT="$HOME/.worktrees" codextree --app feature-dashboard- Must be run inside a Git repository.
- Worktrees are created under:
- default:
<repo>/.worktrees - override:
$WORKTREE_ROOT
- default:
- New folder path is:
<worktree-root>/<repo-folder>-<worktree-name>
- Branch behavior:
- if branch exists: adds worktree for that branch
- if branch does not exist: creates branch from
[base-ref]
WORKTREE_ROOT: parent dir for worktreesCODEX_CMD: command used to launch Codex (default:codex)CODEX_NO_LAUNCH=1: create worktree without launching CodexINSTALL_DIR: install target for installer (default:~/.local/bin)ZSHRC: zsh config path for installer (default:~/.zshrc)
Operation not permittedduring install:- run install in a shell with permission to write to your home directory.
Error: run this script inside a git repository:cdinto a Git repo first.
- Desktop app did not open:
- use
--appand make surecodexCLI is installed. - on macOS, fallback launch uses
open -a "Codex".
- use