Feature request: .claude-ignore — exclude files/directories from Claude's file access

Resolved 💬 3 comments Opened Mar 4, 2026 by menkhus Closed Mar 8, 2026

Feature request: .claude-ignore support

Summary

Claude Code has no mechanism to exclude specific files or directories from its file reading tools (Read, Glob, Grep). A .claude-ignore file (analogous to .gitignore) would let projects define hard boundaries on what Claude can access.

Use case

Tools like ghost manage a ghost-cache/ directory that holds noise-filtered documents intentionally moved out of the active working context to reduce AI context load. Without .claude-ignore support, Claude Code freely reads these files — defeating the purpose of the cache.

More broadly: projects may have directories containing sensitive material, archived content, or generated artifacts that should be invisible to the AI assistant without an explicit retrieval request.

Current workaround

Advisory guidance in CLAUDE.md:

Do not read files from `ghost-cache/` unless explicitly asked.

This relies on Claude following instructions, not on enforcement. It is not a hard barrier.

Proposed behavior

If a .claude-ignore file exists in the project root (or any parent), Claude Code respects it the same way git respects .gitignore:

  • Glob results exclude matching paths
  • Grep does not search matching paths
  • Read tool declines with a clear message: "this file is excluded by .claude-ignore"
  • The user can override with an explicit "read X even though it's in .claude-ignore" instruction

Example .claude-ignore

# Ghost cache — managed by ghost, not active working documents
ghost-cache/

# Secrets — never read these
.env
*.key
secrets/

Notes

  • .gitignore syntax would be familiar and reusable
  • Should be overridable by explicit user instruction (not a security boundary, a context management tool)
  • Composable: .claude-ignore at project root + subdirectory-level overrides

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗