---
title: "Discussion on \"Claude Code Deleted My Files. Here's How I Stop It Now\" | Hashnode"
description: "Discussion on \"Claude Code Deleted My Files. Here's How I Stop It Now\". The four guards I use after Claude Code deleted 49 of my files through a symlink: a deny list, a script that reads every command, a backup first, and a look with ls -la. With a hook I tested and what I did not test."
url: "https://hashnode.com/posts/claude-code-deleted-my-files-here-s-how-i-stop-it-now/6af91749a36b00beebfb9051"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Claude Code Deleted My Files. Here's How I Stop It Now](https://hisashi.hashnode.dev/claude-code-deleted-my-files-here-s-how-i-stop-it-now?utm_source=hashnode&utm_medium=feed)

The four guards I use after Claude Code deleted 49 of my files through a symlink: a deny list, a script that reads every command, a backup first, and a look with ls -la. With a hook I tested and what I did not test.

Nov 15 · 16 min read · hisashi.hashnode.dev  
Read the article

-   [#claude](https://hashnode.com/tag/claude)
-   [#ai](https://hashnode.com/tag/ai)
-   [#devtools](https://hashnode.com/tag/devtools)
-   [#security](https://hashnode.com/tag/security)

## Written by

[Hisashi Hirajo](https://hashnode.com/@hirajo)

@hirajo

  
[View profile](https://hashnode.com/@hirajo)

## Responses 2

Markdown supported · ⌘↵ to post

[OneLifeVibe](https://hashnode.com/@onelifevibe)

[Nov 15](https://hashnode.com/posts/claude-code-deleted-my-files-here-s-how-i-stop-it-now/6af91749a36b00beebfb9051/comment/6af92375c9fd5126502aaf11)

The ls -la trap is the detail I will remember. Checking docs/ with a trailing slash looks like a real folder, while checking the parent without the slash shows the arrow, and that one character difference cost 49 files. Guard 2 is the part I would adopt first, because a deny rule alone does not stop /bin/rm or bash -c, while the hook script you tested does. Your honesty about what the script does not catch, rm docs/a.md and mv, makes the whole piece more useful than a simple checklist.

[Ascendra Ventures](https://hashnode.com/@ascendra-ventures)

[Nov 15](https://hashnode.com/posts/claude-code-deleted-my-files-here-s-how-i-stop-it-now/6af91749a36b00beebfb9051/comment/6af91b9af9efbfa8bf2466ac)

The symlink detail is what makes this worth reading. Nothing was malicious, and as far as the agent could tell nothing was outside the project. It deleted inside a folder that only looked like part of the repo. Your point that ls -la docs/ with a trailing slash hides the arrow is a trap I had not thought about.

I agree with putting two of the guards outside the AI entirely. We took the same view building CleanSync at Ascendra Ventures, a self-hosted tool that keeps Google Drive in two-way sync with your own server. rclone moves the files, and most of CleanSync's job is deciding when not to. Every sync is rehearsed as a dry run first, and if it would delete more files than a set limit, it stops and shows the list. Anything replaced or deleted goes to a Recovery folder before it leaves. None of that depends on the tool behaving well, which is the same reason a hook beats a line in CLAUDE.md.

Does your PreToolUse hook resolve symlinks before it checks the path, or does it match on the command text only?
