[BUG] Grep tool returns 0 matches when bash grep finds 314 matches

Resolved 💬 6 comments Opened Jan 8, 2026 by coygeek Closed Feb 22, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Grep tool returns 0 matches (or drastically fewer matches) compared to equivalent bash grep commands on the same directory and pattern.

When searching for TODO|FIXME in ~/.claude/hooks:

  • Grep tool: 0 matches
  • Bash grep: 314 matches

The Grep tool appears to be silently excluding files or directories that bash grep includes.

What Should Happen?

The Grep tool should return results consistent with grep -r "pattern" path or clearly document what exclusions are applied (e.g., respecting .gitignore, excluding certain directories).

Error Messages/Logs

# Grep tool result:
No matches found
Found 0 total occurrences across 0 files.

# Bash grep result (same pattern, same path):
$ grep -r "TODO\|FIXME" ~/.claude/hooks --include="*.py" --include="*.sh" --include="*.md" | wc -l
314

Steps to Reproduce

  1. Have a directory with Python/shell files containing TODO comments (e.g., ~/.claude/hooks with test files)
  1. Run the Grep tool:
Grep(
  pattern="TODO|FIXME",
  path="/Users/user/.claude/hooks",
  output_mode="count"
)

Result: No matches found. Found 0 total occurrences across 0 files.

  1. Run equivalent bash grep:
grep -r "TODO\|FIXME" /Users/user/.claude/hooks --include="*.py" --include="*.sh" --include="*.md" | wc -l

Result: 314

  1. Even simpler reproduction - first grep returns only 1 match (a filename in CLAUDE.md), not the 287+ actual TODO comments in the codebase:
Grep(
  pattern="TODO|FIXME",
  path="/Users/user/.claude/hooks",
  output_mode="content",
  "-i": true,
  "-n": true
)

Result: Only 1 match from CLAUDE.md:139 (a filename reference), missing 300+ actual matches.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.1

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Session ID: 7530b6cc-afad-416a-ab26-6a15dc577600

The session shows Claude correctly using the Grep tool but receiving incomplete data:

{
  "pattern": "TODO|FIXME",
  "path": "/Users/user/.claude/hooks",
  "output_mode": "content",
  "-i": true,
  "-n": true
}

Tool returned only 1 match (a filename in documentation), leading Claude to incorrectly conclude "0 TODOs need attention" when the actual count is 314.

Hypothesis

The Grep tool may be:

  1. Respecting .gitignore patterns more aggressively than expected
  2. Excluding tests/, mutants/, or other directories by default
  3. Having issues with the | OR pattern in regex
  4. Limiting results in a way that's not documented

Impact

This causes Claude to make incorrect conclusions about codebases when using the Grep tool for analysis tasks. Users asking "how many TODOs are in my project?" will get wrong answers.

Workaround

Use bash grep instead of the Grep tool:

grep -rn "TODO\|FIXME" /path/to/project --include="*.py"

View original on GitHub ↗

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