[BUG] InstructionsLoaded hook does not fire after compaction

Resolved 💬 2 comments Opened Mar 5, 2026 by shanraisshan Closed Apr 3, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The InstructionsLoaded hook fires correctly at session start (with "load_reason": "session_start"), but does not fire again after compaction, even though the instructions (CLAUDE.md, rules files, memory files) are clearly re-injected into context.

Evidence from hooks-log.jsonl

At session start — InstructionsLoaded fires for each file:

{
  "hook_event_name": "InstructionsLoaded",
  "file_path": "...CLAUDE.md",
  "load_reason": "session_start"
}
{
  "hook_event_name": "InstructionsLoaded",
  "file_path": "...test-instructions-loaded.md",
  "load_reason": "session_start"
}

After compaction — SessionStart fires with "source": "compact", but no InstructionsLoaded events follow:

{
  "hook_event_name": "SessionStart",
  "source": "compact"
}
// No InstructionsLoaded events here, even though instructions are reloaded into context

The system-reminder tags in the post-compaction context confirm that CLAUDE.md and rules files ARE being loaded — but the hook doesn't fire for them.

Expected Behavior

InstructionsLoaded should fire after compaction for each instruction file that is re-injected into context, similar to how it fires at initial session start. The load_reason could be "compact" or "reload" to distinguish it from "session_start".

Environment

  • macOS (Darwin 25.3.0)
  • Claude Code latest version
  • Model: claude-opus-4-6

What Should Happen?

InstructionsLoaded should fire after compaction for each instruction file that is re-injected into context (CLAUDE.md, rules files, memory files), just as it does at initial session start. The load_reason could be "compact" or "reload" to distinguish from the initial "session_start" reason.

Error Messages/Logs

No error messages. The hook simply does not fire. The hooks-log.jsonl shows SessionStart with "source": "compact" but no subsequent InstructionsLoaded entries, even though the instructions are confirmed to be present in the post-compaction context via system-reminder tags.

Steps to Reproduce

  1. Set up an InstructionsLoaded hook in .claude/settings.json that logs to a file (e.g., appends to a JSONL log)
  2. Start a new Claude Code session — observe that InstructionsLoaded fires for each instruction file (CLAUDE.md, rules, memory)
  3. Have a conversation until context is large, or manually run /compact
  4. After compaction, check the log file — SessionStart fires with "source": "compact", but no InstructionsLoaded events follow
  5. Verify that instructions ARE present in the post-compaction context (they appear in system-reminder tags)

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.69 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

This was discovered while building a hook-based voice notification system for all 19 Claude Code hooks. The InstructionsLoaded hook was added in a recent version and works correctly at session start, but the missing post-compaction firing means hooks that depend on knowing when instructions are reloaded (e.g., for caching, re-initialization, or notification purposes) have no way to detect this event.

The SessionStart hook does fire after compaction with "source": "compact", so the hook lifecycle is partially working — it's just the InstructionsLoaded event that's missing.

View original on GitHub ↗

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