The whole hunk
from line 1591, old and new numbered
/
lines
from line 1591
15911591
15921592When a long session compacts, Claude Code summarizes the conversation history to fit the context window. As of v2.1.198, the summarization request inherits your session's [extended thinking](/docs/en/model-config#extended-thinking) configuration, so it reasons with thinking enabled when your session has it enabled and stays off otherwise. Thinking affects only how the summary is produced; your session settings are unchanged afterward. What happens to each kind of content depends on how it was loaded:
15931593
1594| Mechanism | After compaction |
1595| :------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------ |
1596| System prompt and output style | Both still apply |
1597| Project-root CLAUDE.md and unscoped rules | Re-injected from disk |
1598| Auto memory | Re-injected from disk |
1599| The plan Claude wrote in [plan mode](/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode) | Re-injected from disk |
1600| Rules with `paths:` frontmatter | Claude Code reloads them as Claude reads files they match |
1601| Nested CLAUDE.md in subdirectories | Claude Code reloads them as Claude reads files in that subdirectory |
1602| Files Claude read or edited | Claude Code re-reads up to five, most recently modified first |
1603| Invoked skill bodies | Re-injected, capped at 5,000 tokens per skill and 25,000 tokens total; oldest dropped first |
1604| Context that hooks added earlier | Summarized with the rest of the conversation |
1605| [SessionStart hooks](/docs/en/hooks-guide#re-inject-context-after-compaction) that match the `compact` source | Claude Code runs them and adds their output to the compacted context |
1594| Mechanism | After compaction |
1595| :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------- |
1596| System prompt and output style | Both still apply |
1597| Project-root CLAUDE.md and unscoped rules | Re-injected from disk |
1598| Auto memory | Re-injected from disk |
1599| The plan Claude wrote in [plan mode](/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode) | Re-injected from disk |
1600| Rules with `paths:` frontmatter | Claude Code reloads them as Claude reads files they match |
1601| Nested CLAUDE.md in subdirectories | Claude Code reloads them as Claude reads files in that subdirectory |
1602| Files Claude read or edited | Claude Code re-reads up to five, most recently modified first |
1603| Invoked skill bodies | Re-injected, capped at 5,000 tokens per skill and 25,000 tokens total; oldest dropped first |
1604| [Background commands](/docs/en/interactive-mode#background-bash-commands) and background [subagents](/docs/en/sub-agents#run-subagents-in-foreground-or-background) | Keep running. Claude Code reminds Claude which ones are still running so it doesn't start a duplicate |
1605| Context that hooks added earlier | Summarized with the rest of the conversation |
1606| [SessionStart hooks](/docs/en/hooks-guide#re-inject-context-after-compaction) that match the `compact` source | Claude Code runs them and adds their output to the compacted context |
16061607
16071608Path-scoped rules and nested CLAUDE.md files load into message history when their trigger file is read, so compaction summarizes them away with everything else. Right after compaction, Claude Code re-reads up to five of the files Claude has read or edited in the session, choosing the ones modified most recently, and reloads the rules and nested CLAUDE.md files that apply to those files. A file over 5,000 tokens comes back as a path reference without its content, shown as `Referenced file` instead of `Read`. Its rules still reload. If a rule must persist across compaction, drop the `paths:` frontmatter or move it to the project-root CLAUDE.md.
16081609