[KongchangAI]
Productcompact 命令

/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)

Nov 16

/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.

Unverified50%
Nov 12

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.

Unverified50%
Nov 10

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.

Unverified50%
Nov 8

Using /compact between tasks cost $2.34, 17% more expensive than doing nothing, because compaction requires reading the entire context before compressing it.

Unverified50%
Oct 28

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.

Unverified50%
Oct 28

Codex CLI's /compact command can compress chat history into a summary to control context bloat, and is suitable for long sessions.

Unverified50%
Oct 23

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.

Unverified50%
Oct 21

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.

Unverified50%
Oct 21

The /compact command frees up context window space by generating a compressed summary of the conversation history and replacing the original message sequence.

Unverified50%
Oct 17

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.

Expired50%

9 more timeline events

All Facts (17)

Verified

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%
Unverified

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.

50%
Unverified

Using /compact between tasks cost $2.34, 17% more expensive than doing nothing, because compaction requires reading the entire context before compressing it.

50%
Unverified

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.

50%
Unverified

Codex CLI's /compact command can compress chat history into a summary to control context bloat, and is suitable for long sessions.

50%
Unverified

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.

50%
Unverified

The /compact command frees up context window space by generating a compressed summary of the conversation history and replacing the original message sequence.

50%
Unverified

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.

50%
Unverified

After 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%
Unverified

When 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%
Unverified

The /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%
Unverified

v0.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%
Unverified

If 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%
Unverified

It is recommended to use the /compact command more frequently and regularly within the first hour of a conversation to truly help control costs.

50%
Unverified

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.

50%

Source Articles