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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
J
Java Code Geeks
V
V2EX
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
博客园 - Franky
爱范儿
爱范儿
T
Tailwind CSS Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
博客园_首页
B
Blog RSS Feed
博客园 - 司徒正美
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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
CLAUDE.md Compaction: Why Your Rules Disappear Mid-Session
Olivia Craft · 2026-06-03 · via DEV Community

Olivia Craft

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. When the context window fills, it summarizes — and that summary prioritizes what looked most relevant to recent actions.

Rules that haven't been triggered recently get compressed or dropped. Formatting preferences disappear. Guard rails that haven't been tested recently become invisible.

The agent keeps working. It just stops following rules you thought were active.

The Signals People Miss

  • The agent starts making formatting choices you explicitly told it not to
  • Structural constraints you wrote at the top of CLAUDE.md get ignored after hour two
  • You ask Claude to follow a rule. It agrees. Then breaks it on the next output.

This isn't a bug. It's how context window management works.

What Survives Compaction (and What Doesn't)

Rules that survive best:

  • Rules that get reinforced by recent usage in the session
  • Rules tied to files actively being edited
  • Rules that are specific and concrete (not abstract preferences)

Rules that get compressed away:

  • Global preferences stated once at the top
  • Structural rules not relevant to current file context
  • Style guidelines not recently triggered

How to Write CLAUDE.md Rules That Survive Context Pressure

1. Repeat critical rules in multiple places
Don't rely on a single mention at the top. Repeat the most important constraints near the sections where they apply.

2. Make rules specific and file-scoped where possible
"Never modify tests" is more resilient than "be careful with the test suite." Specificity is harder to compress.

3. Use concrete examples, not abstract preferences
"Return plain JSON, no markdown wrapping" survives better than "keep responses clean."

4. Mark non-negotiable rules explicitly
A line like CRITICAL: never auto-commit signals weight. Abstract preferences don't get that treatment.

5. Structure for scanning, not reading
Bullet points over paragraphs. Short sentences. Headers that describe the rule, not the section.

The Underlying Problem

CLAUDE.md was designed to give Claude persistent context. But "persistent" doesn't mean immune to compaction pressure.

The rules that survive are the ones that look important to what's happening right now — not the ones that matter to you in the abstract.

Writing a CLAUDE.md that works through a full session is a different skill than writing one that reads well.


I packaged a set of pre-structured CLAUDE.md rules designed to survive compaction: high-signal formatting, explicit weight markers, scoped by task type.

CLAUDE.md Rules Pack — $27

Includes 60+ rules for Claude Code, tested across long sessions, with a structure built to stay intact under context pressure.

Free starter pack also available: oliviacraftlat.gumroad.com/l/pomoo