Prompt Engineering · ~7 min
Compaction frees context by summarising the conversation — and quietly paraphrases your instruction files in the process. The rules survive on disk; their precision doesn't. The fix is a targeted re-read.
When an agent compacts a long session, it summarises older turns to free context space. The summary preserves task state — what was done, what remains — but paraphrases the instruction-file references it carried, losing their precision. The agent works on, with degraded rule fidelity and no visible error signal (post-compaction-reread-protocol).
The trap is assuming that because CLAUDE.md is reloaded after compaction, its rules still bind. Claude
Code does reload it — the InstructionsLoaded hook fires with load_reason: "compact" — but
reload alone does not reliably restore behavioural compliance
(claude-code#14258).
The fix is to make the refresh explicit rather than trusting the reload. The minimal form is a prompt issued before resuming work:
The confirmation requirement is not decoration. Asking the agent to state the key rules it found forces the constraint set back into recent, high-attention context and gives you a visible signal that the re-read actually took — directive-only prompts restore less reliably than re-read-and-confirm.
Relying on yourself to remember after every compaction is fragile. A SessionStart hook with
matcher: "compact" fires only on compaction resumes, and its stdout is injected into the agent's context —
so the re-read directive arrives automatically, exactly when the loss happened:
The mandatory, stop-and-confirm phrasing is intentional: a polite suggestion is treated as optional; an explicit
directive is not. Note the right hook — PostCompact (added in v2.1.76) fires after compaction but has
no context-injection capability, so it suits logging, not re-read. Use SessionStart.
In a multi-agent run, each subagent's context can compact independently — so the re-read must apply per-agent, not just at the orchestrator. Three approaches trade off setup against coverage: a manual prompt needs no wiring but relies on you remembering; the SessionStart hook is deterministic but Claude-Code-only and fires on resume, not mid-session; a marker-based PreCompact pair catches mid-session auto-compaction at the cost of wiring two hooks. Match the form to how your agents actually compact.
SessionStart with matcher: "compact", not PostCompact.Retrieval practice — recall, don't peek
Question 1Compaction degrades rule fidelity because the summary…
Question 2Reloading CLAUDE.md after compaction does not…
Question 3Adding "confirm the key rules you found" to the re-read prompt mainly…
Question 4To inject a re-read directive on compaction, the right hook is…
Question 5 · spaced recall from Lesson 11A rule belongs in a hook rather than the prompt only when it is non-negotiable, binary, and…
SessionStart hook for your own AGENTS.md, or
decide whether your runs compact often enough to need one at all? Next, we open Part 6 and stop fixing single rules:
The Production Stack — how a whole shipping system prompt is actually assembled.