57 pages for /compact.
Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.
sent_count = len(messages sent in the compaction request)
Claude Developer Platform · path
build-with-claude/compaction
compaction-background
Claude Developer Platform · path
build-with-claude/compaction-background
compaction-keep-recent-turns
Claude Developer Platform · path
build-with-claude/compaction-keep-recent-turns
compaction-on-demand
Claude Developer Platform · path
build-with-claude/compaction-on-demand
compaction-thinking-blocks
Claude Developer Platform · path
build-with-claude/compaction-thinking-blocks
compaction-threshold
Claude Developer Platform · path
build-with-claude/compaction-threshold
optimizing-for-cost-and-intelligence
Claude Developer Platform · in the page
about-claude/models/optimizing-for-cost-and-intelligence
…ction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) as a keep-alive request. <CodeGroup exclude="shell:CLI, python, typescript, csharp, go, java, php, ruby">…
memory-tool
Claude Developer Platform · in the page
agents-and-tools/tool-use/memory-tool
…ith [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction), which summarizes older conversation context server-side. Context editing clears specific tool results on the client.…
Log at info level
Claude Developer Platform · in the page
agents-and-tools/tool-use/tool-runner
…side compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold), which works with every SDK's tool runner through the `context_management` request parameter. The Python SD…
Before
Claude Developer Platform · in the page
api/migration-2026-10-21
…The `compactionControl` option and the `@anthropic-ai/sdk/lib/tools/CompactionControl` module are gone. The option stopped working in v0.129.0, where passing it threw an `AnthropicError`. It isn't…
spans
Claude Developer Platform · in the page
api/opentelemetry/spans
…'s [compactions](https://platform.claude.com/docs/en/build-with-claude/compaction), including cache reads and writes. Not part of `gen_ai.usage.input_tokens`. Absent when the response has no compactio…
context-editing
Claude Developer Platform · in the page
build-with-claude/context-editing
…side compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) is the primary strategy for managing context in long-running conversations. The strategies on this page are useful fo…
context-windows
Claude Developer Platform · in the page
build-with-claude/context-windows
…side compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) is the primary strategy for context management. ## How the context window works The "context window" refers to all…
overview
Claude Developer Platform · in the page
build-with-claude/overview
…token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold) | Server-side context summarization for long-running conversations. When input tokens reach the trigge…
preserved-thinking
Claude Developer Platform · in the page
build-with-claude/preserved-thinking
…ide [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction), the checked prefix starts at the most recent compaction block. Request parameters outside those three fields, such…
claude-prompting-best-practices
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/claude-prompting-best-practices
…text compaction](https://platform.claude.com/docs/en/build-with-claude/compaction). </Accordion> ## Tool use ### Tool usage Claude's latest models are trained for precise instruction following and…
Delivering work
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/prompting-claude-fable-5-1
…ide [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) or [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) do any trimming. If you c…
task-budgets
Claude Developer Platform · in the page
build-with-claude/task-budgets
…ide [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold) during a turn does not reset the budget: tokens the turn consumed before the compaction still count against…
thinking-troubleshooting
Claude Developer Platform · in the page
build-with-claude/thinking-troubleshooting
…ide [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) and [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) never trigger it. To fi…
api-and-data-retention
Claude Developer Platform · in the page
manage-claude/api-and-data-retention
…nt (compaction)](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold) | `/v1/messages`<br />with `context_management` | <Eligible>Yes</Eligible>…
opentelemetry
Claude Developer Platform · in the page
manage-claude/opentelemetry
…as [compactions](https://platform.claude.com/docs/en/build-with-claude/compaction), also add the span's `anthropic.usage.compaction.input_tokens` and `anthropic.usage.compaction.output_tokens`, becaus…
Or, for Claude Mythos 5.1, which offers the same capabilities to verified organizations:
Claude Developer Platform · in the page
models/fable-5-1/migration-guide
…ide [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) or [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) ([tool result clearing](h…
whats-new-fable-5-1
Claude Developer Platform · in the page
models/fable-5-1/whats-new-fable-5-1
…or [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction), which don't count as edits. These patterns also keep the [prompt cache](https://platform.claude.com/docs/en/build-wi…
whats-new-opus-5-5
Claude Developer Platform · in the page
models/opus-5-5/whats-new-opus-5-5
…served thinking](https://platform.claude.com/docs/en/build-with-claude/compaction-thinking-blocks#conditions-for-kept-thinking-to-stay-valid)), which matters on Claude Opus 5.5 because its [thinking b…
whats-new-sonnet-5-5
Claude Developer Platform · in the page
models/sonnet-5-5/whats-new-sonnet-5-5
…served thinking](https://platform.claude.com/docs/en/build-with-claude/compaction-thinking-blocks#conditions-for-kept-thinking-to-stay-valid). That matters on Claude Sonnet 5.5 because its [thinking b…
overview
Claude Developer Platform · in the page
release-notes/overview
…ation on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand) on the Claude API, in beta with the `compact-2026-09-04` beta header. Send the top-level `compaction` param…
Escalate hard decisions with the advisor tool
Claude Code CLI · in the page
advisor
…advisor in the current conversation, it stays off until `/clear` or `/compact`, even after you switch models. On some plans, Fable as the advisor also needs your one-time [consent to bill Fable usag…
How the agent loop works
Claude Code CLI · in the page
agent-sdk/agent-loop
…[hooks](/docs/en/agent-sdk/hooks.md). * **Manual compaction:** Send `/compact` as a prompt string to trigger compaction on demand. Commands sent this way are ordinary SDK inputs. See [dispatch comman…
Extend agents with skills
Claude Code CLI · in the page
agent-sdk/skills
…e logic coded into the Claude Code process the SDK runs, for example `/compact` * **Bundled skills**: prompt artifacts included with Claude Code, for example `/code-review` * **Your skills**: prompt a…
Agent SDK reference - TypeScript
Claude Code CLI · in the page
agent-sdk/typescript
…rn that a command completed without entering the agent loop, such as `/compact`. The name is folded to lowercase letters and underscores, so `/reload-plugins` reports `reload_plugins`. A command that…
Orchestrate teams of Claude Code sessions
Claude Code CLI · in the page
agent-teams
…uilt-in commands go to the lead's session, with these safeguards: * `/compact`, `/clear`, and `/rewind` act on the lead's conversation, so Claude Code asks you to confirm before running one of them f…
Best practices for Claude Code
Claude Code CLI · in the page
best-practices
…ode patterns, file states, and key decisions * For more control, run `/compact <instructions>`, like `/compact Focus on the API changes` * To compact only part of the conversation, use `Esc + Esc` or…
Claude Code changelog
Claude Code CLI · in the page
changelog
…, as in `claude -p` runs and cloud sessions * Fullscreen mode: Fixed `/compact` and auto-compact briefly freezing the UI while the visible transcript is rebuilt * Self-hosted runner: Fixed sessions st…
Checkpointing
Claude Code CLI · in the page
checkpointing
…eeps you in the same session and compresses context, like a targeted `/compact`. To branch off and try a different approach while preserving the original session intact, use [`/branch`](/docs/en/sessi…
Use Claude Code in the cloud
Claude Code CLI · in the page
claude-code-on-the-web
…): | Command | Works in cloud sessions | Notes | | :- | :- | :- | | `/compact` | Yes | Summarizes the conversation to free up context. Accepts optional focus instructions like `/compact keep the test…
Commands
Claude Code CLI · in the page
commands
…nversation gets long, `/context` shows what's filling the window and `/compact` summarizes it to free space. Use `/btw` for a side question that shouldn't add to the conversation history. **Run work…
Explore the context window
Claude Code CLI · in the page
context-window
…lows its instructions to stage, commit, and push your changes. After `/compact`, Claude Code re-injects the body of each skill you invoked, capped at 5,000 tokens per skill.', tip: 'Set `disable-m…
Manage costs effectively
Claude Code CLI · in the page
costs
…nds in `run` and a command | `30% Compact before you step away · run /compact` | Nothing happens for this row. Run the command yourself at the Claude Code prompt | | Ends in anything else | `25% Tri…
Message your other Claude Code sessions
Claude Code CLI · in the page
cross-session-messaging
…. * **Commands don't run**: a command in the message's text, such as `/compact`, arrives as plain text. Claude Code never executes it. * **Permission prompts still fire**: if acting on the message req…
Desktop application
Claude Code CLI · in the page
desktop
…summarizes the conversation and continues working. You can also type `/compact` to trigger summarization earlier and free up context space. See [the context window](/docs/en/how-claude-code-works.md#t…
Error reference
Claude Code CLI · in the page
errors
…| [Request errors](#prompt-is-too-long) | | `Context limit reached · /compact or /clear to continue` | [Request errors](#prompt-is-too-long) | | `Context limit reached · /clear to continue` | [Reques…
Glossary
Claude Code CLI · in the page
glossary
…me` in the prompt. Built-in commands such as `/clear`, `/model`, and `/compact` control the session. You can define your own commands as files in `.claude/commands/`, or install them from a [plugin](#…
Hooks reference
Claude Code CLI · in the page
hooks
…automatically: | Matcher | When it fires | | :- | :- | | `manual` | `/compact` | | `auto` | Auto-compact when the conversation reaches the [auto-compact window](/docs/en/model-config.md#set-the-auto-…
How Claude Code works
Claude Code CLI · in the page
how-claude-code-works
…compaction, add a "Compact Instructions" section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refil…
Customize keyboard shortcuts
Claude Code CLI · in the page
keybindings
…, `"meta+g": "command:compact"` in a `Chat` block makes `Meta+G` run `/compact` | \*On Windows without VT mode (Node \<24.2.0/\<22.17.0, Bun \<1.2.23), defaults to Meta+M. ### Autocomplete actions…
Connect Claude Code to an LLM gateway
Claude Code CLI · in the page
llm-gateway-connect
…rompt-is-too-long) and doesn't compact and retry automatically | Run `/compact` to recover the session. To prevent it, set `CLAUDE_CODE_AUTO_COMPACT_WINDOW` to the gateway's limit; Claude Code clamps…
Claude Code gateway compatibility guide
Claude Code CLI · in the page
llm-gateway-protocol
…it: `auto` when the context window approached capacity, `manual` for `/compact`, or `reactive` when the API rejected a request as too long. The value is also `auto` for [idle compaction](/docs/en/sett…
How Claude remembers your project
Claude Code CLI · in the page
memory
…imit to files that load on demand. ### Instructions seem lost after `/compact` Project-root CLAUDE.md survives compaction: after `/compact`, Claude re-reads it from disk and re-injects it into the s…
How Claude Code uses prompt caching
Claude Code CLI · in the page
prompt-caching
…atically. See why a model switch triggers a slow uncached turn, what `/compact` costs, why CLAUDE.md edits don't apply mid-session, and how to check your cache hit rate. Prompt caching makes Claude C…
Continue local sessions from any device with Remote Control
Claude Code CLI · in the page
remote-control
…e. The following work from mobile and web: * Text-output commands: `/compact`, `/clear`, `/context`, `/usage`, `/exit`, `/usage-credits`, `/recap`, and `/reload-plugins`. `/usage-credits` prints the…