Last updated 13 October 2026
How to clear Claude Code session history
The weight of old context in your terminal
When you work with Claude Code for several hours, the terminal window fills with thousands of lines of code, shell output, and reasoning steps. This accumulation creates a heavy context that can eventually slow down the agent or lead to confusion. You might find that the agent starts referencing a bug you fixed two hours ago instead of focusing on the new feature you are building right now. This happens because every interaction stays in the active memory of the current session until you take action to remove it.
Starting fresh is a requirement for maintaining accuracy. When the conversation history becomes too long, the agent has to process a massive amount of data before it can generate a response. This increases the token usage and the financial cost of each prompt. If you notice the tool starts making repetitive mistakes or ignores your specific constraints, the problem is likely a cluttered session history that needs a complete wipe or a summary to restore focus.
Using the internal clear command for an immediate reset
The most direct way to wipe the slate clean inside an active session is to use the /clear command. When you type /clear and press enter, the agent discards the current conversation history while keeping you in the same working directory. This is different from quitting the terminal and starting over because it explicitly tells the agent to forget the previous exchanges. It is like handing the agent a blank piece of paper while they are still standing in your project folder.
Using /clear is a standard part of a clean development workflow. You should use it every time you finish a specific sub-task and move on to something unrelated. For example, if you just finished refactoring a database module and now you want to work on a CSS layout, the agent does not need to remember the SQL queries you just wrote. Removing that irrelevant information prevents the agent from hallucinating connections between the database logic and the front-end styles.
Reducing history size with the compact command
Sometimes you do not want to delete everything but you still need to free up space in the context window. The /compact command serves this specific purpose. When you run /compact, the agent reviews the entire conversation so far and writes a concise summary of the progress and decisions made. It then replaces the long, detailed history with this short summary. This effectively shrinks the amount of data the agent has to hold while preserving the essential facts of the project.
Compaction is an automated process that can also happen on its own. Claude Code has a hook event called PreCompact that triggers when the context window reaches a certain limit. If you prefer to have control over this, calling /compact manually allows you to review what information is being saved before the history is compressed. This keeps the agent efficient and helps you stay within the limits of the model without losing the thread of a complex multi-step operation.
Starting sessions without loading previous history
When you launch the agent from your terminal, how you start the command determines what history is loaded. If you simply type claude in a directory where you have worked before, the agent may attempt to pick up where you left off or ask how to proceed. To avoid loading a massive amount of previous context, you should be intentional about which flags you use. The system is designed to help you resume work, but that same feature can become a hindrance if you are trying to start a completely unrelated task.
If you want to see a list of your previous interactions to choose a specific one or ensure you are not accidentally resuming a bloated session, you can use the claude --resume command. This provides a menu of earlier sessions. If you are certain you want the very last thing you were doing, claude --continue is the shortcut. However, for a fresh start, you often want to avoid these flags and use /clear as soon as the interface loads to ensure no lingering context from a previous day is affecting your current work.
Managing project level instructions in markdown files
Clearing the session history does not remove the persistent instructions found in CLAUDE.md files. These files act as a permanent memory for the project. A CLAUDE.md file in your project root tells the agent about your coding standards, build commands, and preferred libraries. If you find that the agent is still following old patterns even after a /clear command, you need to check these markdown files. There might be a CLAUDE.md in a subdirectory that is overriding your current goals or a global one located at ~/.claude/CLAUDE.md that applies to every project on your machine.
To truly reset how the agent behaves, you must manage these files alongside the session history. If you are changing the direction of a project or moving from a testing phase to a production phase, update the CLAUDE.md file to reflect the new requirements. The agent reads these files at the start of every session and uses them to guide its tool usage, such as how it uses the Edit or Write tools. Keeping these instructions lean and updated is just as important as clearing the interactive history.
Removing session files from the disk manually
Claude Code stores its configuration and session data in specific folders on your hard drive. If you want to perform a deeper wipe than what /clear provides, you can look into the .claude directory within your project. This folder contains settings.json and potentially other files that track how the agent interacts with that specific codebase. For global settings and history that persist across different projects, you can find the relevant data in the ~/.claude directory in your user home folder.
Deleting or editing these files manually is a way to reset the agent to its factory state for your machine. For instance, if you want to wipe all custom slash commands you created, you would look into the .claude/commands folder. If you want to reset your login state or global preferences, you might use the /logout command or modify ~/.claude/settings.json. This level of cleaning ensures that no old permissions or configurations are interfering with your current development environment.
Isolating task history with adhdTerminal
When you work on several features at once, clearing history becomes a constant chore because you are frequently switching contexts. This is where adhdTerminal provides a structural solution for macOS and Windows users. Instead of running one session and clearing it every time you switch tasks, adhdTerminal lets you run many Claude Code sessions side by side. Each session is a tile on a wall with its own name and color. You can have one tile for a database fix and another for a UI update, and each one maintains its own isolated history.
This approach removes the need to constantly use /clear when jumping between different parts of a project. Because tiles in adhdTerminal reopen in the same place after a restart and resume their specific sessions, you can keep the context for one feature alive while starting a completely fresh session in a new tile for another feature. This isolation prevents the history of one task from bleeding into another, which is the primary reason developers seek to clear their history in the first place.
Checking environment health after a context wipe
If you have cleared your history and updated your instruction files but the agent still seems to be behaving oddly, you should use the diagnostic tools available. Running claude doctor from your shell or using the /doctor command inside a session will check your installation and environment. This can identify if there are issues with how the agent is reading your files or if there are conflicts in your configuration. It is a good practice to run this after a major cleanup to ensure everything is functioning as expected.
Additionally, you can monitor the cost and resource usage of your sessions with /cost and /usage. If you notice that even after a /clear, your costs are higher than expected, it might be because the agent is reading large files into its context window using the Read or Glob tools. Clearing the history wipes the conversation, but it does not prevent the agent from immediately re-filling that context if it decides to scan your entire repository again. Always monitor what the agent is doing in the terminal to ensure it is not recreating the baggage you just tried to remove.
Questions people ask
How do I delete a specific old session from the resume list?
You can use the claude --resume command to list your previous sessions. To delete them permanently, you must navigate to the ~/.claude directory on your computer and manually remove the session files, as there is currently no slash command to delete individual entries from that history list.
Does the /clear command delete the code changes I made?
No, the /clear command only removes the conversation history from the agent's current memory. Any changes you made to your source code using the Write or Edit tools are saved to your disk and will remain there. The agent will simply forget the discussion that led to those changes.
Can I undo a /clear command if I realize I needed that history?
You cannot undo /clear within the same session. However, you can try to quit the current session with Ctrl+C and then run claude --resume to see if the system saved an earlier version of that conversation as a separate session that you can reload.
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.