Built-in tools (Glob, Grep, Explore) ignore user instructions to prefer git-aware commands

Resolved 💬 4 comments Opened Feb 1, 2026 by kojiromike Closed Mar 2, 2026

Problem

Claude Code's built-in tools (Glob, Grep, Task/Explore agents) use find, rg, and similar commands under the hood. The system prompt actively instructs Claude to use these tools instead of shell equivalents. This creates a conflict when users configure CLAUDE.md or memory files to prefer git-aware alternatives like git grep and git ls-files.

Even with explicit instructions like:

- **Prefer `git grep`** over `grep` or `rg` for searching file contents
- **Prefer `git ls-files`** over `find` for listing/finding files
- These commands are faster and automatically respect `.gitignore`

Claude still routes searches through Glob/Grep/Explore, which traverse untracked files, build artifacts, vendored dependencies, etc. The user's instructions are effectively overridden by the system prompt telling Claude to use these built-in tools.

Impact

  • Wasted tokens: Results include noise from ignored/untracked files that git grep and git ls-files would exclude automatically.
  • Slower searches: Scanning the full filesystem is slower than git's index-based lookups, especially in large repos.
  • User instructions ignored: This undermines trust in CLAUDE.md as a way to customize behavior. Users set these preferences for good reasons and expect them to be respected.

Expected behavior

When a user's CLAUDE.md instructs Claude to prefer git grep / git ls-files, Claude should respect that and use Bash with those commands for file search and content search, rather than routing through Glob/Grep/Explore agents whose system prompts override the user's preference.

Also, the built-in tools could be made git-aware: when operating inside a git repo, Glob could use git ls-files patterns and Grep could use git grep under the hood.

View original on GitHub ↗

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