Last updated 13 October 2026
Find the Claude Code log file location
Identifying the need for internal execution data
When you use a command line coding agent, you often run into moments where the output on your terminal does not tell the whole story. You might be waiting for a response that never comes, or a tool like Bash might return an error that seems impossible given your current directory. In these moments, you need to look at the internal records of the CLI to see what happened between your prompt and the final failure. Accessing this information is the first step toward fixing a broken configuration or understanding why an agent is stuck in a loop.
Developers who work with complex codebases frequently need to audit the actions taken by their tools. You might want to see the exact sequence of file reads and writes that led to a specific state in your repository. Since the agent can perform many operations in a single turn, the standard terminal scrollback often hides the specific details you need. Finding the internal data helps you verify that the agent is following the instructions you provided in your project files.
Navigating the global configuration directory
Claude Code stores its persistent data and configuration in a hidden directory within your user profile. On both macOS and Windows, you can find the primary data store at ~/.claude/ where settings and session information reside. This folder is the starting point for any manual investigation into how the CLI is behaving on your machine. The directory contains several files that define how the agent interacts with your system and your account.
Inside this hidden folder, you will find ~/.claude/settings.json which holds your global preferences. While this is not a traditional log file, it is the first place to check if the agent is behaving unexpectedly due to incorrect permission defaults or model settings. If you suspect a configuration issue is causing errors, checking the timestamps on the files in this directory can show you when the CLI last updated its internal state. This helps you narrow down whether a problem is related to a specific session or a global system error.
Running internal diagnostics and status checks
When you cannot find a specific record of an error, you should use the built-in diagnostic command to check the health of your installation. Running claude doctor from your shell or using the /doctor slash command inside an active session provides a status report on your environment. This command verifies your connection to the necessary services and identifies common configuration errors that might prevent the agent from working correctly. It effectively acts as an automated log reviewer that surfaces the most common issues without requiring you to read raw text files.
The output of the doctor command will tell you if your authentication is valid and if the required tools are available in your path. It also checks for updates and ensures that the internal components of the CLI are functioning. If the agent fails to start or cannot reach the internet, the information provided here is more useful than a standard log because it specifically tests each dependency. You should run this command whenever you move to a new network or update your operating system.
Reviewing past sessions and command history
If you need to see the history of a specific conversation, the /review command allows you to look back at previous turns in the current session. For older sessions that you have already closed, you can use claude --resume to see a list of previous interactions and pick the one you need to investigate. This provides a structured view of the agent's logic and the results of the tools it used. It is often faster than digging through raw files when you just need to see what the agent proposed earlier in the day.
The history of your shell commands is also a valuable resource when troubleshooting. You can use Ctrl+R to search your terminal history for specific instances of the claude command or other shell tools the agent might have invoked. This allows you to see the exact flags and arguments used during execution. If the agent performed a sequence of Bash or Write operations, your terminal history might hold the record of those calls even if the agent's internal session data is not immediately accessible.
Exporting session data for external analysis
If you need a permanent record of what happened during a session to share with a teammate or to analyze later, the /export command is the best tool for the job. This command saves the entire conversation and the details of the tool calls into a file that you can read with any text editor. It captures the context of the agent and the results of every action it took during its run. This is especially useful when you need to document a bug that only occurs after a long series of interactions.
The exported file provides a clear view of how the agent used tools like Read or Glob to explore your files. You can see the full text of the responses from the Anthropic API and the exact content that the agent tried to write to your disk. By reviewing these exports, you can spot patterns in the behavior of the agent that might indicate a need for better project instructions. It is a reliable way to create a snapshot of your work before you use the /clear command to start a new task in the same folder.
Monitoring multiple sessions with adhdTerminal
Managing many simultaneous projects can lead to a cluttered terminal environment where logs and history become difficult to track. This is where adhdTerminal becomes a useful addition to your workflow by running many Claude Code sessions side by side as tiles on a wall. Each tile shows whether the agent is working or waiting for you, which helps you monitor background tasks without constantly switching directories or searching through shell history. The tiles show the last exchanges of the conversation, acting as a live log of the most recent activity.
Because adhdTerminal is a native app for macOS and Windows, it keeps your sessions organized even after a computer restart. Tiles reopen in the same place and resume the same session, ensuring that your execution history remains visible and accessible. This setup is particularly helpful for developers who need to keep an eye on long running tasks across different repositories. You can see the status of every session at a glance, which reduces the need to manually check logs to see if an agent has finished its work or encountered an error.
Using hook events to capture activity
For developers who need to create custom logging or notification systems, Claude Code supports hook events. You can use hooks like SessionStart, PreToolUse, and PostToolUse to trigger specific actions when the agent performs a task. By configuring these hooks, you can create your own log of every time the agent attempts to use the Bash tool or when a session ends. This provides a way to monitor the behavior of the agent in real-time and integrate it with other logging tools you already use.
Hook events like Notification and Stop are also useful for tracking the lifecycle of an agent's task. If you are running complex operations, you can set up hooks to alert you when a subagent stops or when a session reaches a specific state. This allows you to maintain a high level of oversight without having to watch the terminal constantly. By using the ~/.claude/settings.json file to manage these hooks, you can create a consistent logging experience across all your projects.
Investigating MCP and project level settings
Issues with external tools often stem from the Model Context Protocol configuration. You can manage these settings in the .mcp.json file located in your project or by using the claude mcp command. Troubleshooting these connections usually requires checking the configuration of the specific server to ensure the agent can communicate with the external tool. If a tool fails to load, the MCP configuration is the most likely place to find the cause of the disconnect.
Your project-specific CLAUDE.md file also plays a role in how the agent behaves and what it records. This file holds instructions that guide the agent's choices and tool usage. If you find that the agent is consistently making the same error, you may need to update the instructions in this file to provide better guidance. Between the project-level .claude/settings.json and the global user settings, you have full control over the environment in which the agent operates and how it reports its progress.
Questions people ask
How can I see the exact cost of my recent commands?
You can use the /cost and /usage slash commands inside any active session. These commands provide a detailed breakdown of the tokens consumed and the total spend for the current session or your account. This is the best way to monitor your budget while running large tasks.
What should I do if a session becomes too long and slow?
Use the /compact command to summarize the conversation and free up space in the context window. This removes unnecessary detail from the history while keeping the essential information the agent needs to continue working. It helps maintain performance during long development sessions.
Where are my custom commands and subagents stored?
Custom slash commands are stored as markdown files in the .claude/commands directory of your project. Subagents are kept in the .claude/agents folder. You can edit these files directly to change how the agent performs specific specialized tasks.
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.