Problem
The installer registers a SessionStart reminder hook for Claude Code (matchers startup/resume/clear/compact) that tells the agent to prefer codebase-memory-mcp tools (search_graph, trace_path, get_code_snippet, …) over grep/file-read for code discovery.
But subagents spawned via the Agent tool do not fire SessionStart — only SubagentStart/SubagentStop fire for them. So every subagent starts CMM-unaware and falls back to grep/file-read, exactly the behavior the SessionStart reminder exists to prevent. On agents that lean on subagents for exploration, much of the code navigation happens in precisely the contexts the reminder never reaches.
Proposal
Register a Claude Code SubagentStart hook (matcher *, all agent types) that injects a leaner variant of the same code-discovery guidance via hookSpecificOutput.additionalContext. Leaner = it omits the "run index_repository first" step, since the parent session has already indexed the project.
Notes:
SubagentStart injects context only via a JSON object on stdout (not the plain-text form SessionStart accepts), so the generated hook script emits a static JSON literal — no runtime escaping, no python3/jq dependency.
SubagentStart is Claude-Code-specific (added in Claude Code 2.0.43, command-type hooks only). It belongs in the Claude installer path only; Codex/Gemini/etc. have no equivalent subagent-start event. The guidance text stays tool-neutral, so the agent-agnostic boundary is preserved (only the plumbing is Claude-specific).
- Advisory, non-blocking. Older Claude Code (< 2.0.43) simply ignores the unknown event key (fail-open).
Scope
Small, self-contained: a sibling to the existing SessionStart reminder in the Claude installer, plus a unit test (~80 LOC).
Problem
The installer registers a
SessionStartreminder hook for Claude Code (matchersstartup/resume/clear/compact) that tells the agent to prefer codebase-memory-mcp tools (search_graph,trace_path,get_code_snippet, …) over grep/file-read for code discovery.But subagents spawned via the Agent tool do not fire
SessionStart— onlySubagentStart/SubagentStopfire for them. So every subagent starts CMM-unaware and falls back to grep/file-read, exactly the behavior the SessionStart reminder exists to prevent. On agents that lean on subagents for exploration, much of the code navigation happens in precisely the contexts the reminder never reaches.Proposal
Register a Claude Code
SubagentStarthook (matcher*, all agent types) that injects a leaner variant of the same code-discovery guidance viahookSpecificOutput.additionalContext. Leaner = it omits the "runindex_repositoryfirst" step, since the parent session has already indexed the project.Notes:
SubagentStartinjects context only via a JSON object on stdout (not the plain-text formSessionStartaccepts), so the generated hook script emits a static JSON literal — no runtime escaping, nopython3/jqdependency.SubagentStartis Claude-Code-specific (added in Claude Code 2.0.43, command-type hooks only). It belongs in the Claude installer path only; Codex/Gemini/etc. have no equivalent subagent-start event. The guidance text stays tool-neutral, so the agent-agnostic boundary is preserved (only the plumbing is Claude-specific).Scope
Small, self-contained: a sibling to the existing SessionStart reminder in the Claude installer, plus a unit test (~80 LOC).