Hook event for CLAUDE.md file loading

Resolved 💬 3 comments Opened Feb 27, 2026 by Threynaud Closed Mar 2, 2026

Summary

When Claude Code lazily loads nested CLAUDE.md/AGENTS.md files (triggered by reading files in a directory), the CLI displays a "Loaded backend/CLAUDE.md" annotation. However, this event is invisible to the hooks system — there's no way to programmatically track which project instruction files were consumed during a session.

Current behavior

When Claude reads a file in a directory containing a CLAUDE.md, the CLI shows:

⏺ Read(backend/cloudflare/cloudflare-cdn-proxy.js)
  ⎿  Read 191 lines
  ⎿  Loaded backend/CLAUDE.md

The "Loaded" line is a UI-only annotation. It does not appear in CLAUDE_TOOL_OUTPUT and no hook event fires for it.

What I tried

I configured a PostToolUse hook on Read to grep CLAUDE_TOOL_OUTPUT for "Loaded" lines:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Read",
        "hooks": [
          {
            "type": "command",
            "command": "echo \"$CLAUDE_TOOL_OUTPUT\" | grep -i 'Loaded.*CLAUDE\\.md' >> ~/.claude/claude-md-log.txt 2>/dev/null; true"
          }
        ]
      }
    ]
  }
}

The log file remains empty after confirmed "Loaded" events in the UI, confirming CLAUDE_TOOL_OUTPUT does not include this information.

Feature request

One of the following would enable tracking:

  1. New hook event (preferred): A ContextFileLoaded event that fires when CLAUDE.md/AGENTS.md files are loaded into context, with the file path available as an environment variable.
  1. Include in CLAUDE_TOOL_OUTPUT: Append the "Loaded X/CLAUDE.md" line to the tool output so existing PostToolUse hooks can capture it.

Use case

Observability over which project instructions are active in a session — useful for debugging agent behavior in monorepos with many nested CLAUDE.md files.

View original on GitHub ↗

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