Harness Notes

Worktrees

Updated 2026-11-22,

On this page

How each harness creates an isolated checkout, what it starts from, and what happens to the changes afterward. Worktrees isolate files; conversation forks and subagent context are separate. Unknown answers mark gaps in the recorded evidence, not proof that a capability is absent.

Forking: conversation history and file isolation

Subagents: delegation and workspace isolation

QuestionCodex CLIchecked at 0.164.0
Create or enter

Start a local session with codex --worktree or codex exec --worktree. The local TUI new/fork picker offers Create new Git worktree; /worktree browses managed worktrees.

CLI/TUI source inspected at 0.164.0. Desktop Worktree mode is a separate host surface.

Starting state

The inspected CLI/TUI creation paths pass no base override, so the manager creates a detached checkout of the source checkout's current HEAD. Tracked edits, staged changes and untracked files are not carried over. The default allocation root is $CODEX_HOME/worktrees.

The host-local desktop.git-worktree-root setting can override the root. A detached checkout has no new branch until you create one.

Session isolation

New sessions can run in a managed worktree. codex fork <id> --worktree and codex exec fork <id> --worktree copy a conversation into a new checkout. The CLI rejects --worktree with resume, queue, archive, unarchive and delete; fork requires an explicit session.

The inspected --worktree startup path requires local execution and refuses an explicitly untrusted source.

0.165.0 TUI resume picker adds a Repo filter alongside Cwd and All when several local worktrees exist, listing sessions from matching directories across linked worktrees. The Cwd filter and resume --last/fork --last still use only the current directory.

Subagent isolation

Partly

The inspected built-in spawn path prepares a child config using the parent turn's cwd; it does not allocate a worktree in that path. A chat in a managed worktree and a subagent with its own worktree are separate capabilities.

This describes the traced built-in path, not every custom host, remote provider or extension.

Setup and environment files

Not documented

Provision dependencies and local environment files in the new checkout. The inspected manager materializes committed files; this audit has not established an automatic dependency setup or ignored-file copying mechanism for CLI worktrees.

Do not infer desktop setup behavior from the CLI manager or from shared root settings.

Review and integrate changes

Partly

Review the detached checkout and preserve the result on a branch or in commits before integrating it with normal Git operations. The inspected creation path returns a checkout with no branch; it does not establish a desktop Apply or automatic merge contract.

Exit and cleanup

CLI settings explicitly disable automatic cleanup. The TUI worktree browser supports explicit removal through the manager: it refuses the current checkout and ignored local files, then calls git worktree remove without force. Thread history is retained.

The manager's removal checks are source evidence, not a runtime-tested guarantee about unpushed commits or desktop cleanup.

CLI, tools and APIs

Partly

CLI entry points create the checkout locally before using App Server. App Server thread/start and thread/fork accept a cwd; that field selects a directory and does not by itself establish a worktree-creation API. A client can arrange a checkout before supplying its path.

The traced CLI caller and protocol are distinct. Custom hosts and hosted worktree services remain outside this audit.

Commands

From your shell

Commands you run in a terminal or script, outside a session.

TaskCodex CLIchecked at 0.162.1
Set up
Create

codex [exec] --worktree

Start a new local session in a managed detached Git checkout. Explicit session forks also accept --worktree.

1 note

Source inspected at 0.164.0; no worktree lifecycle runtime probe.

Inside a session

Slash commands you type into an open session.

TaskCodex CLIchecked at 0.162.1
Use
Open the manager

/worktree

Browse managed worktrees and choose actions, including explicit removal.

1 note

Source inspected at 0.164.0; no worktree lifecycle runtime probe.

Notes and sources

Codex CLI, 14 sources
  • Source inspection at rust-v0.164.0 (6aaac694803004a63c6f393d153c96d22521a6b9). No lifecycle runtime probe; desktop, hosted services and custom/cloud providers are outside the traced paths.
Create or enter, 4
Starting state, 4
Session isolation, 3
Subagent isolation, 2
Setup and environment files, 1
Review and integrate changes, 1
Exit and cleanup, 4
CLI, tools and APIs, 3