Repository navigation
Conversation
…for exact lookups
The Claude plugin's SessionStart context ("CRITICAL: You MUST use the
mgrep skill for ALL searches. NEVER use built-in WebSearch or Grep
tools ...") and skill description ("MANDATORY: Replaces ALL built-in
search tools ...") make Claude call mgrep for every exact lookup and
about four times per conceptual question.
Replace both with neutral guidance: mgrep for conceptual or cross-file
questions where the identifier is unknown, Grep or rg for exact strings,
symbols and regexes. The context names the session directory. Watcher
behaviour and the update notice are unchanged.
In a 150-run benchmark (claude -p, Opus 5.5) the new text keeps mgrep
on all conceptual questions with one call each, drops it from all exact
lookups, keeps correctness at 50/50 and lowers total cost by 18%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Claude plugin steers with two texts that tell Claude to use mgrep for every search:
plugins/mgrep/hooks/mgrep_watch.py) adds "CRITICAL: You MUST use the mgrep skill for ALL searches. NEVER use built-in WebSearch or Grep tools. ...";plugins/mgrep/skills/mgrep/SKILL.md) is described as "MANDATORY: Replaces ALL built-in search tools. ... NEVER use the built-in Grep tool ...".Measured in isolated
claude -pruns, Claude follows this literally. It calls mgrep on every exact lookup, where a single Grep is enough, and calls it about four times per conceptual question. The exact lookups get three times slower and almost three times more expensive.Expected: Claude uses mgrep where semantic search helps (conceptual and cross-file questions) and Grep/rg for exact strings and symbols.
Change
Both texts are replaced with neutral guidance. The watcher behaviour does not change.
SessionStart context. Old:
New (
{cwd}is the session directory from the hook payload):What changed and why:
Skill description. Old: "MANDATORY: Replaces ALL built-in search tools. You MUST invoke this skill BEFORE using WebSearch, Grep, or Glob. NEVER use the built-in WebSearch tool - use
mgrep --webinstead. NEVER use the built-in Grep tool - usemgrepinstead." New: "Semantic search for conceptual questions about project files, alongside Grep and rg for exact matches." The body keeps the usage and options and drops the "CRITICAL: Tool Override" and the ❌/✅ lists.Scope and approval
There is no prior issue or discussion. The change touches only the two steering texts and their tests. #153 makes the same change for Codex, where the benchmark showed the same effect. I've used mgrep with Claude Code since January and would like the default to work well for everyone. Happy to adjust the wording.
Verification
Benchmark:
claude -p(Claude Code 2.1.291, Opus 5.5 with 1M context, effort high), isolated from the user's own configuration. The isolation used no user settings,CLAUDE.md, plugins, hooks or MCP servers, checked in each run'sinitevent, with only the variant plugin loaded through--plugin-dir, read-only. The target was a private 853-file TypeScript monorepo that was already indexed, and the hook started no watcher during the runs. 10 questions: 6 conceptual (no identifiers named) and 4 exact (a symbol, a literal error string, a config key, an env var). 5 runs per question and variant, 150 runs, none failed. Correct = the answer cites at least one expected file. Costs are Claude Code's owntotal_cost_usd.The new text is cheaper than the current one on 9 of 10 questions and cheaper than no steering on all 10. With it, Claude runs one
mgrep search, reads the returned ranges and confirms specifics with Grep. Unlike the current text, conceptual questions also cost less than with no steering (−17%), so steering toward mgrep pays off once it is selective.Tests: the SessionStart hook tests now assert the new text and the session directory, the update-notice tests still pass, and a new test checks that the context contains none of "CRITICAL", "MUST", "NEVER" or "MANDATORY". 47 bats tests pass.
Not checked: other models than Opus 5.5, much larger repositories, and web-search behaviour (the questions are code-only).
Model and harness: Claude Opus 5.5 (1M context) in Claude Code for design, review and benchmarking; GPT-6.1-Sol in Codex for implementation.