Managing Project Context
Introduction
Welcome back to Customizing Claude Code for Your Projects! You've completed the first unit on project instructions, in which we learned how CLAUDE.md establishes persistent conventions and standards. Now, in this second unit, we'll tackle a different, but equally important, challenge: context management. As projects grow, they accumulate temporary files, old test data, cached dependencies, and other artifacts that clutter the workspace. Without proper management, Claude wastes time and tokens processing irrelevant files when analyzing code or suggesting changes. We'll explore how to use .claudeignore files to control what Claude sees, ensuring it focuses only on the files that matter for your current work.
The Clutter Problem
Before diving into solutions, let's understand why context management matters. When we work on a project over time, the file system naturally accumulates artifacts: dependency folders like node_modules or venv, build outputs in dist or target, old test data files we kept for reference, scratch notes from debugging sessions, log files from past runs, and temporary backup files.
Each of these files consumes space in Claude's context window, which has a finite limit of around 200K tokens. More critically, irrelevant files create ambiguity. If we have both sales_data.csv and test_data_old.csv, Claude might ask which dataset to use or — worse — analyze the wrong one. Temporary files like scratch_notes.txt add noise that obscures the actual project structure.
The solution is to explicitly tell Claude which files to ignore, similar to how .gitignore tells git which files not to track.
Checking What Claude Can See
Let's begin by examining the files to which Claude currently has access in our project. We can simply ask Claude to list the files:
Notice how Claude uses the Search tool to find files in the project. The output reveals our clutter problem: alongside the active files (sales_data.csv and analyze.py), we have scratch_notes.txt from past debugging, an old test dataset (test_data_old.csv), and an old_data/ folder with legacy data. These extra files do not contribute to our current analysis, yet they're discoverable and can consume context when Claude loads them.
