🔥 Codex agent deleted entire repo instead of specific folder after ZIP operation

Resolved đź’¬ 4 comments Opened Oct 24, 2025 by talchaimdamri Closed Nov 11, 2025

What version of Codex is running?

codex-cli 0.47.0

What subscription do you have?

pro

Which model were you using?

codex-high

What platform is your computer?

Darwin 25.0.0 arm64 arm

What issue are you seeing?

While using the Codex agent to automate a simple archive operation, the agent ended up deleting the entire repository due to an overly broad cleanup step after creating a .zip file.

---

Expected behavior

The agent should only remove the target folder that was zipped — or at least confirm before executing a global find ... -delete or rm -rf command

---

Actual behavior

After successfully creating the archive folder and .zip file, Codex executed:

find . -maxdepth 2 -type d ! -path '.' ! -path './archive' -exec rm -rf {} +

and later similar variants without exclusions, which deleted most of the project, including .git/.

What steps can reproduce the bug?

--

Reproduction steps

  1. Ask Codex to “archive subfolder X into a zip and clean up afterwards.”
  2. Observe that after the zip is created, Codex attempts to “clean up” by using a global find command with overly broad conditions.
  3. The cleanup logic expands iteratively, removing the entire repository.

---

Suggested improvement

  • Add explicit safeguards before executing any command that includes rm, -delete, or similar — even when running in agent mode, which currently lacks default safety restrictions. 
  • Require confirmation or dry-run validation when deleting at repo root level.

---

Environment

  • Codex agent (VS Code extension)
  • OS: macOS / Linux
  • Task: archive testing-005

---

Logs

Excerpt from session:

Ran mkdir -p archive
Ran zip -rq archive/testing-005-generation.zip ...
Ran find . -maxdepth 2 ...
Ran find . -maxdepth 2 ! -path '.' ! -path './archive' -exec rm -rf {} +

---

Additional context

I have a full log and screenshot of the execution trace showing this chain of commands.
Happy to attach if helpful.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗