Codex CLI should support persistent worktree binding and show bound worktree in statusline
Description
Codex should support binding the active agent session to a specific git worktree, and once it enters that worktree it should treat that worktree as the active repository context until explicitly told to leave or switch.
That transition should be possible from either direct user instruction or skill instructions.
While bound to that worktree, the statusline should reflect the bound worktree rather than the main workspace. In practice this means showing the bound worktree's working directory, branch name, commit id, and similar git context, instead of showing those values from the base workspace.
Motivation
When using dedicated issue worktrees, the current statusline can still reflect the main workspace. That makes it hard to confirm which checkout the agent is actually operating in and increases the risk of confusion about where edits and git operations are happening.
The important behavior is persistent binding: if the agent is told to work in a specific worktree, Codex should continue presenting that worktree as the active context until a user action or skill instruction switches it to another context.
Proposed Solution
Add first-class support for changing the agent's active worktree context during a session.
Once bound:
- tool execution should run relative to that worktree
- repository context should come from that worktree
- the statusline should show the bound worktree's path, branch, commit SHA, and related git state
- this binding should remain in effect until the user or a skill explicitly changes it
This should support explicit transitions into, out of, and between worktrees when directed by either the user or skill files, so the visible statusline always matches the actual active worktree context.
Alternatives and Constraints
Related issues already request some worktree and statusline improvements, but this request is specifically about persistent agent binding to a chosen worktree and ensuring the statusline reflects that bound context instead of the main workspace.
I do not have a specific command syntax or API shape requirement as long as:
- entering a worktree is explicit
- remaining in that worktree is sticky
- leaving or switching worktrees can be driven by either the user or skill instructions
- the visible statusline always matches the actual active worktree context
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗