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:
.claudeignore rules should take precedence over .gitignore for 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-gitignored to override gitignore behavior globally
- Config file option: Setting in Claude Code's configuration to control gitignore respect
- Environment variable:
CLAUDE_RESPECT_GITIGNORE=false for 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
.gitignore syntax)
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.
This issue has been re-created, because the initial one has been closed without the solution: #2305
Current Behavior
Claude Code currently respects
.gitignorefiles and excludes gitignored files from:@-mention autocomplete suggestionsProblem Description
This behavior creates friction for local development workflows where users want to:
Use Case Example
I maintain a local
tasks/folder with markdown files containing project notes and TODOs. These files are:@-mentions, making the workflow cumbersomeProposed Solution
Introduce a
.claudeignorefile that works similarly to.gitignorebut specifically controls Claude Code's file awareness:!tasks/to make gitignored files visible to Claude Code.claudeignorerules should take precedence over.gitignorefor Claude Code's file handlingExample
.claudeignoreconfiguration:Alternative Solutions
--include-gitignoredto override gitignore behavior globallyCLAUDE_RESPECT_GITIGNORE=falsefor session-based controlBenefits
.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.
This issue has been re-created, because the initial one has been closed without the solution: #2305