Allow `codex app` to attach an existing worktree to its repository project
What variant of Codex are you using?
App and CLI
What feature would you like to see?
Please let codex app accept both a parent repository path and an existing Git worktree path, then attach that worktree to the repository's existing Codex project instead of creating a separate project.
For example:
codex app /path/to/repo --worktree /path/to/existing-worktree
The existing worktree should:
- appear under the parent repository project in the sidebar;
- be selectable in "Where to run the task";
- keep its current branch and Git state untouched;
- work when created by external tools such as Worktrunk.
Codex could validate the relationship through Git's common directory or git worktree list. If that worktree is later removed, Codex should stop offering it as a runnable environment while preserving its task history.
Additional information
Current behavior: running codex app /path/to/existing-worktree opens that checkout as a separate Codex project, even though Git knows it belongs to the same repository.
This prevents a Worktrunk lifecycle hook from integrating cleanly with Codex: the hook can open a newly created worktree, but it cannot associate it with the parent project.
Related issues: #26622 and #12863. This request focuses specifically on a supported CLI/API for passing both the parent repository path and an already-existing worktree path.