You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displayenhancementNew feature or requestsessionIssues involving session (thread) management, resuming, forking, naming, archiving
codex unintenally deletes some files which is not tracked by git.
codex unintenally modify something when something is not git committed.
It bites me several times in recent days and I miss the /undo feature each time.
Additional information
No response
Reacted by Stefan Hueg, Xynonners, Eivind Norling, 배동훈, tom-bomba, Ignat Remizov, b20lopez, Feng Liyuan, Karol Gusak, Franco Marchesoni and 499 more
Reacted by Vivek Patel, haume, TaggartMaher, Pa3k5, Haowei Wen, Tran Ngoc Thanh Binh, Roee Klinger, Pedro Henrique Dos Santos, Yumo Bai, Archit Checker and 42 more
codex unintenally deletes some files which is not tracked by git.
This happened to me too just these last days, out of nowhere, been using codex since it was available, and never had this happen to me before. Suddenly it wants to "keep the git repository clean" and deletes anything regardless of it existing before starting codex or not, it doesn't seem to realize what side-effects the commands it runs actually have.
Work around, actually check things into git or keep out of reach from Codex.
git is the real solution rather than /undo here as well, the sooner you learn it, the faster you'll be able to continue working without waiting for something to come back, which likely won't come back :) Ask codex to help you learn git ;)
Reacted by Rob Royce, Alexey, Zuch Huang, 天然純真, Adomas, digitalhurricane-io, Chenlu Ye, zzy-life, John Miller, Mykola Veryha and 5 more
I find this mainly an issue where I'm working on something in a session, fine with the last few changes codex made, then it makes a bad change. If I don't remember to do a stash before the bad change then how am I supposed to revert without loosing all my progress?
I find this mainly an issue where I'm working on something in a session, fine with the last few changes codex made, then it makes a bad change. If I don't remember to do a stash before the bad change then how am I supposed to revert without loosing all my progress?
Its gone.. asking codex to fix it will make it worse. Im forced to go back to using Claude.
Google anti Gravity is also a great alternative.
Reacted by Rob Royce, Antonio, Zuch Huang, 忍野ペンギン, Monawwar Abdullah, aki4nvr, Mykola Veryha, Batuhan Ayhan, Vasiliy-Makogon and Arham
@etraut-openai Could you revert it back? If there is a particular reason to hide it, could you put it in experimental and warn people the reason when we enabling it?
@SunRunAway, the previous experimental implementation had problems. It was causing many issues even for users who did not use the feature. If we bring it back, it will need to be redesigned.
I use the following prompt as a hack to get codex to undo its changes:
I don’t like it. Undo the changes you just made in your previous message using the patch tool. Do not use git commands to revert your work. Do not touch anything else that appears changed unless you modified it directly in this session.
I use it often and it works reliably. It just takes longer. If you need to revert multiple turns, you have to send the prompt, wait for the llm to finish, backtrack and rinse-repeat.
The only caveat is that it cannot bring back deleted files. I agree with @embedding-shapes - even if the undo feature existed, it should not be considered a first line of defense against accidental file deletion.
Until /undo is back, a workaround that works with any agent, including Codex: npx @abelo9996/snap-back wrap -- codex takes snapshots before and during the session into a separate shadow git repo, and snap-back undo restores the files, including ones that were deleted. Your own .git, index and stash are never touched. It cannot undo side effects outside the project (database writes, network calls).
Until /undo is back, a workaround that works with any agent, including Codex: npx @abelo9996/snap-back wrap -- codex takes snapshots before and during the session into a separate shadow git repo, and snap-back undo restores the files, including ones that were deleted. Your own .git, index and stash are never touched. It cannot undo side effects outside the project (database writes, network calls).
Disclosure: I wrote it. https://github.com/Abelo9996/snap-back
Yalla with this malware dude... its 200,000 lines the whole github repo dude.
Dude..
lol it's literally around 2k lines of code and I've tested it pretty thoroughly.... but sure
I would also like /undo (or a separate /retract / /unsend command) to support retracting the most recently sent user message, not only reverting code or filesystem changes.
A common case is sending a prompt by mistake, sending it to the wrong thread, or immediately realizing that it contains incorrect instructions. Stopping the turn does not fully solve this because the incorrect message remains in the conversation and may continue affecting later context.
Ideally, the action would:
stop the active turn if it is still running;
remove or exclude the last user message from future model context;
restore the message text to the composer so it can be edited and resent;
clearly warn that tool actions already completed may not be reversible.
A conversation-only retract would already be valuable even if code rollback remains a separate feature.
30. > > Until /undo is back, a workaround that works with any agent, including Codex: npx @abelo9996/snap-back wrap -- codex takes snapshots before and during the session into a separate shadow git repo, and snap-back undo restores the files, including ones that were deleted. Your own .git, index and stash are never touched. It cannot undo side effects outside the project (database writes, network calls).
> > Disclosure: I wrote it. https://github.com/Abelo9996/snap-back
>
>
> Yalla with this malware dude... its 200,000 lines the whole github repo dude.
> Dude..
lol it's literally around 2k lines of code and I've tested it pretty thoroughly.... but sure
something like this should be minified into 400 lines , cap
Until a first-party /undo / /rewind lands, one gap git alone doesn't cover is untracked / gitignored files the agent deletes or rewrites mid-session. I built a small open-source CLI, agentckpt, as an external safety net that works with Codex (and Claude Code / Cursor / OpenCode / …) without forking them:
Snapshots (including untracked files) live in a private shadow store under .agentckpt/. It never runs git add / git commit or moves branches in your real .git. agentckpt watch can auto-snap while the agent works. Honest limits: it restores the working tree, not the conversation; it can't undo DB/network side effects; respects .gitignore and skips files over 10 MiB by default.
For anyone who needs this now: Bellows, a desktop app for Windows, macOS and Linux that runs Codex (alongside Claude, Gemini CLI, Qwen Code and any ACP agent), has undo for Codex built in.
Every message you send records a restore point first. Choose Rewind files here on any earlier message, or Restore points in Ctrl+K, and the project goes back to how it was then: files Codex changed are put back, files it made are removed, and files it deleted come back, whether Codex did it with an edit or a shell command. Nothing needs to be committed, and the record lives in Bellows' own data folder, never in your project or your git history. Before you rewind, it also lists anything the agent did since that the files can't take back, like a push or a deploy.
This kept biting me too, mostly with untracked files. Codex would rm something that wasn't committed yet and it was just gone.
I got annoyed enough that I built a small workaround while waiting for /undo to come back: unwreck It uses Codex hooks to snapshot the working tree at every turn, including untracked and gitignored files, and keeps the snapshots outside the repo. When something breaks, you run unwreck undo in another terminal.
cargo install unwreck && unwreck hooks --write
Disclaimer: I wrote it, and it's v0.1.0, so expect some rough edges. It doesn't replace a native /undo, but it's covered me for the "codex deleted my uncommitted stuff" case. Happy to hear if it breaks for anyone.
After reading the whole thread, I think the long back-and-forth is mostly people asking for three different things under one name:
"Take back my message." I hit Enter too early, or sent a vague prompt, and want it out of the context. (@jbergq, @Jason-Wang313, @I571664)
"Put my files back." Codex deleted or rewrote something git never saw: untracked files, .env, a file made and changed within one turn. (@zba, @S2thend)
"Undo what it did out in the world." Commands, migrations, API calls. (@ignatremizov's write-up covers this well.)
"Just use git" only answers part of #2. Wanting #1 is the most common case in this thread, and it's the one that needs no file system work at all.
Suggested order, smallest and safest first:
Ship update summary to auto #1 on its own first:/undo removes the last user turn and puts the text back in the composer. If tools already ran, show one plain line: "3 commands already ran; this doesn't reverse them." It's cheap, it can't touch the user's disk, and it avoids whatever made the old version cause trouble for people who never used it.
Treat move all tests under tests/ #3 as a report, not an undo. Listing what can't be reversed is already most of the value. Trying to reverse shell commands automatically is where trust gets lost.
The real product question is what the word "undo" promises. Most people in this thread read it as "everything goes back the way it was". If the first version only does #1, I'd name it /rewind or /retract, or say clearly that files aren't touched, so nobody gets a nasty surprise.
Open question for the team:@etraut-openai mentioned the old version caused problems even for people who didn't use it. Was that the per-turn file tracking cost? If so, a conversation-only first step avoids it completely, and could land well before the file part is redesigned.
In case it helps anyone while /undo is gone: I built mulligan, a small CLI that uses Codex's hooks to snapshot the project at every prompt and before every tool call, into a separate git repository outside your project. mulligan list shows the timeline, mulligan diff 3 what changed since a point, and mulligan undo 3 puts everything back, including changes made by shell commands, not just apply_patch. mulligan redo takes the undo back.
mulligan setup codex prints the hooks for .codex/hooks.json (they need to be trusted in /hooks). It never touches your own repo's history, index or stash, and has no network access. One binary for macOS and Linux, MIT. It's been tested against Codex's documented hook format rather than many real sessions yet, so reports are welcome.
27. This kept biting me too, mostly with untracked files. Codex would rm something that wasn't committed yet and it was just gone.
I got annoyed enough that I built a small workaround while waiting for /undo to come back: unwreck It uses Codex hooks to snapshot the working tree at every turn, including untracked and gitignored files, and keeps the snapshots outside the repo. When something breaks, you run unwreck undo in another terminal. cargo install unwreck && unwreck hooks --write
Disclaimer: I wrote it, and it's v0.1.0, so expect some rough edges. It doesn't replace a native /undo, but it's covered me for the "codex deleted my uncommitted stuff" case. Happy to hear if it breaks for anyone.
Check it out: https://github.com/ayushdoesdev/unwreck
If the edit went through apply_patch before the loss, ~/.codex/sessions/ still holds the full - and + diff hunks in the rollout .jsonl even with no git history. I built a small cli (deja-vu) that walks those recorded hunks to reconstruct the file to -o without touching the working tree (0.8 ms lookup across 19,195 local sessions in our day-zero run). Raw shell rm on a file Codex never patched still needs a pre-turn snapshot, though.
If that would help you before a native fix lands, a 👍 on issue #1 there tells me whether it's worth building. A native /undo in Codex would of course be the better outcome.
If that would help you before a native fix lands, a 👍 on issue #1 there tells me whether it's worth building. A native /undo in Codex would of course be the better outcome.
is a better link for nowhttps://github.com/yarahmouni/shellundo/blob/main/README.md?plain=1
please rename the README.md into skill.MD
and make a normal readme refrencing where its used
but in my option i just to use my slopping agents slowly but surely , if my codex is making a mistake i tell it WHAT THE HELL DID YOU DO ??? PLEASE REVERT THIS ONE CHANGE "no i am not happy , please refactour the whole codebase"
TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displayenhancementNew feature or requestsessionIssues involving session (thread) management, resuming, forking, naming, archiving
Activity
github-actions commentedon Jan 14, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
b20lopez commentedon Jan 15, 2026
Bro i lost too much progress just because the/undo is gone!!!! :( :( :(
Please put it back.
embedding-shapes commentedon Jan 15, 2026
This happened to me too just these last days, out of nowhere, been using codex since it was available, and never had this happen to me before. Suddenly it wants to "keep the git repository clean" and deletes anything regardless of it existing before starting codex or not, it doesn't seem to realize what side-effects the commands it runs actually have.
Work around, actually check things into git or keep out of reach from Codex.
git is the real solution rather than /undo here as well, the sooner you learn it, the faster you'll be able to continue working without waiting for something to come back, which likely won't come back :) Ask codex to help you learn git ;)
TraFriTCR commentedon Jan 15, 2026
I find this mainly an issue where I'm working on something in a session, fine with the last few changes codex made, then it makes a bad change. If I don't remember to do a stash before the bad change then how am I supposed to revert without loosing all my progress?
b20lopez commentedon Jan 16, 2026
Its gone.. asking codex to fix it will make it worse. Im forced to go back to using Claude.
Google anti Gravity is also a great alternative.
SunRunAway commentedon Jan 16, 2026
@etraut-openai Could you revert it back? If there is a particular reason to hide it, could you put it in experimental and warn people the reason when we enabling it?
etraut-openai commentedon Jan 16, 2026
@SunRunAway, the previous experimental implementation had problems. It was causing many issues even for users who did not use the feature. If we bring it back, it will need to be redesigned.
miraclebakelaser commentedon Jan 17, 2026
I used the feature often as well.
I use the following prompt as a hack to get codex to undo its changes:
I use it often and it works reliably. It just takes longer. If you need to revert multiple turns, you have to send the prompt, wait for the llm to finish, backtrack and rinse-repeat.
The only caveat is that it cannot bring back deleted files. I agree with @embedding-shapes - even if the undo feature existed, it should not be considered a first line of defense against accidental file deletion.
embedding-shapes commentedon Jan 17, 2026
I'm not sure what the use of this feature is? Is my workflow different from others? How I work with Codex:
Is this workflow different from how other people are using it? Are others not using git and saving/undoing via git when needed?
b20lopez commentedon Jan 21, 2026
Ohhh,,, you read its work.
Hehe, for me who rely on /undo
I only check which files its working in..
I let it code. Observe the actual app.
if it did what i wanted, good, If not.
Most likely going to use /undo.
If AI is having a hard time,, thats the only time i read its code and find a solution myself.
other IDE's /coding agent have History you can switch back easily.
Claude, Cursor, AntiGravity
I dont know why in Codex they make it hard to undo
87 remaining items
Mahkhmood9 commentedon Oct 5, 2026
Yalla with this malware dude... its 200,000 lines the whole github repo dude.
Dude..
Abelo9996 commentedon Oct 5, 2026
lol it's literally around 2k lines of code and I've tested it pretty thoroughly.... but sure
Jason-Wang313 commentedon Oct 7, 2026
I would also like
/undo(or a separate/retract//unsendcommand) to support retracting the most recently sent user message, not only reverting code or filesystem changes.A common case is sending a prompt by mistake, sending it to the wrong thread, or immediately realizing that it contains incorrect instructions. Stopping the turn does not fully solve this because the incorrect message remains in the conversation and may continue affecting later context.
Ideally, the action would:
A conversation-only retract would already be valuable even if code rollback remains a separate feature.
Mahkhmood9 commentedon Oct 11, 2026
something like this should be minified into 400 lines , cap
Blackman99 commentedon Oct 13, 2026
Until a first-party
/undo//rewindlands, one gap git alone doesn't cover is untracked / gitignored files the agent deletes or rewrites mid-session. I built a small open-source CLI, agentckpt, as an external safety net that works with Codex (and Claude Code / Cursor / OpenCode / …) without forking them:Snapshots (including untracked files) live in a private shadow store under
.agentckpt/. It never runsgit add/git commitor moves branches in your real.git.agentckpt watchcan auto-snap while the agent works. Honest limits: it restores the working tree, not the conversation; it can't undo DB/network side effects; respects.gitignoreand skips files over 10 MiB by default.Disclosure: I wrote it. Demo:
uvx --from git+https://github.com/Blackman99/agentckpt agentckpt demo· https://github.com/Blackman99/agentckptStill worth upvoting this issue either way — a proper in-product rewind is the right long-term fix.
bellowsai commentedon Oct 19, 2026
Disclosure: I'm Rob, and I built this.
For anyone who needs this now: Bellows, a desktop app for Windows, macOS and Linux that runs Codex (alongside Claude, Gemini CLI, Qwen Code and any ACP agent), has undo for Codex built in.
Every message you send records a restore point first. Choose Rewind files here on any earlier message, or Restore points in Ctrl+K, and the project goes back to how it was then: files Codex changed are put back, files it made are removed, and files it deleted come back, whether Codex did it with an edit or a shell command. Nothing needs to be committed, and the record lives in Bellows' own data folder, never in your project or your git history. Before you rewind, it also lists anything the agent did since that the files can't take back, like a push or a deploy.
How it works: https://bellowsai.app/guides/undo-a-coding-agent-file-changes?utm_source=github&utm_medium=reply
Give it a try and tell me what would make it better. We act fast on feedback.
ayushdoesdev commentedon Oct 20, 2026
This kept biting me too, mostly with untracked files. Codex would rm something that wasn't committed yet and it was just gone.
I got annoyed enough that I built a small workaround while waiting for /undo to come back: unwreck It uses Codex hooks to snapshot the working tree at every turn, including untracked and gitignored files, and keeps the snapshots outside the repo. When something breaks, you run unwreck undo in another terminal.
cargo install unwreck && unwreck hooks --writeDisclaimer: I wrote it, and it's v0.1.0, so expect some rough edges. It doesn't replace a native /undo, but it's covered me for the "codex deleted my uncommitted stuff" case. Happy to hear if it breaks for anyone.
Check it out: https://github.com/ayushdoesdev/unwreck
balabommablock-cpu commentedon Oct 20, 2026
After reading the whole thread, I think the long back-and-forth is mostly people asking for three different things under one name:
.env, a file made and changed within one turn. (@zba, @S2thend)"Just use git" only answers part of #2. Wanting #1 is the most common case in this thread, and it's the one that needs no file system work at all.
Suggested order, smallest and safest first:
/undoremoves the last user turn and puts the text back in the composer. If tools already ran, show one plain line: "3 commands already ran; this doesn't reverse them." It's cheap, it can't touch the user's disk, and it avoids whatever made the old version cause trouble for people who never used it.The real product question is what the word "undo" promises. Most people in this thread read it as "everything goes back the way it was". If the first version only does #1, I'd name it
/rewindor/retract, or say clearly that files aren't touched, so nobody gets a nasty surprise.Open question for the team: @etraut-openai mentioned the old version caused problems even for people who didn't use it. Was that the per-turn file tracking cost? If so, a conversation-only first step avoids it completely, and could land well before the file part is redesigned.
stanczykwyatt commentedon Oct 30, 2026
In case it helps anyone while
/undois gone: I built mulligan, a small CLI that uses Codex's hooks to snapshot the project at every prompt and before every tool call, into a separate git repository outside your project.mulligan listshows the timeline,mulligan diff 3what changed since a point, andmulligan undo 3puts everything back, including changes made by shell commands, not justapply_patch.mulligan redotakes the undo back.mulligan setup codexprints the hooks for.codex/hooks.json(they need to be trusted in/hooks). It never touches your own repo's history, index or stash, and has no network access. One binary for macOS and Linux, MIT. It's been tested against Codex's documented hook format rather than many real sessions yet, so reports are welcome.Mahkhmood9 commentedon Nov 5, 2026
@Blackman99
Incorrect implementation of a very basic idea that exwist in git already
I think anyway you can stretch it, it should bound to the source control you are using.
git is powerful as it is. Learn the correct
gitfunctionshttps://git-scm.com/videos
dont reinvate, things considered basic to why git was even invented and was needed
Mahkhmood9 commentedon Nov 5, 2026
https://sapling-scm.com/
is better
vshulcz commentedon Nov 21, 2026
If the edit went through
apply_patchbefore the loss,~/.codex/sessions/still holds the full-and+diff hunks in the rollout.jsonleven with no git history. I built a small cli (deja-vu) that walks those recorded hunks to reconstruct the file to-owithout touching the working tree (0.8 ms lookup across 19,195 local sessions in our day-zero run). Raw shellrmon a file Codex never patched still needs a pre-turn snapshot, though.yarahmouni commentedon Nov 23, 2026
While this is open: I'm considering building a small agent-agnostic tool for this gap. It would snapshot the working tree before each agent turn through hooks, then restore what changed or was deleted, including through shell commands, without needing git. Nothing exists yet; the README describes the plan: https://github.com/yarahmouni/shellundo
If that would help you before a native fix lands, a 👍 on issue #1 there tells me whether it's worth building. A native
/undoin Codex would of course be the better outcome.iqdoctor commentedon Nov 23, 2026
+1
Mahkhmood9 commentedon Nov 29, 2026
is a better link for nowhttps://github.com/yarahmouni/shellundo/blob/main/README.md?plain=1
please rename the README.md into skill.MD
and make a normal readme refrencing where its used
but in my option i just to use my slopping agents slowly but surely , if my codex is making a mistake i tell it WHAT THE HELL DID YOU DO ??? PLEASE REVERT THIS ONE CHANGE "no i am not happy , please refactour the whole codebase"