Search the documentation
10 pages for precompact.
Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.
How the agent loop works
Claude Code CLI · in the page
agent-sdk/agent-loop
…compactor matches on intent, so the section header is free-form. * **`PreCompact` hook:** Run custom logic before compaction occurs, for example to archive the full transcript. The hook receives a `tr…
Intercept and control agent behavior with hooks
Claude Code CLI · in the page
agent-sdk/hooks
…| | `PreCompact` | Yes | Yes | Conversation compaction request…
Agent SDK reference - Python
Claude Code CLI · in the page
agent-sdk/python
…ng execution "SubagentStop", # Called when a subagent stops "PreCompact", # Called before message compaction "Notification", # Called for notification events "SubagentStart", # Cal…
Agent SDK reference - TypeScript
Claude Code CLI · in the page
agent-sdk/typescript
…this option. Some hook events, such as `Notification`, `SessionEnd`, `PreCompact`, and `PostCompact`, never produce an `SDKHookStartedMessage`, even with this option. For those events, Claude Code sti…
CLI reference
Claude Code CLI · in the page
cli-reference
…d this flag. Some hook events, such as `Notification`, `SessionEnd`, `PreCompact`, and `PostCompact`, never produce a `hook_started` event, even with this flag. For those events, Claude Code still emi…
Explore the context window
Claude Code CLI · in the page
context-window
…const visibleCount = EVENTS.filter(e => e.t <= time).length; const preCompactVisible = useMemo(() => EVENTS.slice(0, visibleCount), [EVENTS, visibleCount]); const compactGateIdx = GATES.length -…
Hooks reference
Claude Code CLI · in the page
hooks
…d, TaskCompleted), and Stop or StopFailure, followed by TeammateIdle, PreCompact, PostCompact, and SessionEnd, with Elicitation and ElicitationResult nested inside MCP tool execution, PermissionDenied…
Automate actions with hooks
Claude Code CLI · in the page
hooks-guide
…| | `PreCompact` | Before context compaction…
Plugins reference
Claude Code CLI · in the page
plugins-reference
…| | `PreCompact` | Before context compaction…
Week 16 · April 13–17, 2026
Claude Code CLI · in the page
whats-new/2026-w16
…<code>/security-review</code> via the Skill tool</div> <div><code>PreCompact</code> hooks can block compaction by exiting with code 2 or returning <code>{"{"}"decision":"block"{"}"}</code></div>…