[Bug] Model repeatedly falls back to grep despite CLAUDE.md rule, stored memory and per-call hook reminder to use the project's MCP search tool first
Summary
The user's CLAUDE.md requires a project knowledge index (MDKB, exposed as an MCP server and a CLI) to be queried before any grep/rg filesystem search. The rule is reinforced three ways, all present in context during the failing turn:
- An explicit instruction in the loaded CLAUDE.md hierarchy ("Ask a repository's own MDKB before reading its source; use
rgonly when the index cannot answer"). - A stored memory surfaced at session start ("MDKB before rg, every time", recorded after an earlier user correction).
- A PreToolUse hook that injects "Use
mdkb search ...instead" as additional context on grep-like Bash calls.
The model still went to grep after one shallow index query.
Reproduction (observed 2026-10-04, Claude Code with claude-opus-5-5, long-running coordinator session after auto-compaction)
- User asks about a problem in project B, while the session's working directory is project A.
- Model runs one index search from project A's directory (wrong index), gets unrelated results.
- Instead of re-querying the index from project B, the model runs
grepover files. The hook reminder appears; the model ignores it. - Only after the user complains does the model query project B's index, which returns the relevant documents.
This is not a one-off: the same user correction was recorded as a memory on an earlier day, and the behavior recurred.
Expected
When the user's instructions name a preferred search tool, and a hook reminds on every violating call, the model uses that tool first (and in the correct scope) and treats grep as the fallback only when the index cannot answer.
Actual
The model treats the rule and the hook reminder as advisory and defaults to grep. The only reliable mitigation left to the user is a blocking hook, which should not be necessary for an explicit, repeated instruction.
Related
#98870, #95718, #95142 (CLAUDE.md instructions not followed). This report adds a concrete case where the instruction is reinforced by memory and a per-call hook reminder, and is still ignored.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗