Back
39/65
Lesson 39
4 min
PCR: Post-Compact Reminder
Keep agents aligned after context compaction
Ready to level up?
Mark complete to track your learning progress.
Keep agents aligned after context compaction
Mark complete to track your learning progress.
Keep agents aligned after context compaction with Post-Compact Reminder.
PCR (Post-Compact Reminder) is a Claude Code hook that fires after context compaction and forces the agent to re-read AGENTS.md. This prevents agents from “forgetting” project rules and conventions after their context window is compressed.
Without PCR, agents that hit context limits lose awareness of project-specific instructions. PCR ensures continuity by automatically injecting a reminder to re-read the project guidelines.
Triggers on every context compaction event
Forces re-reading project guidelines
Restores lost project awareness after compaction
Installs as a Claude Code hook, works automatically
# PCR registers a SessionStart hook in Claude Code settings# with matcher: "compact". Claude sends JSON on stdin when that event fires.# Simulate the exact compact payload locally:echo '{"session_id":"demo","source":"compact"}' | \~/.local/bin/claude-post-compact-reminder# Normal startup events stay quiet because the hook only emits output when# source == "compact".
PCR does not parse AGENTS.md or CLAUDE.md itself. Its job is narrower and safer: emit a reminder after compaction so the agent re-reads the project instructions before continuing.
You can also change the reminder tone without touching the hook script by re-running the installer with templates like minimal, detailed, checklist, or default.
Watch what happens when context compaction hits — with and without PCR. Click Fill Context to simulate a long session, then Compact to trigger compaction. Toggle PCR on/off to compare the outcomes.