惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园 - 【当耐特】
月光博客
月光博客
C
Check Point Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
B
Blog
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
美团技术团队
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
L
LangChain Blog
The Cloudflare Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
After a Delete, I Kill the Session
eyesofish · 2026-05-28 · via DEV Community

eyesofish

Problem

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.

Clouded judgment while editing yields messy diffs. During deletions, it can destroy the project. Incident reports: December 2025, a user saw Claude run rm -rf … ~/ where the trailing ~/ expanded to the entire home directory. October 2025, another user watched rm -rf / execute from root; only file permissions saved the system. Deletion risk isn’t linear—it’s explosive.

My hard rule: if a session has ever run a delete command, I kill it and start fresh.

Approach

Instead 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. /compact compresses hundreds of messages into a short summary; the signal survives, the noise is dropped.

After 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.”

Many 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.

Implementation

The steps:

  1. After any delete operation (file, directory, rm, etc.), ask the model: Summarize the current state of the project. What have we accomplished? What remains? Note any decisions or open questions.
  2. Run /compact to distill the session into a high‑signal, compact context.
  3. Start a fresh Claude Code session and paste the summary as the initial prompt.

It takes a couple of minutes and drives the risk of destructive misjudgment close to zero.

This practice aligns with Anthropic’s five‑pronged context‑rot strategy: /rewind (roll back), /clear (wipe), /compact (compress), subagents (isolate tasks), and Continue (pick up where you left off with less noise). Combining /compact with a manual fresh start is essentially Continue with an explicit summary handoff.

The 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.

Results

I can’t quantify “fewer catastrophic deletions,” but the mechanism is sound. /compact strips 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.

Editing risk is linear: mess up one file, you lose one file; git diff catches it. Deletion risk is exponential—one command can destroy the entire project. Treating them the same is a mistake.

Lessons learned

  • Context rot is measurable and dangerous. A 70 MB session dump can be 93 % noise.
  • Deletion commands in long‑running sessions are the highest‑risk moment. The 2025 incidents show that even with guardrails, YOLO mode can issue rm -rf ~/ or rm -rf /.
  • Session hygiene is a necessary workaround for a fundamental architecture limitation. Anthropic’s official strategy and community tools like Cozempic confirm this.
  • The “plan‑then‑new‑session” pattern is already widespread. Making “delete” an explicit trigger formalizes a sensible boundary.