[DOCS] SDK /compact slash command output
Resolved 💬 5 comments Opened Sep 16, 2025 by benbrandt Closed Sep 29, 2025
Documentation Type
Incorrect/outdated documentation
Documentation Location
https://docs.anthropic.com/en/docs/claude-code/sdk/sdk-slash-commands#common-slash-commands
Section/Topic
SDK Slash Commands /compact
Current Documentation
The /compact command reduces the size of your conversation history by summarizing older messages while preserving important context:
import { query } from "@anthropic-ai/claude-code";
for await (const message of query({
prompt: "/compact",
options: { maxTurns: 1 }
})) {
if (message.type === "system" && message.subtype === "compact_boundary") {
console.log("Compaction completed");
console.log("Pre-compaction tokens:", message.compact_metadata.pre_tokens);
console.log("Trigger:", message.compact_metadata.trigger);
}
}
What's Wrong or Missing?
What actually gets returned from the SDK is a message type of "user" with the following content:
<local-command-stdout>Compacted </local-command-stdout>
Suggested Improvement
Either update the documentation or the code to match the expected behavior.
Impact
High - Prevents users from using a feature
Additional Context
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗