/compact
A built-in slash command in Claude Code used to manually compact the context. Users can specify what to focus on retaining (for example, "focus on the API changes"), which preserves information needed for subsequent tasks more precisely than automatic compaction.
Core Facts
Timeline (last 90 days)
/clear completely wipes the current session and starts from zero, with the lowest cost but loss of all context; /compact has the model compress the existing conversation into a summary that retains key information and then continues, still incurring one call's cost but far less than having the whole original text repeatedly participate in subsequent requests.
v2.1.323 fixed an issue where, when resuming a session, new messages were appended to an unrestored old interrupted message, as well as an issue where /compact was repeatedly executed on a message to which Claude had not yet replied, causing content to be summarized away.
Using /compact to have Claude summarize the conversation compressed about 36,000 tokens to 5,000 after the first task, and the result was quota meter readings of 18% and 23%, list-price cost about a quarter higher, with each compaction itself costing 7 to 10 cents.
Using /compact between tasks cost $2.34, 17% more expensive than doing nothing, because compaction requires reading the entire context before compressing it.
In Claude Code, too much context significantly degrades response quality, so `/compact` (compressing history) and `/clear` (clearing history) are key means of controlling agent behavior and token consumption.
Codex CLI's /compact command can compress chat history into a summary to control context bloat, and is suitable for long sessions.
In Claude Code, the /clear command does not consume quota, whereas the /compact command must read the entire session to generate a summary and thus itself incurs token consumption.
Appending retention instructions after the /compact command (such as "compact but keep the API decisions and database schema") can guide the summary to retain important information.
The /compact command frees up context window space by generating a compressed summary of the conversation history and replacing the original message sequence.
After compressing the conversation with /compact, context usage in the demo dropped from 24% to 13%; after clearing with /clear, 10% was still occupied by the system prompt, tools, and CLAUDE.md.
9 more timeline events
All Facts (17)
The /compact command can reduce token consumption by 30% to 50%.
75%Unverified/clear completely wipes the current session and starts from zero, with the lowest cost but loss of all context; /compact has the model compress the existing conversation into a summary that retains key information and then continues, still incurring one call's cost but far less than having the whole original text repeatedly participate in subsequent requests.
50%UnverifiedUsing /compact to have Claude summarize the conversation compressed about 36,000 tokens to 5,000 after the first task, and the result was quota meter readings of 18% and 23%, list-price cost about a quarter higher, with each compaction itself costing 7 to 10 cents.
50%UnverifiedUsing /compact between tasks cost $2.34, 17% more expensive than doing nothing, because compaction requires reading the entire context before compressing it.
50%UnverifiedIn Claude Code, too much context significantly degrades response quality, so `/compact` (compressing history) and `/clear` (clearing history) are key means of controlling agent behavior and token consumption.
50%UnverifiedCodex CLI's /compact command can compress chat history into a summary to control context bloat, and is suitable for long sessions.
50%UnverifiedIn Claude Code, the /clear command does not consume quota, whereas the /compact command must read the entire session to generate a summary and thus itself incurs token consumption.
50%UnverifiedThe /compact command frees up context window space by generating a compressed summary of the conversation history and replacing the original message sequence.
50%UnverifiedAppending retention instructions after the /compact command (such as "compact but keep the API decisions and database schema") can guide the summary to retain important information.
50%UnverifiedAfter a long interruption (cache expiry), compaction is actually cheaper than simply continuing the conversation, because each subsequent turn then reads only about 15k tokens instead of the entire context.
50%UnverifiedWhen appending a question to a 42,000-token conversation history, staying in the existing session costs 0.9 cents, starting a new session costs 1.8 cents, and running compact before asking costs 6 cents—nearly 7 times more expensive.
50%UnverifiedThe /compact command generates a summary of the current conversation and adds it to a brand-new conversation; it is recommended to manually compress at 70%–90% usage.
50%Unverifiedv0.0.42 adds the /compact slash command for summarizing the current session's conversation content to free up context space.
50%Unverified/compact generates summaries using the provider settings configured in the session, and the summary is not sent to the model as a prompt.
50%UnverifiedIf a conversation has gone more than one hour since the last message, running /compact at that point often finds the cache already invalid, forcing the model to re-read the entire context.
50%UnverifiedIt is recommended to use the /compact command more frequently and regularly within the first hour of a conversation to truly help control costs.
50%Unverifiedv2.1.323 fixed an issue where, when resuming a session, new messages were appended to an unrestored old interrupted message, as well as an issue where /compact was repeatedly executed on a message to which Claude had not yet replied, causing content to be summarized away.
50%