/compact
Last updated
What is /compact?
The /compact command is a context management tool designed to optimize your session's memory when the context window begins to fill up. Instead of completely wiping your history like /clear, /compact instructs Claude to generate a concise summary of the key decisions, code changes, and project state established so far. It then replaces the bulky, line-by-line conversation history with this summarized version, effectively "compressing" the tokens used while preserving the essential knowledge the AI needs to continue the task.
Free resources to learn /compact
More in stage 9: Hooks
/compact: common questions
Can I learn /compact in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain /compact in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this /compact tutorial for beginners?
It is lesson 71 of 109 in the free Claude Code roadmap, in stage 9, Hooks. If you are new to Claude Code, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.