Compaction
By Mike Schreiber · Updated 31 October 2026
Compaction
Compaction is the reduction of an AI conversation’s active history into a shorter summary, freeing context space while retaining information needed to continue. In Claude Code, /compact [instructions] summarizes the conversation, optionally emphasizing details you specify. It is a context-management operation, not a guarantee that every earlier detail remains available. [1]
What changes after compaction
A summary replaces detailed conversational history in the active context. This distinction matters when resuming work: Claude Code restores the latest compaction summary, messages left unsummarized, and subsequent messages. It does not reload the messages that the latest compaction summarized. [2] Treat the summary as a working handoff rather than a complete historical record.
Persistent instructions have separate loading behavior. Claude Code re-reads and reinjects project-root CLAUDE.md after compaction. Nested instruction files and path-scoped rules reload on demand. A conversation-only instruction can therefore disappear from working context even when a repository instruction survives. [3]
Compaction versus external memory
Compaction reduces what occupies the current context. External memory provides information that an application can retrieve later. For an MCP memory server, local means the server runs on the same machine, commonly communicating through standard input/output. Hosted means it runs remotely, commonly using Streamable HTTP. The deployment choice concerns where the service operates; persistence, sharing, and retention depend on its implementation. MCP itself defines context exchange, not how an application manages its context window. [4]
Hark belongs in the project-record category, not universal transcript transfer. Its briefs, Memory, and handoffs draw from a shared record covering Inventory, Health, Work, Authority, and Decisions. Its documentation limits automatic session hooks and compaction protection in the Hark mod to Claude Code; other tools use their connection guides and explicit session tools. [5]
Practical example
During a payment migration, first record durable constraints in project instructions and save current decisions with their rationale. Then run:
/compact Preserve the migration goal, rejected approaches, failing tests, and next action.
Focus instructions are supported by the command. [1] Afterward, ask the assistant to restate the constraints and next step, then check those against the saved record before continuing. This makes omissions easier to catch without requiring the entire discussion in active context.
Sources
[1] Claude Code: Commands [2] Claude Code: Manage sessions [3] Claude Code: Project memory [4] MCP: Architecture overview [5] Hark: How it works