Part 5 · Beyond the Prompt

Prompt Engineering · ~7 min

The Re-read Protocol

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.

Why this, for you: Lesson 10 covered the rule that fades while still in context. This is worse — a rule that is silently rewritten the instant a long session compacts, with no error to catch. If you run agents long enough to hit auto-compaction, this is the failure that breaks your carefully placed rules after they were working fine, and the one-line move that restores them.

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).

1 Survival is not compliance

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).

Fade-out (Lesson 10) is the rule losing attention while its text stays exact. Compaction loss is the rule's text being paraphrased into a summary — a lower-fidelity copy. Users report behaviour that was reliable before the compaction event being violated after it, not because the file was removed, but because the summary no longer carries the full constraint set.

2 Re-read, then confirm

The fix is to make the refresh explicit rather than trusting the reload. The minimal form is a prompt issued before resuming work:

# minimal — re-read the file from disk: Reread AGENTS.md so it's still fresh in your mind. # higher compliance — re-read AND prove it landed: Reread AGENTS.md and confirm the key rules you found before continuing.

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.

3 Automate it on the compaction event

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:

# .claude/settings.json — fire only on compact resumes "SessionStart": [{ "matcher": "compact", "hooks": [{ "type": "command", "command": "$HOME/.local/bin/claude-post-compact-reminder" }]}] # the script's stdout becomes context — mandatory, with confirm: IMPORTANT: Context was just compacted. STOP. Read AGENTS.md NOW and confirm the key rules before proceeding with any task.

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.

One agent isn't the whole story

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.

↪ Your win: restore fidelity, don't assume it

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…

Ask me anything. Want to wire a 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.
✎ Feedback