Tegoby Attention SpanBlogBook a demo

A cleanup trap deleted a home folder

Strict rules refuse key steps

In August 2026, a Claude Code user reported that the agent wrote a test script for itself, and a cleanup line in that script deleted their whole home folder, SSH keys and all. With strict rules, Tego would refuse the deletes outside the folders you name, and your home folder isn't one of them. We reproduced the incident's steps under these rules to confirm it.

What happened?

The report is Claude Code issue #88462, opened on 21 August 2026 and still open when we read it on 5 November 2026. Claude Code ran in auto mode, where it acts without asking first, on WSL2, the Linux that comes built into Windows. Everything here is as the reporter described it.

The agent wrote a small bash script to help with its tests. It included an exit trap (a cleanup command a shell script runs when it finishes): trap 'rm -rf "$_HT_HOME"' EXIT. In plain words: "when you're done, delete the folder named in _HT_HOME." The single quotes mean the script looks up that folder name at the end, not when the line is written.

Minutes later, in the same session, the agent added an option to that script that sets _HT_HOME="$HOME", the user's home folder.

A test run then used the helper twice. The first time, _HT_HOME named a throwaway temp folder. The second time, it named the home folder. When the script finished, the trap ran rm -rf /home/<user> and deleted everything in it.

The output ended with a getcwd error, the message a program gets when the folder it is working in no longer exists. The agent took it for normal temp cleanup and kept going for several turns.

The loss: several days of work, the full Claude Code setup (hooks, agents, memory), about 1.4 GB of session transcripts, SSH keys, the gh login (GitHub's command-line tool) and three conversations in progress. Only part came back from backups. The reporter lists earlier issues in the same tracker that they count as the same kind of incident.

Why didn't the usual safety catch it?

Claude Code checks each command before it runs. In auto mode, set by "defaultMode": "auto" in the settings file, there is no prompt for the user either. The command it checked was bash /tmp/.../test-lib-demo.sh: "run this script." Nothing in that line looks dangerous.

The delete was inside the file, and the file changed between runs. As the reporter put it, "nothing in the permission chain could see it coming". A check that reads the text of a command cannot know what a script will do once it runs.

How it could have been prevented

The habit that prevents this kind of harm is simple: decide in advance which folders an agent may change, and have something outside the agent refuse every other change as it happens. You don't need to predict the bug. Whatever the script does, a delete in your home folder is refused, because your home folder was never on the list.

Tego does this with the Linux kernel, from outside the agent. It doesn't read scripts; it decides each file change and each program start at the moment it happens, which is exactly where the command check was blind. Tego's strict setup is three built-in rule sets: the agent can't read your secrets, can only reach the hosts you list, and can only change files in the folders you name. The last one is the part that matters here. See the strict setup for the full file and how to start it.

Say the agent may change only ./src/ and ./tests/. When the trap fires, rm still runs, but every delete it tries anywhere else fails with a permission error: your home folder, the rest of the project and its git history all survive. Each refusal is written to the run's record, which Tego keeps outside the agent's reach. Claude Code is also told which rule refused it, instead of a puzzling getcwd error.

In Tego's rules file, that's:

YAML
extends: [tego/no-secrets, tego/no-prod, tego/repo-only-writes]
fs:
  write: ["./src/", "./tests/"]   # the only folders the agent may change

The honest limit: files inside ./src/ and ./tests/ can still be deleted, so uncommitted changes there are lost, and Tego keeps no backups.

How Tego handles it

Without the strict setup, Tego's default is to let the agent change files only in the project folder. That alone saves everything outside it: your SSH keys, the gh login, your real Claude Code settings and Tego's own record. The project itself stays writable, so it would be largely emptied: the work, the git history and this session's state. Git's hooks and config inside it are protected by built-in rules.

Two more things change under our example rules file. The agent can't write under /tmp, so its script lands in the project or in its own temp folder. And Claude Code starts with a fresh settings folder inside the project, so your real hooks, memory and auto-mode setting aren't loaded unless you copy them in.

Tego wouldn't have caught the bug in the script; it judges actions, not code. And only sessions started with tego run are covered. This works without root. On Windows, Tego runs inside WSL2; check that tego doctor says this protection is available, as the Windows install notes explain. The reporter did not give their WSL or kernel version.

The lesson

Check what a command does, not what it says. Any agent that can write a file and then run it can hide anything from a check on command text. Put the limit where the action happens, at the file change and the program start, and keep backups and the record out of the agent's reach.

Sources (30 links)