Add an opt-out for the built-in find→bfs / grep→ugrep shadow functions injected into the Bash tool shell

Open 💬 2 comments Opened Jun 20, 2026 by ccharname

Title: Add an opt-out for the built-in find→bfs / grep→ugrep shadow functions injected into the Bash tool shell

What happens

The Bash tool's shell snapshot (~/.claude/shell-snapshots/snapshot-zsh-*.sh) injects shadow functions that replace find and grep with bundled bfs / ugrep binaries:

# Shadow find/grep with embedded bfs/ugrep
unalias find 2>/dev/null || true
unalias grep 2>/dev/null || true
function find {
  ...
  ARGV0=bfs "$_cc_bin" -S dfs -regextype findutils-default "$@"
}
function grep {
  ...
  ARGV0=ugrep "$_cc_bin" -G --ignore-files --hidden -I --exclude-dir=.git ... "$@"
}

These are not user aliases — they are emitted by Claude Code itself and run on every Bash tool call.

Why it's a problem

bfs and ugrep are not drop-in for GNU find/grep:

  • bfs leading-dash paths: find ./-somedir -name '*.x' (a directory whose name starts with -) fails under bfs — it parses the path as an unknown flag (Unknown argument; did you mean -ignore_readdir_race?). The same command works with GNU find. This silently breaks agent-generated commands.
  • ugrep --ignore-files: makes grep honor .gitignore by default, so a literal grep over a repo silently skips ignored files — different result set than GNU grep, no error, no signal.

The agent (and users) reasonably assume find/grep mean the system tools. The workaround is to type \find / \grep / command find everywhere, which is easy to forget and pollutes generated commands.

What I'm asking for

An opt-out, any of:

  1. An env var, e.g. CLAUDE_CODE_DISABLE_BUILTIN_SEARCH=1, that skips emitting the find/grep shadow functions into the snapshot.
  2. A settings.json key (e.g. "disableBuiltinSearchShadows": true).
  3. Failing a global toggle, make the shadows opt-in rather than opt-out.

Environment

  • Claude Code 2.1.183, macOS (darwin), zsh 5.9
  • Confirmed no existing env/setting disables this (grepped the version dir for BFS/UGREP/SHADOW toggles — none found).

Related

Snapshot also serializes user ~/.zshrc aliases (cat=bat, ls=eza, cp -i, …) into the non-interactive tool shell; users can guard those with [[ -o interactive ]], but the find/grep shadows above are CC-injected and have no such escape hatch.

View original on GitHub ↗

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