/compact Command

Compresses the current conversation history into a concise summary, freeing context window space while preserving the essential task thread. Unlike /clear, /compact keeps the context of what you're working on. Use at natural task boundaries in long sessions.

Syntax

claude-code
/compact

// Claude Code summarizes the conversation and continues
// with the compressed version as context

Example

claude-code
// Scenario: 45 minutes into a complex refactor
// Multiple files changed, many back-and-forth turns
// Starting to see slightly inconsistent responses

/compact
// Claude Code: "Summarized. We have completed: [list].
// In progress: [current task]. Remaining: [what's left]."

// Continue from the compressed state:
> Good. Continue with the remaining files in the migration.