CLAUDE.md Compaction: Why Your Rules Disappear Mid-Session

Iniciado por joomlamz, 03 de Junho de 2026, 07:35

Respostas: 0   |   Visualizações: 24

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

CLAUDE.md Compaction: Why Your Rules Disappear Mid-Session



Tópico: CLAUDE.md Compaction: Why Your Rules Disappear Mid-Session
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
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


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: