Claude Code hook

Post Compact Reminder

Claude Code hook that detects context compaction and injects a reminder to re-read AGENTS.md, preventing post-compaction rule amnesia in long sessions

55 stars 7 forksHooks Source

Install

Install
brew install jq python

Found in the project README. Check it for setup steps after installing.

From source
git clone https://github.com/Dicklesworthstone/post_compact_reminder.git

From the README

Post-Compact Reminder for Claude Code

Stop Claude from forgetting your project rules after context compaction.

Quick Install

TL;DR

The Problem: During long coding sessions, Claude Code compacts the conversation to stay within context limits. After compaction, Claude loses all memory of your project's AGENTS.md, the file that defines your coding conventions, forbidden commands, architectural decisions, multi-agent coordination rules, and everything else that keeps Claude on the rails. The result: Claude starts freelancing, ignoring your rules, deleting files you told it never to delete, and generally going on a post-compaction rampage.

The Solution: A hook system that detects compaction events and injects a short plain-text reminder telling Claude to re-read AGENTS.md before doing anything else. One install, zero maintenance, works globally across all your projects.

Why Use Post-Compact Reminder?

Quick Example

After installation, when compaction happens:
1. Claude Code triggers the SessionStart hook with source: "compact"
2. The matcher: "compact" filter ensures the hook only fires after compaction
3. Claude receives the reminder directly in its context
4. Claude re-reads AGENTS.md before proceeding

Design Philosophy

1. Simplicity.
A single SessionStart hook with matcher: "compact" detects compaction and injects the reminder directly. No marker files, no multi-hook coordination -- just one hook that fires at the right time.

2. Atomic file operations.
Every modification to settings.json is written to a temp file first, then moved into place with shutil.move(). If the process crashes mid-write, your settings file stays intact. Backups are created automatically before every modification.

3. One installer, complete functionality.
The entire project is a single…
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
Shell
Last updated
14 October 2026
Topics
ai-agentsbashclaudedeveloper-toolshooks

FAQ

What is Post Compact Reminder?

Claude Code hook that detects context compaction and injects a reminder to re-read AGENTS.md, preventing post-compaction rule amnesia in long sessions It is a hook for Claude Code, from Dicklesworthstone/post_compact_reminder on GitHub.

How do I install Post Compact Reminder?

Run brew install jq python, then follow the setup in the README.

Is Post Compact Reminder popular?

Dicklesworthstone/post_compact_reminder has 55 GitHub stars and 7 forks, and is included in 1 curated Claude Code list. It was last updated on 14 October 2026.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.