Claude Code Compaction Architecture
Claude Code has an interesting recipe for compaction. This is how it works.

Again, shared by Claude Code
Claude Code is not doing just one compaction. It has three layers, and each layer handles a different kind of overload.
Layers
- MicroCompact — cheap, every turn
- Session Memory Compact — medium, no API call
- Legacy Compact — expensive, full summarization
Window and Triggering Behavior
- Effective window = model window with reserved space