claude-code - 💡(How to fix) Fix .claudeignore is not respected by Glob/Grep tools — only affects auto-context loading [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46699Fetched 2026-04-12 13:35:23
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×5closed ×1commented ×1

.claudeignore entries are ignored when Claude explicitly calls Glob or Grep tools. The file only affects automatic context loading, not tool-based file searches.

Root Cause

.claudeignore entries are ignored when Claude explicitly calls Glob or Grep tools. The file only affects automatic context loading, not tool-based file searches.

RAW_BUFFERClick to expand / collapse

Summary

.claudeignore entries are ignored when Claude explicitly calls Glob or Grep tools. The file only affects automatic context loading, not tool-based file searches.

Environment

  • Claude Code version: 2.1.101
  • OS: macOS 25.4.0 (Darwin)
  • Shell: zsh

.claudeignore content

```

Virtual environment — large, not needed for analysis

.venv/ venv/ pycache/ ```

Steps to Reproduce

  1. Add .venv/ to .claudeignore
  2. Ask Claude to find test files (e.g., "run tests" or "find test files")
  3. Claude calls Glob with pattern **/test_*.py
  4. Results include .venv/lib/.../test_*.py files — .claudeignore is not applied

Expected Behavior

Glob and Grep tools should respect .claudeignore and exclude matching paths from results.

Actual Behavior

.venv/ entries appear in Glob/Grep results despite being listed in .claudeignore.

Example paths returned:

  • .venv/lib/python3.14/site-packages/Cryptodome/SelfTest/Util/test_number.py
  • .venv/lib/python3.14/site-packages/Cryptodome/SelfTest/Signature/test_eddsa.py
  • .venv/lib/python3.14/site-packages/Cryptodome/SelfTest/Hash/test_SHA256.py

Impact

  • Claude wastes context window on irrelevant third-party package files
  • Test discovery may incorrectly include third-party package tests
  • Users have no reliable way to exclude directories from Glob/Grep tool searches
  • .claudeignore behavior is inconsistent and misleading — works for auto-context but not tool calls

extent analysis

TL;DR

Modify the Glob and Grep tool calls to manually exclude paths matching .claudeignore entries.

Guidance

  • Review the .claudeignore file to ensure it correctly lists directories to be excluded, such as .venv/ and venv/.
  • Update the Glob pattern to explicitly exclude ignored directories, for example, by adding a negative match for .venv/.
  • Consider modifying the Claude configuration to automatically apply .claudeignore rules to tool-based file searches.
  • Verify the fix by re-running the test file discovery with the updated Glob pattern or configuration.

Example

# Example Glob pattern that excludes .venv/
glob_pattern = "**/test_*.py"
excluded_dirs = [".venv/"]
for dir in excluded_dirs:
    glob_pattern += " && !**/" + dir + "/**"

Notes

The current implementation of .claudeignore only affects automatic context loading, and a separate solution is needed for tool-based file searches.

Recommendation

Apply a workaround by modifying the Glob and Grep tool calls to manually exclude ignored directories, as a permanent fix may require updates to the Claude codebase.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix .claudeignore is not respected by Glob/Grep tools — only affects auto-context loading [1 comments, 2 participants]