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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
Y
Y Combinator Blog
IT之家
IT之家
博客园 - 聂微东
L
LangChain Blog
爱范儿
爱范儿
H
Help Net Security
GbyAI
GbyAI
F
Fortinet All Blogs
B
Blog
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
D
DataBreaches.Net
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享

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.