CLAUDE.md Compaction: Why Your Rules Disappear Mid-Session
The article discusses the issue of rules disappearing during sessions with CLAUDE.md due to context window compaction. It explains how the system prioritizes recent actions, leading to the loss of less frequently triggered rules. Strategies for writing resilient rules that survive this compaction are also provided.
- ▪CLAUDE.md does not retain all rules in memory throughout a session, leading to potential loss of important guidelines.
- ▪Rules that are specific, reinforced by recent usage, and tied to actively edited files are more likely to survive compaction.
- ▪To improve rule retention, users are advised to repeat critical rules, make them specific, and use concrete examples.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3860999) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Olivia Craft Posted on Jun 3 CLAUDE.md Compaction: Why Your Rules Disappear Mid-Session #claudeai #aitools #claudemd #llm You spent an hour writing a tight CLAUDE.md. Clear rules. Good structure. Specific constraints for your project. Then Claude Code hits its context window limit mid-session. It compacts. And half your rules don't make it through. What Actually Happens During Compaction Claude Code does not keep your full CLAUDE.md in memory throughout a long session.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).