Inject worktree/root path environment variables into setup scripts

Resolved 💬 1 comment Opened Mar 5, 2026 by robinebers Closed Mar 26, 2026

What variant of Codex are you using?

App/CLI

What feature would you like to see?

Add injected environment variables to worktree setup scripts for reliable path access, similar to Conductor.

Current behavior in Codex app:

Setup scripts (configured in local environments) run when creating a new worktree, but they receive no special environment variables providing paths.

The script executes in the worktree directory (so pwd gives the worktree path), but there's no straightforward way to get the absolute path to the main/original repo root (the local checkout you imported).

This forces fragile workarounds like:

  • git rev-parse --git-common-dir then dirname to guess the root
  • Hardcoding paths (no good)

So it's hard to reliably copy non-committed files/folders that live only in the main repo, such as:

  • .env or .env.local
  • .agents/ and .cursor/ (tooling rules/skills/etc)

Comparison to Conductor:

Conductor injects clear env vars into its equivalent setup scripts, e.g.:

  • $CONDUCTOR_ROOT_PATH → main repo root
  • $CONDUCTOR_WORKSPACE_PATH → current workspace/worktree

This allows dead-simple operations like:

# Example in a setup script
cp "${CONDUCTOR_ROOT_PATH}/.env.local" .env.local
ln -sf "${CONDUCTOR_ROOT_PATH}/.agents/.cursor" .agents/.cursor

Proposed change

When executing a worktree setup script, Codex should set (at minimum):

  • CODEX_ROOT_PATH = absolute path to the original/main repository checkout
  • CODEX_WORKTREE_PATH = absolute path to this worktree directory

Thank you!

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗