{
  "id": 23827895,
  "title": "Claude Code Deleted My Files. Here's How I Stop It Now",
  "url": "https://urgent.news/2026/12/06/claude-code-deleted-my-files-heres-how-i-stop-it-now",
  "topic": "ai",
  "section": "AI",
  "published": "2026-12-06T13:00:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/hisashispace/claude-code-deleted-my-files-heres-how-i-stop-it-now-4lok"
  },
  "original_language": null,
  "account": "Claude Code inadvertently deleted 49 files from the user's project by following a symlink that pointed to shared settings folders. The user discovered this by creating a video about the incident and outlining four safeguards to prevent such occurrences.\n\nThe official documentation provides two crucial points about Claude Code's behavior. First, user instructions or the CLAUDE.md file \"shape what Claude tries to do, but they don't change what Claude Code allows.\" Second, a deny rule \"isn't a security boundary around the program.\" To safeguard against Claude's actions, the user employs a combination of tools and habits.\n\nThe four safeguards consist of two measures that exist outside the AI and two personal habits. The two external safeguards are:\n1. A \"never list\" or deny rules, which live in the settings.json file. This list specifies actions Claude Code is explicitly forbidden to perform, evaluated in order of precedence.\n2. A PreToolUse hook, a script that reads every command before it runs, preventing unsafe operations from executing.\n\nThe two personal habits are:\n1. Backing up data before making any changes.\n2. Inspecting files before deletion, using the ls -la command on parent folders to identify symlinks and understand their contents.\n\nThe user has experienced the consequences of Claude Code's actions firsthand, noting that 43 files within a shared docs folder and an additional 6 files in the shared commands folder were removed. For the user's own testing purposes, they replicated the situation on a throwaway folder to demonstrate the potential impact.\n\nThe user has established a comprehensive list of 25 deny rules within the settings.json file, covering a range of actions to prevent potential damage. These rules include preventing disk wipes, database resets, and various destructive commands executed through tools like Docker, Git, and Prisma.\n\nThe user acknowledges that AI systems like Claude Code may not always act with the intention to cause harm, but the lack of awareness and understanding of the broader consequences can lead to unintended file deletions. The four safeguards mentioned above help mitigate the risk of such accidental deletions, ensuring that the user maintains control over their project's data.",
  "summary": "Claude Code deleted my files. Forty-nine of them, in one go, and they were not even inside the project it was working on. I made a video about it and the four guards I use now to stop it. This article has what the video has no room for: what the official docs say about deny rules and hooks (including a table of the commands a deny rule does not stop), a hook script I wrote and ran against a test…",
  "summary_source": "publisher",
  "key_points": [
    "Claude Code inadvertently deleted 49 files from user's project",
    "User safeguards include deny rules and PreToolUse hook",
    "Two personal habits: backup data and inspect files before deletion"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}