[BUG] Glob tool doesn't respect .gitignore
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?
- Grep (ripgrep) correctly ignores node_modules/ via .gitignore
- Glob returns 100+ files from node_modules/ when searching **/*.md
What Should Happen?
Glob should respect .gitignore patterns
Error Messages/Logs
Steps to Reproduce
- Create a repo with node_modules/ in .gitignore
- Have a node_modules/ directory with .md files (e.g., via npm install in a
subdirectory)
- In Claude Code, ask: "find all markdown files" or similar
Expected: Only repo-owned .md files returned (respecting .gitignore)
Actual: Glob returns 100+ files from node_modules/
Comparison:
# Glob tool (doesn't respect .gitignore)
Glob(pattern: "**/*.md") → 100+ files including node_modules/
# Grep tool (respects .gitignore)
Grep(pattern: "README", glob: "*.md") → 1 file (only repo files)
Environment:
- Claude Code CLI
- macOS (Darwin 25.2.0)
- Repo structure: infra/node_modules/ with CDK dependencies
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.19
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗