openai / openai/codex-plugin-cc
feat: git worktree isolation for write-capable rescue tasks
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Problem
When /codex:rescue runs with --write, it uses Codex's native workspace-write sandbox, which edits files directly in the current working directory. This creates conflicts when:
- Concurrent uncommitted work — The user has staged/unstaged changes in their working tree. Codex's edits interleave with the user's in-progress work, making it hard to separate what Codex changed from what the user was already doing.
- Parallel Claude + Codex work — Claude Code may be actively editing files in the same directory while Codex rescue is running in the background. Both agents writing to the same files creates race conditions and merge conflicts.
- Safe rollback — If Codex's changes are unwanted, the user has to manually
git checkoutindividual files or usegit stashtricks. With a worktree, you justgit worktree removeand it's gone.
Proposed Solution
For write-capable rescue tasks, optionally create a git worktree so Codex operates in an isolated copy of the repository:
git worktree add .worktrees/codex-<timestamp> -b codex/<timestamp>
Then run the Codex task against the worktree path instead of the main working directory. After completion:
- Keep: Generate a patch from the worktree and apply it to the main tree, or let the user merge the branch
- Discard:
git worktree remove+git branch -D
This could be exposed as a --worktree flag on /codex:rescue, or made the default for background write tasks where the risk of conflict is highest.
Prior Art
I built a custom Codex skill for Claude Code that uses this exact pattern — subagent creates a worktree, runs codex exec -s workspace-write inside it, then presents a diff for review before applying. It works well in practice and eliminates the concurrent-edit problem entirely.
Alternatives Considered
- Stash-based isolation:
git stashbefore Codex runs, restore after. Fragile and loses staged vs unstaged distinction. - Branch-based: Just create a branch. Doesn't help — still editing the same working directory.
- Do nothing: Users accept the risk. Works for simple cases but breaks down with background tasks or concurrent editing.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /codex:rescue write path and inspect how codex exec currently uses the workspace-write sandbox. Review the proposed git worktree add, patch or merge, and removal flow, including the --worktree option. Done means write-capable rescue tasks can run in an isolated worktree and clearly support keeping or discarding the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, javascript
- Domain
- cli, devtools, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100