Context & Reasoning/Context Engineering
Intermediate6 min

.claudeignore — Cutting Context Overhead at the Source

.claudeignore stops files from auto-loading into context during Claude's tool searches. One well-tuned file can cut your working context by 30–40% on the first search.

Quick Reference

  • Syntax is identical to .gitignore — glob patterns, one per line
  • Place in project root; applies to all Claude Code sessions in that directory
  • Ignored files are excluded from Glob/Grep auto-results — not blocked from explicit reads
  • Real impact: 236 → 90 files reported after aggressive .claudeignore
  • node_modules/ is often auto-excluded but still worth being explicit
  • Do NOT ignore source files Claude needs for TDD or architecture understanding
  • .claudeignore and .gitignore serve different purposes — maintain separately
  • Use /context to see what is currently loaded and identify what should be ignored

What .claudeignore Actually Does

When Claude Code runs a Glob or Grep search, it returns matches from all files in your project. Without .claudeignore, that includes node_modules, build output, lock files, generated code, and everything else that has never needed to be in context. .claudeignore removes these from search results before they get appended to the window.

Ignored ≠ Blocked

.claudeignore prevents auto-loading during tool searches. It does not prevent Claude from reading a file if you or Claude explicitly requests it. If you ask 'read package-lock.json', Claude can still read it. The ignore rule only applies to ambient auto-loading via search results.

This distinction matters for workflows that intentionally need specific generated files. .claudeignore reduces noise from automated searches without removing your ability to access any file directly.