Handing Work from Claude Code to Codex with Uncommitted Changes
About This Article
When I handed work from Claude Code to Codex while there were uncommitted changes in the repository, those changes were unintentionally lost. This article documents what happened and the steps I now follow to hand off safely.
What Is a Dirty Worktree?
Git is a tool that tracks the history of file changes. When a file is changed, a “commit” records that change as a save point.
A “dirty worktree” is the state where there are changes that have not yet been committed — files have been edited and saved, but no save point (commit) has been created yet.
Handing off to Codex in this state can cause problems.
What Can Go Wrong
Codex works by referencing the GitHub repository. Committed changes are reflected on GitHub, but uncommitted changes do not exist there.
If Codex modifies the same file and creates a new commit, the uncommitted changes can be lost. Codex treats the committed state as the correct baseline, so it has no way of knowing that additional changes exist on top of it.
This is exactly what happened to me. I had changed several files with Claude Code and, thinking “I’ll hand the rest off to Codex,” gave the handoff instruction without committing first. Codex modified the same files with different content, and the changes I had made with Claude Code were overwritten.
Steps for a Safe Handoff
Step 1: Check the Current State of Changes
Before handing off, confirm what has changed.
git status
git diffgit status shows which files have been modified. git diff shows the actual content of those changes.
Step 2: Generate the agent-handoff Document
Update the handoff document to record the current state.
npm run agent:handoffIn the generated file, note explicitly that uncommitted changes exist and list which files were changed.
Step 3: Decide Whether to Commit or Stash
The right action depends on the situation.
If the changes are complete: Commit them before handing off to Codex.
git add <changed files>
git commit -m "Note about what was done"If the changes are in progress: Use a stash. A stash is an operation that temporarily sets aside changes without creating a commit.
git stashStashed changes can be restored later with git stash pop.
Step 4: Confirm a Clean State Before Handing Off
Once the commit or stash is done, run git status to confirm a clean state — no uncommitted changes. Then give Codex the handoff instruction along with the agent-handoff document.
What to Do If the Sequence Was Wrong
If Codex has already made changes and you realize afterward that earlier work is missing, git reflog may let you see the state before the changes.
git reflogHowever, changes that were not stashed are not tracked, so if Codex overwrote them, recovery may not be possible. Following the steps in the right order is the best preventive measure.
Summary
- A dirty worktree is the state where uncommitted changes exist in the working tree
- Handing off to Codex with uncommitted changes can result in those changes being overwritten
- Safe handoff sequence: check changes → update the handoff document → commit or stash → confirm a clean state → give Codex the handoff instruction
- In-progress changes can be set aside temporarily with a stash
- Recovering lost changes can be difficult, which makes following the sequence important