You have files (logs, traces, generated output) that should be:
- Ignored by git - they shouldn't be committed
- Searchable by Claude Code - so the AI can find and use them
By default, Claude Code's search respects .gitignore, so gitignored files are invisible to search.
ripgrep (which powers Claude Code's Grep tool) supports .ignore files that take precedence over .gitignore. Use negation patterns (!) to override gitignore rules.
In your directory, create two files:
your-directory/
├── .gitignore # Contains: *
├── .ignore # Contains: !*
└── ... (your files)
| File | Content | Effect |
|---|---|---|
.gitignore |
* |
Git ignores all files in this directory |
.ignore |
!* |
ripgrep un-ignores them, making them searchable |
ripgrep's ignore precedence (highest to lowest):
.ignorefiles.rgignorefiles.gitignorefiles
The ! prefix negates a pattern. So !* in .ignore overrides * in .gitignore for ripgrep, while git only sees its own .gitignore.
- Zero configuration - no Claude Code or VS Code settings changes needed
- Self-contained - the solution lives entirely within the directory
- Works with nested directories - each directory can have its own rules
- Standard ripgrep behavior - not Claude-specific, works with any ripgrep-based tool