# Auto-Compact

> Claude Code sums up an old chat to make room.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** Compaction, /compact

## Think of it like

It is like a big pile of notes, cut down to one short page.

## Definition

Auto-compact is how Claude Code makes room when a session's context window is nearly full. It writes a short summary of the chat so far. Then it carries on from that summary. Your CLAUDE.md and your auto memory are loaded again after it. But a rule you only gave in the chat may get lost. You can also run /compact yourself, and say what to keep.

## Example

Jack has worked for three hours in one session. The context is nearly full, so Claude Code sums up the work so far and keeps going.

## Example code

```console
/compact keep the API changes
```

Compact now, and tell it what matters most.

## Why it matters

It lets a long job keep going after the context is full.

## Common mistake

Giving key rules only in chat. Put rules that must last in CLAUDE.md, because a summary can drop a detail.

## Three principles

- **When context is full.** Or when you ask.
- **A summary.** Replaces old talk.
- **Files survive.** CLAUDE.md is reread.

## Related terms

- [Context Window](https://learn.benibix.com/term/ai/context-window)
- [CLAUDE.md](https://learn.benibix.com/term/ai/claude-md)
- [Claude Code Session](https://learn.benibix.com/term/ai/claude-code-session)
- [Auto Memory](https://learn.benibix.com/term/ai/auto-memory)
- [Context Compaction](https://learn.benibix.com/term/ai/context-compaction)

## Told apart from

- [/clear vs /compact](https://learn.benibix.com/compare/clear-command-vs-auto-compact): People often think /clear and /compact both just make room. They keep very different things. /compact squeezes the chat into a summary, so Claude still knows what you were doing. /clear starts a new chat with an empty context, so Claude knows nothing of it. Use /compact to go on with the same task. Use /clear to start a new one.

## Taught in

- [Claude Code Sessions](https://learn.benibix.com/learn/ai-claude-code/claude-code-sessions): Claude Code, 2/16

![The context bar fills up. Near the top, the old talk is squeezed into a short summary and space comes back.](https://learn.benibix.com/diagrams/cc-auto-compact.svg)

---

Source: https://learn.benibix.com/term/ai/auto-compact
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
