[FEATURE REQUEST] Allow Claude Code to access gitignored files
Resolved 💬 35 comments Opened Jun 19, 2025 by npupko Closed Jul 31, 2025
💡 Likely answer: A maintainer (ollie-anthropic, collaborator)
responded on this thread — see the highlighted reply below.
Current Behavior
Claude Code currently respects .gitignore files and excludes gitignored files from:
@-mention autocomplete suggestions- General file awareness and reading (unless explicitly requested)
Problem Description
This behavior creates friction for local development workflows where users want to:
- Keep certain files out of version control (private notes, local configs, etc.)
- Still have Claude Code access these files for development assistance
- Avoid committing sensitive or personal files to public repositories
Use Case Example
I maintain a local tasks/ folder with markdown files containing project notes and TODOs. These files are:
- Gitignored to keep them out of the public repository
- Useful for Claude Code to reference when providing development assistance
- Currently inaccessible via
@-mentions, making the workflow cumbersome
Proposed Solution
Introduce a .claudeignore file that works similarly to .gitignore but specifically controls Claude Code's file awareness:
- Override gitignore: Allow patterns like
!tasks/to make gitignored files visible to Claude Code - Additional exclusions: Support standard ignore patterns to exclude files from Claude Code even if they're tracked by git
- Precedence:
.claudeignorerules should take precedence over.gitignorefor Claude Code's file handling
Example .claudeignore configuration:
# Make tasks folder visible to Claude Code despite being gitignored
!tasks/
# Exclude specific files from Claude Code even if tracked by git
*.log
temp/
Alternative Solutions
- Command-line flag:
--include-gitignoredto override gitignore behavior globally - Config file option: Setting in Claude Code's configuration to control gitignore respect
- Environment variable:
CLAUDE_RESPECT_GITIGNORE=falsefor session-based control
Benefits
- Maintains security by keeping sensitive files out of version control
- Improves local development experience with Claude Code
- Provides granular control over file visibility
- Follows familiar patterns (similar to
.gitignoresyntax)
Impact
This would significantly improve the local development workflow for users who need to reference private/local files while keeping them out of version control.
35 Comments
Please let me know if you disagree, but it also ignores all dot-files, even if they are git-committed.
This is strange. I was able to instruct claude to modify.env and.env.local files which are git ignored
@vladrpmd oh my mistake I was speaking directly about the @-mention functionality, I haven't had a problem with it not being able to access git-ignored stuff if told directly, i guess i haven't noticed it otherwise
@vladrpmd It's indeed possible to modify them, but they will not be taken into account unless you explicitly ask Claude Code to do so. And you will not be able to use autocomplete for that
@npupko
Unless I misunderstand you, this is a general "feature" of Claude Code - it is not aware of anything that happens to the codebase unless it makes the change itself or you inform it of the change. If it's already read a file, it will not be aware if that file changes until it tries to touch it again.
@hesreallyhim You’re absolutely right. It doesn’t automatically track changes to the codebase unless it’s directly involved or explicitly informed.
However, the issue I’m describing is a bit different from that general file awareness behavior. What I’m specifically talking about is the initial discovery and availability of files for @-mention autocomplete and general file reading capabilities.
Here’s the distinction:
Current .gitignore behavior:
General file awareness behavior (what you’re referring to):
The .claudeignore proposal is specifically about that first issue - making certain gitignored files discoverable and available for @-mention autocomplete, while still keeping them out of version control.
+1
+1 to this. I was using Claude to author some unit tests and increase code coverage. It asked for access my coverage report which included in .
gitignore. I had to temporarily remove that directory from.gitignorein order for autocomplete to "see" them.+1 This would be ideal for me based on the number of repos I work in.
I often keep a file called
NOTES.txt, several directories deep, when I'm working on projects I haven't touched in a while. It would be a huge boost for to me to be able to directly tell Claude "please look at my notes at@src/foo/bar/NOTES.txt" when I want it to do some work on a particular feature on a particular repo.+1 I keep
*_TODO.mdin my.gitignoreso I don't commit my various planning documents but this has the side effect of not being referencable by using@which is a shame.+1
+1
++
I use repomix to package documentation into a single file to ensure its entirety is always read into context.. I put the repomix-output.md in .gitignore so I don't inadvertently commit it, but that means I have no way of forcing Claude Code to read the entirety of my documentation (since it's broken up into a bunch of files, tool-use doesn't always read everything like I want it to).
A command-line flag or some other kind of config to allow @'ing .gitignored files would be great. (In Cursor I have the same problem but I can at least manually drag it from the file explorer into the chat.)
+1
+1
+1
+1
+1
hidden files could be shown with a different style, but still allowed to be picked.
+1
+1
+1
If anyone needs a workaround, which at least protects you from inadvertently committing secrets, you can:
/.no-commit
.git/hooks/pre-commit
Execution:
Some more workarounds off the dome before I ask Claude for the optimal solution:
.gitkeepmefile or something (.gitkeepalready kinda has a purpose) which is like a .gitignore list. Put the files you want to show claude but not commit into there, and leave them out of .gitignore. When you commit, add -A, then git reset on those files and keep (+ any steps to avoid pre-commit hooks from adding them). (I think this is like @tylerseymour is suggesting but, you know, for dumb people like me. 🤣)*
.gitkeepmething again. this time, what you do is copy gitignore to gitignore_bak, and gitkeepme to .gitignore, do the commit, then swap the files back.These are all a little risky, but i'm sure there's ways to make them safer. Or not, I'm spitballing but i think something like this workflow is viable, and would be safe using git hooks or claude hooks + extra guardrails if you want. 🤷
+1
+1
+1
+1
+++
dotfiles and folders which are not gitignored are also restricted from indexing. For example, our team has a .vscode/settings.json and claude code cannot access it, even though it's in source control.
Hey all, hidden files should be available now for searching in the latest release (v1.0.64) :)
<img width="229" height="67" alt="Image" src="https://github.com/user-attachments/assets/34f84fa4-e217-427e-a186-d3717148b9eb" />
@ollie-anthropic I'm not sure the hidden files being included resolves the original issue's ask.
Given the problem description:
If files or directories are .gitignored (e.g. .claude/), @mentioning them still doesn't work, even if hidden files are shown because it's still respecting .gitignore.
@ollie-anthropic Not sure this resolved the initial concern. It still impossible to easily operate with the .gitignored files. Should I create another issue on that matter?
I will create the duplicate so we could re-request this functionality again
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.