Try free

Last updated 13 October 2026

List files currently in context

Verifying the current context of your session

You are working in a terminal and need to know exactly which files the agent has read. When Claude Code provides a solution that seems slightly off, the most likely cause is a missing piece of local context. You might wonder if it saw the utility folder or if it is still relying on a stale version of a config file it read ten minutes ago. Knowing the boundary of its current knowledge saves you from frustrating cycles of incorrect code generation. It is common to feel like the agent is guessing when it actually just lacks the correct file content in its active memory.

A session fills its context window as you work. Every time the agent uses the Read tool or performs a Glob search, those results enter the conversation history. If you are halfway through a complex refactor, the context window might contain dozens of files. Without a way to list these files, you cannot be sure if the agent has a global view or a fragmented one. This leads to issues where the agent suggests changes that break dependencies it has not yet discovered. You must verify what is currently loaded to ensure the agent has enough information for the task at hand.

Reviewing session history and tool usage

The /review command is the most direct way to see what has happened in your current session. When you run this command, the agent displays a summary of the conversation and the actions it took. This includes a list of the files it accessed using the Read tool. By looking through the review output, you can track the exact path of the agent through your file system. It shows you the sequence of events and which specific files provided the data for the current logic the agent is proposing.

This command also highlights where the agent used the Glob or Grep tools to find information. If you see that the agent searched for a specific pattern but did not actually read the resulting files, you know that those files are not in the current context. This audit trail is essential for debugging the reasoning process of the agent. It allows you to see if the agent ignored a critical file or if it misinterpreted the structure of your repository based on a limited search.

Checking the status of the current environment

The /status command provides an immediate overview of the agent's current state within your project. While it is less detailed than a full review, it gives you a quick snapshot of where you stand. It confirms the directory you are working in and the general state of the session. This is useful when you have multiple terminal windows open and need to verify which project context is active in the current instance. It helps prevent accidental edits in the wrong branch or folder.

If you find that the status shows the agent is focused on a subfolder, you might need to broaden its view. You can use the /add-dir command to bring more parts of your project into the scope of the agent. This command tells the agent to look at an additional directory and include its structure in the current session. By checking the status after adding a directory, you can confirm that the agent now acknowledges that part of the tree as part of its working environment.

Defining persistent context with project instructions

The CLAUDE.md file is the primary way to ensure certain information is always in the context. This file sits in your repo root and holds project instructions that the agent reads at the start of every session. If you have specific files that are always relevant, such as a main entry point or a complex configuration schema, you should mention them here. The agent will prioritize the information in this file, making it a reliable way to keep core files top of mind without manual prompting every time.

You can also place a CLAUDE.md file in a subdirectory to apply specific rules to that part of the tree. This creates a nested hierarchy of instructions. When the agent works inside that subdirectory, it combines the root instructions with the local ones. This is particularly helpful for monorepos where different services have different build commands or coding standards. It ensures that the agent always has the right context for the specific file it is currently editing.

Monitoring tool behavior for file access

You can observe the agent as it works to see which files it chooses to read. When you give a prompt, the agent often starts by using the Glob or Grep tools to find relevant code. Watch the terminal output for these tool calls. If the agent calls the Read tool on a file, that file is now in the context window. If the agent skips a file you know is important, you can intervene by explicitly telling it to read that file. This manual guidance keeps the context focused on what matters.

The agent also uses the Task tool to break down complex requests. Each step in the task often involves reading specific files. By following the progress of the task, you can see how the agent is building its understanding of the codebase. If the task steps do not include reading the necessary files for a feature, you can interrupt the process by pressing Escape. This allows you to provide more specific instructions before the agent spends more time on a flawed plan.

Managing context limits and summarizing history

As a session grows, the context window fills up with the conversation and the files the agent has read. This can lead to increased costs and slower response times. You can use the /cost and /usage commands to see how much of the context window you are consuming. If the session becomes too large, the agent might start to lose track of earlier details. Monitoring this usage helps you decide when it is time to clean up the session context.

The /compact command is the tool for managing a bloated context. It summarizes the session so far and frees up space in the context window. This keeps the most important information while removing the line-by-line history of every file read. Using this command allows you to maintain a long-running session without hitting the limits of the context window. It ensures that the agent stays efficient and that your costs remain under control while still retaining the essential logic of the work performed.

Organizing multiple project contexts with adhdTerminal

When you are juggling multiple tasks across different services, managing context in a single terminal window becomes difficult. This is where adhdTerminal provides a native app experience for macOS and Windows. It allows you to run many Claude Code sessions side by side, with each session appearing as a tile on a wall. Each tile has its own name, color, and number, making it easy to identify which context belongs to which task. You can see at a glance if a specific tile is working, waiting for your input, or sitting idle.

The app is made by MINDBALANCER OU in Estonia and is not affiliated with Anthropic. It costs 99 dollars once, and one key runs on one computer at a time. A major benefit for context management is that tiles reopen in the same place after a restart and resume the same session automatically. This means you do not have to manually rebuild the context for five different sub-projects every morning. You can even use a free iPhone app to mirror the wall over an encrypted link, allowing you to check the status of your context or send a quick prompt while away from your desk.

Starting fresh and clearing the session memory

Sometimes the context becomes so cluttered with old versions of files or failed attempts that it is better to start over. The /clear command resets the current session while staying in the same folder. This wipes the context window clean, removing all previously read files and conversation history from the agent's memory. It is a useful reset button when the agent is stuck in a loop or is hallucinating based on outdated information in the session history.

After running a clear command, the agent will only have access to the instructions in your CLAUDE.md files. You will need to provide a new prompt to guide it back to the files you want it to work on. This is often faster than trying to correct a confused agent in a heavily bloated session. Starting fresh ensures that the agent's next tool use, whether it is a Read or a Glob call, is based only on your current needs and the latest version of your code.

Questions people ask

How can I see the exact line-by-line content the agent currently has in memory?

There is no single command to dump the entire raw context buffer to your terminal. However, you can use the /review command to see the history of Read tool calls, which tells you which files were added. If you need to verify a specific file's state in memory, you can ask the agent to describe the contents of that file as it understands them.

Does the agent remember files from previous sessions in the same folder?

No, every new session starts with a fresh context unless you use the --continue or --resume flags. If you start a new session with the basic claude command, the agent only knows what is in your CLAUDE.md files until it uses tools to read more of your project. Context does not persist across independent sessions unless you explicitly resume an old one.

Can I prevent the agent from reading certain files and adding them to the context?

Yes, Claude Code respects your .gitignore file and will not look at files that are ignored by your version control system. You can also control specific tool permissions in the .claude/settings.json file under the permissions key. If you want to deny the agent access to certain tools like Read or Glob for specific paths, you can configure those rules there.

Read next

More on claude code basics·All posts