Bug Report — Data Loss caused by Claude Code (Opus 4.6)
Date: 2026-02-27
Model: claude-opus-4-6 (Claude Code CLI, VSCode extension)
OS: Windows 11, bash shell
What happened
The user asked Claude Code (acting as a Git agent) to create an orphan branch (locale/documentazione) to store documentation files from a gitignored directory (_md_files/).
The correct procedure (documented in the project's own instructions file that Claude had just read) was:
git checkout --orphan locale/documentazione
git rm -rf .
# copy _md_files/, commit, switch back
Instead, Claude executed:
git checkout --orphan locale/documentazione
git rm -rf .
git clean -fd # <-- THIS WAS NOT IN THE PROCEDURE
The git rm -rf . removed all tracked files including .gitignore. After that, all previously-gitignored directories became regular untracked directories. The git clean -fd then permanently deleted them from disk.
What was destroyed
Directories permanently deleted by the unnecessary git clean -fd:
| Directory |
Content |
Recoverable? |
_md_files/ (39 files) |
Project documentation, agent instructions, guides, index |
Partially — 37/39 recovered from git history and Claude session transcripts |
_documentazione_integrativa/ |
Normative documents (PDF, ODT, DOC, XLS) |
NO — binary files, never in git, not in transcripts |
| Other gitignored dirs |
Potentially _old/, _screenshots/, istruzioni_locale/, etc. |
Unknown extent of damage |
Why this is a critical bug in Claude's behavior
-
Claude added a destructive command (git clean -fd) that was NOT in the procedure it had just read. The instructions clearly said only git rm -rf ..
-
Claude violated its own operational rules. The project's ISTRUZIONI_GIT_AGENT.md (which Claude read at the start of the session) explicitly states: "Prima di comandi distruttivi (checkout -f, reset, clean): SEMPRE avvisare l'utente" — Claude did not warn the user.
-
Claude's system prompt says: "Carefully consider the reversibility and blast radius of actions" and "for actions that are hard to reverse... check with the user before proceeding." git clean -fd is irreversible and Claude did not ask for confirmation.
-
No backup was made before the destructive operation. Claude should have copied the gitignored directories to a safe location before switching branches and running any cleanup.
-
The user explicitly asked Claude to create the backup branch BEFORE deleting the old files. Claude did the opposite — it destroyed the files while trying to create the backup.
Expected behavior
Claude should have:
- Followed the documented procedure exactly (no
git clean)
- OR at minimum, warned the user before running any destructive command
- OR at minimum, backed up gitignored directories before any branch manipulation
Environment
- Claude Code CLI via VSCode extension
- Model: claude-opus-4-6
- Windows 11, bash shell
- Git repository with multiple gitignored directories containing important local-only files
Impact
Weeks of work potentially lost. Binary files (PDF, DOC, XLS) in _documentazione_integrativa/ are not recoverable. Markdown documentation was partially recovered through a multi-hour extraction from Claude's own session transcript JSONL files.
Bug Report — Data Loss caused by Claude Code (Opus 4.6)
Date: 2026-02-27
Model: claude-opus-4-6 (Claude Code CLI, VSCode extension)
OS: Windows 11, bash shell
What happened
The user asked Claude Code (acting as a Git agent) to create an orphan branch (
locale/documentazione) to store documentation files from a gitignored directory (_md_files/).The correct procedure (documented in the project's own instructions file that Claude had just read) was:
Instead, Claude executed:
The
git rm -rf .removed all tracked files including.gitignore. After that, all previously-gitignored directories became regular untracked directories. Thegit clean -fdthen permanently deleted them from disk.What was destroyed
Directories permanently deleted by the unnecessary
git clean -fd:_md_files/(39 files)_documentazione_integrativa/_old/,_screenshots/,istruzioni_locale/, etc.Why this is a critical bug in Claude's behavior
Claude added a destructive command (
git clean -fd) that was NOT in the procedure it had just read. The instructions clearly said onlygit rm -rf ..Claude violated its own operational rules. The project's
ISTRUZIONI_GIT_AGENT.md(which Claude read at the start of the session) explicitly states: "Prima di comandi distruttivi (checkout -f, reset, clean): SEMPRE avvisare l'utente" — Claude did not warn the user.Claude's system prompt says: "Carefully consider the reversibility and blast radius of actions" and "for actions that are hard to reverse... check with the user before proceeding."
git clean -fdis irreversible and Claude did not ask for confirmation.No backup was made before the destructive operation. Claude should have copied the gitignored directories to a safe location before switching branches and running any cleanup.
The user explicitly asked Claude to create the backup branch BEFORE deleting the old files. Claude did the opposite — it destroyed the files while trying to create the backup.
Expected behavior
Claude should have:
git clean)Environment
Impact
Weeks of work potentially lost. Binary files (PDF, DOC, XLS) in
_documentazione_integrativa/are not recoverable. Markdown documentation was partially recovered through a multi-hour extraction from Claude's own session transcript JSONL files.