Feature request: PostCompact hook event

Resolved 💬 2 comments Opened Mar 26, 2026 by migueldeguzman Closed Mar 26, 2026

Problem

There's no hook event that fires after /compact runs. This means users who maintain stateful context (like persona systems loaded via skills) lose that state after compaction and must manually reload it.

Current workaround

Two-step process: /compact/anders (or whichever persona skill). This is friction every time context gets large.

Proposed solution

Add a PostCompact hook event that fires after compaction completes. This would allow users to:

  1. Automatically reload persona/context state after compaction
  2. Run any post-compaction setup (re-reading key files, restoring state, etc.)

Example usage

{
  "hooks": {
    "PostCompact": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "cat ~/.claude/active-persona",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

The hook output could tell Claude which persona to reload, or provide other context that was lost during compaction.

Alternative considered

  • Using UserPromptSubmit to detect post-compact state — but there's no reliable way to distinguish "first prompt after compact" from any other prompt.
  • Creating a custom /resume skill — but this still requires the user to remember to type it manually after every compact.
  • Adding instructions to CLAUDE.md — soft instruction, not guaranteed.

Use case

I run a multi-persona system where different AI personas (Anders, Mia, Fred, etc.) are loaded via skills. Each persona loads identity files, memory, and workspace context. After /compact, all of this is gone and must be manually reloaded. A PostCompact hook would make this seamless.

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗