Last updated 13 October 2026
Check which files are in the current Claude context
The agent relies on current file data to make decisions
Claude Code works by reading your local files and processing them within a session context. When you ask the agent to fix a bug or explain a function, it does not automatically know everything in your repository. It uses tools like Read and Glob to pull specific information into its context window. If the agent makes a suggestion that seems outdated, it is likely because the context contains an old version of a file or is missing a new file entirely. Understanding what is currently in that memory is the first step to debugging a failing session.
You might notice the agent hallucinating details about a module that you recently changed. This happens because the agent is still looking at the output from a Read tool call that happened earlier in the session. The context window is a rolling log of everything the agent has seen and done. If you do not verify what the agent has read, you might waste time trying to explain a problem that the agent cannot see. Checking the context ensures that the AI is working with the same reality that you see in your code editor.
Use the tool execution output to track file access
The most direct way to see what the agent has accessed is to watch the tool output in your terminal. Every time Claude Code needs to see a file, it will invoke the Read tool. You will see a message in the terminal indicating that the tool is running along with the file path. If you are unsure if a file is in context, scroll up through your current session and look for the specific paths. If you see the content of a file printed in the terminal as part of a tool response, that content is now part of the agent context.
The agent also uses the Glob tool to list files in a directory. This tells the agent that a file exists, but it does not mean the agent has read the contents of that file. If you see a Glob call that includes your target file, the agent knows the file is there but it still needs to follow up with a Read call to see the code inside. Distinguishing between knowing a file exists and knowing what is inside a file is crucial for effective prompting. If the agent seems confused about the contents of a file it just listed, you should explicitly tell it to read that file.
Navigate the session history with physical keys
You can use the keyboard to look back at what the agent has processed. Pressing the Escape key twice in an active session opens a history viewer. This interface allows you to scroll through previous turns in the conversation. You can see the exact text of the files the agent read and the output of any Bash commands it executed. This is the most granular way to verify the state of the context. If the file content shown in this history is old, the agent is working with stale data.
The history viewer also shows you the results of Grep searches. If the agent searched for a string and found several matches, those snippets are now in its context. This can sometimes lead to a fragmented understanding if the agent only sees small parts of many files. By reviewing these entries, you can determine if the agent has enough surrounding context to understand the logic. If the history shows only a few lines of a large class, you may need to ask the agent to read the whole file to give it the full picture.
Use slash commands to inspect the session state
The /status command provides a high level overview of your current session. While it does not list every single line of code currently in memory, it helps you understand the general state of the agent. It can tell you which model is active and what the current session goals are. This is useful when you have been working for a long time and need a quick reminder of the session scope. If the status indicates the agent is focused on a different part of the tree, you may need to redirect it.
You can also use the /memory command to see what the agent is tracking. Claude Code maintains internal notes about your project to help it stay on track. These notes often include summaries of the files it has read and the progress it has made on the current task. If a file is in the agent memory, it will often show up here as a key piece of information. Checking /memory is faster than scrolling through a long history if you just need to know if the agent has grasped the core concepts of a specific module.
Project files influence the initial context
Files in your repository define what Claude Code considers important from the start. The CLAUDE.md file in your root directory is always part of the context or is frequently referenced by the agent. If you want to ensure the agent always has context for specific files or architectural patterns, you should list them in CLAUDE.md. There can also be CLAUDE.md files in subdirectories that provide localized context for those specific parts of your project. This ensures that as soon as the agent enters a directory, it has the right background information.
The agent also respects your .gitignore file. If a file is ignored by git, Claude Code will generally not see it unless you specifically tell it to ignore those rules. If you are wondering why the agent cannot find a configuration file or a build artifact, check your .gitignore. The agent uses the Glob tool to find files, and that tool follows the rules defined in your project. This prevents the agent from accidentally reading sensitive environment variables or massive dependency folders that would bloat the context window.
Manage context limits with summarization tools
The context window has a limit, and as it fills up, the agent may become less responsive. You can use the /cost and /usage commands to see how many tokens you have used in the current session. A high token count usually means the context window is very full. If you feel the agent is getting bogged down by too many files, use the /compact command. This command asks the agent to summarize the conversation so far and clear out the detailed logs. This keeps the important information but removes the bulky raw data of every Read and Write operation.
If you want to start with a fresh slate without losing your terminal history, use the /clear command. This resets the context window entirely within the same folder. This is useful when you are moving from one task to another and do not want the previous task files to interfere with the new one. After running /clear, the agent will have no memory of the files it previously read. You will need to use Read or Glob again to bring necessary files back into the context.
Visual organization reduces the mental load of context tracking
Keeping track of context across different tasks is difficult in a single terminal. If you keep everything in one terminal session, the context window fills with unrelated files and old logic. You can use claude --resume to switch between sessions, but you cannot see them at the same time. This is where adhdTerminal provides a reliable way to manage your work. It is a native app for macOS and Windows, made by MINDBALANCER OU in Estonia, and it is not affiliated with Anthropic. It runs many Claude Code sessions side by side, where each one is a tile on a wall.
Because each tile shows the last exchanges of its conversation, you can see which files are in context for each task without clicking around. A tile also shows whether the agent is working, waiting for you, done, or idle. This visual layout allows you to maintain several distinct context windows for different parts of your project. If you need to check a session while away from your desk, a free iPhone app mirrors the wall over an end to end encrypted link. This setup costs 99 dollars once and ensures you never lose track of what the AI knows in any of your active sessions.
Questions people ask
How can I force Claude Code to forget a specific file?
You cannot delete a single file from the context once it has been read, but you can use the /compact command to summarize the session. This usually replaces the full text of the file with a shorter description in the agent memory. If you need it to completely forget a file, use /clear and then only read the files you currently need.
Does the agent see my local environment variables?
Claude Code only sees what it explicitly reads using tools like Read or what it discovers via Bash commands. If your environment variables are in a file that is listed in .gitignore, the agent will generally not read it unless instructed to do so. You should check your .claude/settings.json and .gitignore to ensure sensitive files are protected.
Can I see the exact number of tokens currently in my context?
You can use the /usage command to see the total number of tokens consumed in your current session. While this includes all previous turns, it gives you a very good estimate of how much space is left in the context window. If the usage numbers are very high, it is a sign that you should use /compact to free up space.
Read next
- Add build instructions to your CLAUDE.md fileImprove project context by adding specific build commands and environment requirements to your CLAUDE.md file for the AI to follow.
- Add common error fixes to CLAUDE.mdImprove project memory by adding a section for common errors and their fixes to your CLAUDE.md configuration file.
- Add custom shell aliases for Claude CodeSpeed up your workflow by creating shell aliases for common Claude Code invocations and project-specific startup commands.
- Add test commands to a CLAUDE.md fileUnderstand how to define specific test runners and environment flags in your CLAUDE.md file so the tool runs the correct test suite.