V:/Program Files/Git/compact auto-read control — post-compact context management
Feedback: /compact Auto-Read Control — Post-Compact Context Management
Filed: 2026-04-04
Product: Claude Code (CLI)
Severity: MEDIUM — efficiency + token waste, not data loss
Version tested: 2.1.91, Opus 4.6 (1M context)
Related: Cache replay cost bomb (sibling feedback)
---
The Problem
After /compact (auto-compact or manual), Claude Code automatically re-reads recently-used files back into context. This creates two issues:
1. Double injection with hooks
Users who have UserPromptSubmit hooks that inject context — project status, configuration, task queues, team notifications, custom prompts — get double content on the first post-compact turn:
- Compact's auto-read of recently-used files (configs, source files, docs)
- Hook injections of overlapping content (the same configs, status files, project state)
Example: a hook injects the project's TODO.md on every prompt. Compact also auto-reads TODO.md because it was recently used. The model receives TODO.md twice. Scale this across multiple hooks (status dashboards, linter configs, test results, team chat) and the first post-compact turn adds 10-20K tokens of redundant content.
2. Auto-reads don't create useful context
The model receives the file contents but doesn't know WHY they were being used. Post-compact, the summary says "we were editing server.py" but the auto-read dumps the entire file without the model knowing it was mid-refactor on the authentication middleware. The model typically re-reads the file anyway to orient itself — making the auto-read a pure token waste.
---
Proposed Options
Option 1: No auto-reads — prioritized file list only
Post-compact, inject ONLY:
- The compact summary (already generated)
- A prioritized list of recently-used files with one-line context:
server.py (editing, auth middleware refactor),config.yaml (read for DB credentials) - Let the model (or user) decide what to re-read
Pro: Minimal post-compact bloat. User control.
Con: Model is cold-booted with a list it may not interpret well without more context. Requires good summary quality.
Option 2: Summary-only to separate file
Write the compact summary to a session-scoped file. This file is the ONLY auto-injection post-compact. No file re-reads. The summary is the complete orientation document.
Pro: Clean architecture. Single source of truth. Small injection.
Con: Single point of failure — if the summary dropped important context (active task, mid-edit state), there's no fallback. Summary quality is model-dependent.
Option 3: Current behavior (keep as-is)
Auto-read everything that was recently used.
Pro: Model has working context immediately. Files serve as ground truth even when summary is incomplete.
Con: Redundant with hook injections. Wastes tokens. Doesn't respect the user's hook investment.
Recommended: User-configurable behavior
Expose the auto-read behavior as a setting:
{
"compact": {
"autoReadFiles": "none" | "list" | "full",
"injectSummary": true,
"suppressHooksPostCompact": false
}
}
"none": summary only, no file re-reads"list": summary + file list with context hints (default)"full": current behavior (backward compatible)"suppressHooksPostCompact": if true, skip UserPromptSubmit hooks for the first turn after compact (prevents double injection)
---
Why This Matters
Users who invest in hook systems — custom dashboards, project state injection, notification feeds, automated context management — are penalized by /compact because hooks and compact's auto-reads fight over the same context space. The first post-compact turn should be the leanest turn in the session. Instead, it's the most bloated.
This compounds with the cache replay issue (sibling feedback): if the post-compact turn is large, it's also more likely to break the prompt prefix cache, causing a full replay on the next message.
---
Based on observed double-injection patterns in a production hook system with 8+ UserPromptSubmit hooks.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗