r/ClaudeCode • u/waruyamaZero • 3h ago
Rant Just had the worst session ever
First Claude deleted two linked repositories while removing a working tree. Then it was lazy as fuck, always told me to do this and that and when asked it could suddenly do it alone, and that happened several times. Maybe there should be a /thissessionisdogshit command. I would have used it. (Fable 5.2 in case you want to know)
0
Upvotes
•
u/AutoModerator 3h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Level1_Crisis_Bot 3h ago
In 6 months of heavy use in my work's codebase, not once has this happened to me. Deleting worktrees after finishing work on a Jira task is part of its workflow, and it does that ~10 times a day. And that's using Opus 5 models.
2
u/ChanceExcuse8669 1h ago
I don't know which command it used, so I won't claim a hook would have caught this one. After a similar scare I stopped relying on a CLAUDE.md line that says "don't delete outside the project." That's a suggestion the model can ignore. I added a PreToolUse hook on Bash that reads the command text and exits 2 if it's a recursive delete aimed outside the project folder. In my tests it blocked 12 of 21 ways of writing that delete, and 0 safe commands. It still misses /bin/rm, bash -c, xargs, PowerShell, git history, and settings edits, so I treat it as a seatbelt, not a sandbox.
-1
u/writesCommentsHigh 3h ago
Zero issues with any of my sessions. Working like fire today
-2
u/Strange-Sea-9894 2h ago
Ouch, losing two linked repos on a worktree cleanup is brutal.
Two concrete fixes that completely stopped both problems for me (destructive shell calls + the model getting lazy and handing tasks back):
Move destructive-command rules out of CLAUDE.md and into a PreToolUse Bash hook. A recent November arXiv study (2611.19549) tested written prompt rules vs. in-loop runtime hooks across 460 runs and found prompt rules still let recursive deletes slip through, while an in-loop hook dropped violations to 0 across 104 paired runs:
!/usr/bin/env bash
CMD=$(jq -r '.tool_input.command // ""') if echo "$CMD" | grep -qE '(|[;&|]\s*)rm\s+-[a-zA-Z]r|git\s+worktree\s+remove.--force|git\s+reset\s+--hard'; then echo "BLOCKED: destructive command denied by PreToolUse hook." >&2 exit 2 fi exit 0