On October 23, 2026 at 7:48pm ET, an AI agent testing a solution to prevent dangerous deletes accidentally ran a dangerous delete. The command was rm -rf "/Applications/", which deletes everything in the Mac's Applications folder including subfolders. The agent deleted 13 applications, including the Claude desktop app, the app running the agent's own session. Apple protected its system applications and other applications that had higher ownership (root).
The agent never noticed; it saved its work, wrote a tidy report and handed it in. The supervising AI session read the report and accepted the work 47 seconds later. Nobody noticed anything for about 10 hours.
The lesson is uncomfortable. Every safety check that evening read the commands the agent typed, and the delete was in none of them. It ran inside a test, where no check was looking. An agent can work around any protection that reads commands, except one the operating system enforces.
Four Dangerous Delete Attempts in 8 days: Claude Code caught two, but two went unnoticed
AI agents build code for Kyberna and delete temporary files and folders during the build and after they complete their tasks. Often, models—in this case Opus 5.5—create complicated commands for the agent to run to delete many files at once. Those complicated commands assemble the names of folders and files to be deleted in one of their steps. But if the steps assembling the names fail, the delete command will run on unintended folders. Even more dangerous, if the variable comes out empty, the name can shrink to /, the top of the whole disk.
Over an 8-day span, agents tried four times to run a complex recursive delete that could have deleted everything on the Mac—two got caught, but two slipped through. On October 16, the supervising agent ran a delete with an empty variable, which would have deleted everything on the Mac. On October 23, a building agent ran another similar command. Both times, Claude Code's safety check refused it because it couldn't tell where the delete would land.
Here is an example of one of those complicated commands, which includes creating a temp folder, creating a config file and a model in it, running a memory check on the model, and then deleting the temp folder:
d=$(mktemp -d)/made-up-btc; mkdir -p $d; echo '{}' > $d/config.json; truncate -s 500G $d/pytorch_model.bin; cd ~/Developer/kyb-agents/g14e && Scripts/lib/model-memory-check.sh $d --kyb ~/Library/Caches/swiftpm-scratch/g14e/debug/kyb 2>&1 | sed "s#$d#FOLDER#"; echo "exit ${pipestatus[1]}"; rm -rf $(dirname $d)
The lesson from the first incident had lived only in an agent's working note, so no later agent read it; the second mistake was the same as the first. One of those dangerous deletes was found during the investigation of the fourth delete, which deleted the 13 applications.
The fix: A single gatekeeper for every delete
Agents implemented a new rule for the Kyberna project: every delete an agent executes outside the project's scripts goes through a safe delete script. The script refuses any folder that could reach beyond the temp folders the agent made. The script is enforced by a Claude Code hook, which watches every command an agent sends and turns away any delete that skips the script.
The earlier paper, Agents Forget Rules. Hooks Don't., describes both in detail.
Then the supervising agent looked at its own house and found 41 deletes in its scripts with a variable that could be empty and could potentially delete everything.
The agent's assignment: put a safety lock on all 41 dangerous deletes
On the evening of October 23, a Claude agent was given the job: add a lock to each risky delete, so the script stops if the variable is empty. Then it was to write a test proving every lock holds.
The agent was thorough. Instead of simply reading each line, it ran each delete in a scratch folder with the variable left empty, to watch it do nothing.
Running deletes to prove they are safe is like testing smoke detectors by setting fires. It works until one fire is in the wrong room and burns down the house.
The first slip: the agent's test erased part of the Mac's scratch folder at 7:46pm ET
One script line deletes the folder above its target, on purpose. The agent's first test put the target directly inside the Mac's temporary folder, the shared scratch space every app uses. So the line went after the temporary folder itself.
The test's 60-second time limit stopped it. Nobody knows what it removed. The agent left no audit trail.
The agent saw the error and changed its test, so that from then on each target sat 2 folders deep inside a folder the test made itself. A delete that reached one folder too high would still land inside the test's own space.
At 7:58pm, the author approved a new sentence for the project's delete rule, requiring the same. The sentence ends with a promise: "so even a delete of the target's parent removes only what the test made."
By then, the promise had been broken for 10 minutes.
The second slip: the agent's test on the old scripts deleted the Mac's Applications folder at 7:48pm ET
The project's build rules ask an agent to run each new test on the code as it stood before the fix, to show the test catches the problem. So at 7:48pm the agent copied the old scripts into a temporary folder and ran its test on them using a Python script.
One of the scripts the agent was testing is the build script for the Kyberna Checks application. The script had the following delete command:
if [[ "${INSTALL:-}" == yes ]]; then rm -rf "/Applications/$(basename "$APP")" && cp -R "$APP" /Applications/ && APP="/Applications/$(basename "$APP")" && echo "installed $APP"; fi
When an agent runs the script to install the app, the script erases the old copy in Applications and copies the new one in. In a normal build, the variable APP holds the full path of the newly built app. But when the variable APP is empty, the delete runs on the entire Applications folder, rm -rf "/Applications/", becoming a dangerous delete. The agent, running the script outside the build process, didn't pass a value for the APP variable.
It removed everything it could in the Applications folder.
Copying the scripts into a temporary folder protected nothing. The path did not point into the copy; it began with the word Applications, written into the line itself. The fix from the first slip, burying each target 2 folders deep, failed for the same reason: it works only when the whole path comes from a variable.
The 2 minutes that nobody watched
7:48:21pm. The agent started its test against the old scripts.
7:48:40pm. The test finished.
7:49:24pm to 7:49:27pm. macOS recorded 13 apps as gone, one after another.
7:49:41pm. The agent saved its work.
7:50:00pm. The agent reported. The report described the first slip only.
7:50:47pm. The supervising agent accepted the work.
13 apps gone, the protected ones stayed, and some losses can never be counted
The 13 apps were Kyberna's 3 apps, Claude, 6 other AI apps, 2 web browsers and a writing assistant.
The apps that survived include Apple's applications (Xcode among them), the Microsoft 365 apps and Slack. Every survivor is owned by root, the Mac's system account, which an ordinary account cannot delete.
The code base itself was untouched: the project's repository checks clean, with no file missing. Kyberna's background services live in a different folder, and the delete did not reach them.
Why every alarm stayed silent
Claude Code's safety check reads each command the agent sends, and so does the project's hook. The agent sent one command: run the Python test. The test then started a shell, and that shell ran the delete where neither check ever saw it. That Claude Code session was running without a sandbox; otherwise, the dangerous delete on the Applications folder would have been prevented. However, a sandbox cannot protect everything, for example, dangerous deletes within the project's folder, which is now protected by 2 rules, 1 safe delete script and a Claude Code hook.
Kyberna's own protections were not in play either. The agent worked in Claude Code, not inside Kyberna.
The agent said it was careful, and in its own words it was
The agent's report says: "I did not run any whole script, because its delete could reach real build, support or Applications folders."
The caution was real: the agent understood that a whole script could reach Applications. It did not apply the same caution to a single line from that script.
The supervisor waved it through
The supervising session, another Claude session that hands out the work, checks each agent's work and merges it. It made 2 mistakes of its own.
It accepted the work 47 seconds after the report. It reran the agent's tests but never asked what the run against the old scripts had done.
It checked only the scratch folder. It counted the temporary folder's contents after the first slip. Nobody looked in Applications.
The agent made the delete. The supervisor made sure nobody found out until morning.
What changes now
Tests will pretend to delete. The test will swap in a stand-in for every delete command. The stand-in writes down what it would remove and removes nothing, and the test then checks that list.
A new instruction in the existing rule: "A test never runs a real delete from a repository script; it replaces the delete with a stand-in that records what it would remove."
Kyberna will have a new feature. Kyberna's planned delete guard will judge each delete after its blanks are filled in, not before. The test's stand-in uses the same idea.
What this paper cannot prove
macOS records that the apps disappeared, not which program removed them. So the cause rests on 3 facts:
Rerunning the agent's steps without deleting anything shows that the test's own code would perform
rm -rf "/Applications/".The agent ran the test, which deleted the apps, 44 seconds before the first app was gone.
No other command in the project's session touched Applications that evening. And no other sessions or scripts were running.
This is one Mac and one project, so the paper claims nothing about how often agents do this.
If you use AI coding agents:
Make sure agents' briefs have clearly defined rules around deletes, that hooks enforce those rules, and that agents must use a safe delete script.
Turn on a sandbox, harden operating system access and privileges, and make sure backups are on.
If you or agents write tests for a safety check, make the dangerous step pretend.
If you supervise an agent, read what it ran, not only what it reports.
Make sure your supervising agent has clear instructions to check agents' work, not just accept what they submit.
The agent set out to prove no delete could slip past its guard. It proved the opposite, and took Claude with it.
Prosights.ai