{"slug": "after-a-delete-i-kill-the-session", "title": "After a Delete, I Kill the Session", "summary": "An Anthropic engineer has documented a critical safety practice for Claude Code sessions: immediately terminating any session that has executed a delete command. The engineer's analysis of a 70 MB session dump revealed that 93% was noise—redundant metadata, stale tool results, and old base64 screenshots—with only 3% being actual conversation, contributing to what Anthropic calls \"context rot\" that degrades model judgment over time. The practice involves using the `/compact` command to distill the session into a high-signal summary before starting a fresh session, reducing the risk of catastrophic deletions like the December 2025 incident where `rm -rf ~/` expanded to a user's entire home directory.", "body_md": "The longer a Claude Code session runs, the worse the model’s judgment gets. Anthropic calls it “context rot.” In one dissected 70 MB session dump, **93 % was noise**: redundant JSON envelope metadata, stale tool results, old base64 screenshots. Only 3 % was actual conversation.\n\nClouded judgment while editing yields messy diffs. During deletions, it can destroy the project. Incident reports: December 2025, a user saw Claude run `rm -rf … ~/`\n\nwhere the trailing `~/`\n\nexpanded to the entire home directory. October 2025, another user watched `rm -rf /`\n\nexecute from root; only file permissions saved the system. Deletion risk isn’t linear—it’s explosive.\n\nMy hard rule: **if a session has ever run a delete command, I kill it and start fresh.**\n\nInstead of just exiting, I first ask the model to summarize where we are—what we’ve built, what’s left, key decisions. Then I run `/compact`\n\n. `/compact`\n\ncompresses hundreds of messages into a short summary; the signal survives, the noise is dropped.\n\nAfter that, I start a new session and feed it the summary. Fresh context means the model’s full attention is available. It won’t confuse “delete that config file” with “delete the project root.”\n\nMany already adopt a plan‑then‑new‑session workflow. I make the trigger explicit: if a session has been in YOLO mode and a remove command has been issued, I start a new conversation. No exceptions.\n\nThe steps:\n\n`rm`\n\n, etc.), ask the model: `/compact`\n\nto distill the session into a high‑signal, compact context.It takes a couple of minutes and drives the risk of destructive misjudgment close to zero.\n\nThis practice aligns with Anthropic’s five‑pronged context‑rot strategy: `/rewind`\n\n(roll back), `/clear`\n\n(wipe), `/compact`\n\n(compress), subagents (isolate tasks), and `Continue`\n\n(pick up where you left off with less noise). Combining `/compact`\n\nwith a manual fresh start is essentially `Continue`\n\nwith an explicit summary handoff.\n\nThe community agrees this is a pain point: Cozempic, an open‑source context‑pruning tool, has **35,000+ users** and offers **18 pruning strategies** across three tiers.\n\nI can’t quantify “fewer catastrophic deletions,” but the mechanism is sound. `/compact`\n\nstrips away over 90 % of the noise. A fresh session eliminates residual context confusion—the model sees only the essential summary, not thousands of stale tool outputs. In a long‑running session, “delete that test file” might match a dozen paths the model saw earlier; a fresh session has no such memory.\n\nEditing risk is linear: mess up one file, you lose one file; `git diff`\n\ncatches it. Deletion risk is exponential—one command can destroy the entire project. Treating them the same is a mistake.\n\n`rm -rf ~/`\n\nor `rm -rf /`\n\n.", "url": "https://wpnews.pro/news/after-a-delete-i-kill-the-session", "canonical_source": "https://dev.to/eyesofish/after-a-delete-i-kill-the-session-1h4a", "published_at": "2026-05-27 17:07:57+00:00", "updated_at": "2026-05-27 17:41:44.618466+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "ai-safety", "ai-tools", "ai-products"], "entities": ["Claude Code", "Anthropic"], "alternates": {"html": "https://wpnews.pro/news/after-a-delete-i-kill-the-session", "markdown": "https://wpnews.pro/news/after-a-delete-i-kill-the-session.md", "text": "https://wpnews.pro/news/after-a-delete-i-kill-the-session.txt", "jsonld": "https://wpnews.pro/news/after-a-delete-i-kill-the-session.jsonld"}}