Try free

Last updated 13 October 2026

Difference between reset and compact in Claude Code

Context management prevents session degradation

You are deep in a coding session and notice the responses from Claude Code are getting slower. The agent starts to repeat terminal commands or asks you to clarify things you explained twenty minutes ago. This happens because the context window is filling up with every file the agent views using the Read tool and every change it makes with the Edit tool. The conversation history and the files currently in memory compete for the same space. If you do not manage this context, the agent will eventually lose track of your original goals or start making errors because it is overwhelmed by old logs and previous iterations of the code.

Effective context management is about balance. You want the agent to remember your architectural decisions but forget the ten failed attempts at fixing a minor syntax error. If the history becomes too long, every prompt you send requires the model to process a massive amount of data. This increases the time you wait for a response and the cost of the session. You have two primary tools to handle this situation: the /compact command and the /clear command. Knowing which one to use depends on whether you are finishing a phase of work or starting something entirely new.

Use the compact command to maintain project continuity

The /compact command is designed to summarize your progress without losing the current state of the project. When you run this command inside a session, Claude Code reviews the entire conversation history and creates a high-level summary. It then replaces the detailed turn-by-turn history with this summary. This process frees up a significant amount of space in the context window. It keeps the information the agent has gathered using the Read and Glob tools but removes the specific dialogue that led to those discoveries. This is the best choice when you are in the middle of a large task and need to keep the momentum going.

Compacting is like taking notes on a meeting and then throwing away the transcript. The agent still knows what the plan is and what files have been modified, but it no longer has to process every message from an hour ago. You can trigger this manually or let the agent suggest it when the context window reaches a certain limit. Using /compact ensures that the most recent and relevant information remains at the top of the agent's memory. This keeps the agent sharp and prevents the confusion that often occurs when a session grows too large for the model to handle effectively.

Use the clear command for distinct task transitions

The /clear command provides a total reset for the session memory. Unlike compacting, which tries to preserve the essence of the conversation, clearing wipes everything. When you run /clear, the agent forgets all previous messages, all files it has read, and all terminal output it has seen. The session remains open in the same directory, but the brain of the agent is fresh. This is the correct tool to use when you have successfully completed a task and want to start a new one without any baggage. It ensures that the agent does not try to apply logic from a finished bug fix to a new feature request.

Distinguishing /clear from quitting the application with Ctrl+C is helpful. Quitting and restarting with the claude --continue command will bring back the previous context. Running /clear stays within the current interactive session but resets the token count for the conversation to zero. This is a powerful way to reduce costs and improve accuracy. If you are moving from front-end styling to back-end logic, a /clear command prevents the agent from being distracted by CSS classes and layout issues that are no longer relevant to the new task.

Context limits impact tool efficiency and costs

Context management is not just about performance; it is also a matter of cost efficiency. Every token in your context window is sent to the model with every new prompt you write. If you have a massive history that has not been compacted or cleared, you are paying to re-send the same information over and over again. You can monitor this by running the /cost and /usage commands. These commands show you exactly how many tokens you have consumed and what the estimated cost of the current session is. If you see the cost per message increasing, it is a sign that your context is too heavy.

By using /compact or /clear regularly, you keep the token count low. A smaller context window means the model has less data to process, which results in faster response times. The agent can use the Bash tool and the Edit tool more effectively when it is not sifting through hundreds of lines of irrelevant history. If you find that the agent is frequently misinterpreting your instructions, check the /usage output. High context usage often leads to lower quality responses. Keeping a lean session ensures that you get the best possible output for the lowest possible price.

Configuration files and hooks influence context behavior

You can customize how Claude Code handles context by modifying your configuration files. The .claude/settings.json file in your project or the global ~/.claude/settings.json file allows you to define default behaviors. You can also use hook events to manage context transitions. For example, the PreCompact hook event occurs just before the agent summarizes the conversation. You can use this to perform specific logging or to check the status of your project before the detailed history is lost. These hooks provide a way to integrate context management into your broader development workflow.

Project specific instructions in your CLAUDE.md file also play a role in how the agent recovers from a context reset. Even after a /clear command, the agent will look for the CLAUDE.md file in the root of your repository to understand the project standards and build commands. This file provides a persistent memory that survives even a total session wipe. By keeping your build instructions and code style preferences in CLAUDE.md, you ensure that the agent always has the necessary foundation to work effectively, regardless of how often you clear the conversation history.

Parallel sessions simplify context management

Maintaining focus across different tasks often requires having multiple contexts available at once. This is where adhdTerminal becomes a useful addition to your workflow. It is a native app for macOS and Windows made by MINDBALANCER OU in Estonia and is not affiliated with Anthropic. The app allows you to run many Claude Code sessions side by side as a wall of tiles. Each tile represents a specific session with its own name, number, and color. You can see at a glance whether a session is working, waiting for you, or idle. This structure allows you to keep one session in a compacted state for deep architectural work while using other tiles for fresh sessions where you have just used the /clear command.

The app provides a 7 day free trial and requires no account to use. It costs 99 dollars once and a single key runs one computer at a time but can be moved between machines. It also features a free iPhone app that mirrors your terminal wall over an end to end encrypted link, which is helpful when you need to answer a prompt or send the next task away from your desk. Since tiles reopen in the same place after a restart and resume the same session, you do not have to worry about losing the context you have carefully managed. This approach reduces the need to constantly run /clear or /compact because you can simply move to a different tile that is already configured for the task at hand.

Manual intervention versus automatic summarization

Sometimes the automatic summary generated by /compact might miss a subtle detail that you know is important. In these cases, manual intervention is better. You can use the /memory command to see what the agent has stored in its long-term memory for the session. If the summary is missing key information, you can provide that information again in a fresh prompt. If the context is too messy for a summary to be useful, a /clear command followed by a brief re-explanation of the current state is often the most reliable way to get the agent back on track.

Manual control also involves choosing the right tools for the job. Instead of letting the agent use the Read tool on every file in a directory, you can use the Glob tool or Grep tool to find specific information. This prevents the context window from filling up with files that the agent does not actually need to see. By being deliberate about what information you allow into the session, you reduce the frequency with which you need to run /compact or /clear. This proactive approach to context management leads to a more stable and predictable development experience.

Verifying state after a context operation

Verifying the state of your session after a context operation is a vital step. If you have just run /compact, ask the agent to list its current tasks or summarize its understanding of the project. This confirms that the important details were preserved in the summary. If you have run /clear, you may need to use the Read tool on a few core files to give the agent the necessary context to continue. You can also use the /status command to check the overall health of the session and ensure that the agent is still aligned with your goals.

If you accidentally run /clear or if a compacting operation removes something you needed, you have options for recovery. The claude --resume command, or the -r flag, allows you to see a list of previous sessions and pick one to restore. This acts as a safety net for your context management. You can also use the /export command to save the current session history to a file before you clear it. This gives you a permanent record of the conversation that you can refer to later if you realize you missed a detail during the reset.

Permission modes influence context consumption

Your choice of permission mode also impacts how quickly your context window fills up. When you use the bypassPermissions mode, the agent can execute many Bash and Edit commands in quick succession without waiting for your approval. This speed is great for productivity but it can lead to a very noisy context window full of terminal output. If you notice the context filling up too fast, you can use Shift+Tab to cycle through modes and switch to the plan mode. In this mode, the agent will describe what it intends to do instead of executing the tools immediately.

Using the plan mode allows you to review the agent's logic and make adjustments before any tokens are spent on tool execution or file reads. This is a highly context-efficient way to brainstorm or map out a complex change. Once the plan is finalized, you can switch back to default or acceptEdits mode to carry out the work. By alternating between these modes, you can control the density of information in your session history. This strategic use of permission modes, combined with /compact and /clear, gives you complete mastery over the Claude Code context window.

Questions people ask

Does the /clear command delete any of my project files?

No, the /clear command only removes the conversation history and file contents from the agent's active memory. Your actual source code and project files on disk remain completely untouched. It is a safe way to start a new task in the same folder without old conversation data confusing the agent.

Can I recover my conversation after running /compact?

Once you run /compact, the detailed turn-by-turn history is replaced by a summary and cannot be undone within that specific session. However, you can use the /resume command or exit and use claude --resume to pick an earlier version of the session if you need to access the full logs. It is a good practice to use /export before compacting if you want a permanent record of the raw dialogue.

How does CLAUDE.md interact with context resets?

The CLAUDE.md file serves as a persistent guide that survives even a /clear command. Every time a session starts or resets, the agent refers back to this file for project instructions and build standards. This ensures that essential project knowledge remains available even when you wipe the conversational context.

Read next

More on claude code basics·All posts