anomalyco / anomalyco/opencode
Desktop agent unexpectedly deleted an existing project directory after I only requested changing the working directory
@Brendonovich is already working on this.
Since Jul 21, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Description
First of all, thank you for OpenCode. It has been an amazing development tool for me, and I'm opening this issue because I hope it can prevent similar incidents for other users.
This is not intended as a complaint, but as feedback about a potentially dangerous Desktop behavior.
What happened
I initially asked the Desktop agent to create a new project.
The agent first created the project on my Windows desktop.
Since my desktop was cluttered, I simply told it:
"Move the directory to D:\AI\opencode"
That was my complete instruction regarding the directory. The remainder of my prompt only described the program I wanted it to build.
I never instructed the agent to delete anything.
During execution, the Desktop app requested permission to run shell commands.
Because I had previously used the terminal version of OpenCode without encountering destructive behavior, I assumed this was a routine permission request for file operations and approved it without expecting anything unusual.
Instead, the agent executed:
Remove-Item -LiteralPath "D:\AI\opencode" -Recurse -Force
It recursively deleted the entire existing directory before copying the new project.
That directory already contained dozens of my original projects accumulated over roughly a year.
After deleting them, the agent proceeded to generate nearly 2 GB of new files in the same location, which overwrote much of the deleted data and made recovery effectively impossible.
Why I'm reporting this
Afterward, I asked the agent why it had deleted the directory.
It acknowledged that:
- I only asked it to move the project into
D:\AI\opencode. - I never instructed it to delete the directory.
- It chose to execute
Remove-Item -Recurse -Forceon its own. - It did not inspect the existing directory contents before deleting it.
- It should have listed the directory contents first and asked me how to proceed if files already existed.
I think this highlights a UX and safety issue rather than simply a model mistake.
Suggestions
I believe the Desktop application should add additional safeguards for destructive filesystem operations.
For example:
- Never recursively delete an existing directory simply because the user requested moving or copying a project into it.
- Always inspect the destination directory before performing destructive actions.
- If the directory already contains files, ask the user how they want to proceed instead of assuming it is safe to delete.
- Show a dedicated warning for recursive deletion commands such as
Remove-Item -Recurse -Forceorrm -rf. - Clearly display the directory that will be deleted, the number of files, and the estimated size before asking for permission.
- Consider adding protected folders or trusted workspaces that cannot be recursively deleted without an additional confirmation.
I understand that I approved the shell permission request, so I am not claiming I bear no responsibility.
However, I did not expect that a simple request to move a project into an existing directory would cause the agent to recursively delete that directory first.
Again, I really appreciate OpenCode and hope this feedback helps improve the Desktop experience. I don't want anyone else to lose months or years of work because of a single destructive command that was easier to approve than it should have been.
Contributor guide
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.
Assessment
This issue has not been assessed yet.