Skip to content

[FEATURE REQUEST] Allow Claude Code to access gitignored files #5105

Description

@npupko

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

  1. Command-line flag: --include-gitignored to override gitignore behavior globally
  2. Config file option: Setting in Claude Code's configuration to control gitignore respect
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions