[BUG] @ symbol autocomplete shows .gitignore'd files like .git, .env, .DS_Store
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?
When using the @ symbol to tag files in Claude Code, the autocomplete list shows files that are explicitly listed in .gitignore, including:
.git/directory (git metadata).envfiles (environment variables with potentially sensitive data).DS_Store(macOS system files)- Other dotfiles/directories specified in
.gitignore
Expected Behavior
Files and directories listed in .gitignore should be filtered out from the @ autocomplete suggestions, similar to how most IDEs and tools respect .gitignore for search and file browsing features.
Actual Behavior
All files in the working directory appear in the @ autocomplete, regardless of .gitignore settings.
Security Concern
This is particularly problematic for .env files which often contain sensitive credentials and API keys. Having these appear in autocomplete increases the risk of accidentally including them in context or sharing them.
Related Issues
This appears to contradict the behavior described in #5105, which states that "Claude Code currently respects .gitignore files and excludes gitignored files from @-mention autocomplete suggestions."
What Should Happen?
Files listed in .gitignore should be automatically filtered out from the @ symbol autocomplete suggestions. This would:
- Reduce noise in the autocomplete list
- 2. Prevent accidental inclusion of sensitive files (like
.env) - 3. Match the behavior of most modern IDEs and development tools
- 4. Align with the documented behavior described in #5105
Error Messages/Logs
Steps to Reproduce
- Have a project with a
.gitignorefile that includes entries like.env,.DS_Store, etc. - 2. Ensure these files exist in your working directory (e.g., create a
.envfile if needed) - 3. Open Claude Code in the terminal
- 4. Type
@to bring up file autocomplete - 5. Observe that
.env,.DS_Store,.git/, and other gitignored files appear in the suggestions
Example .gitignore excerpt:
.env
.env.local
.DS_Store
.vscode/
.idea/
All of these files/directories still appear in the @ autocomplete despite being in .gitignore.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.1 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
This issue affects usability and creates security concerns, particularly with .env files containing sensitive credentials appearing in autocomplete suggestions.
The behavior contradicts what's described in issue #5105, which claims gitignored files should be filtered from autocomplete.
Impact: Increases noise in file selection and risk of accidentally including sensitive files in context.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗