
Claude Code logs live in your home folder under ~/.claude. Debug logs go to ~/.claude/debug/<session-id>.txt, but only when debug logging is on. Conversation transcripts go to ~/.claude/projects/<project>/<session-id>.jsonl for every session, whether debugging is on or not.
To create a debug log, start Claude Code with claude --debug (or -d), or type /debug inside a running session. The log is written to a file, not to your screen, so nothing extra appears in the terminal. Use claude --debug-file ./debug.txt when you want the log in a place you choose.
We turned on debug logging in a small demo project, broke an MCP server on purpose, ran a hook, and then read every log file Claude Code wrote. Below you’ll see where each file landed, what the lines look like, and how to share them safely in a bug report.
Browse all our Claude Code tutorials for more fixes and how-tos.
Tested with Claude Code v2.1.332 on macOS on December 4, 2026. Everything ran in a throwaway folder with its own .claude/settings.json and .mcp.json. We tested on macOS; the Windows and Linux steps follow Anthropic’s official instructions.
Quick Summary: Every Claude Code Log Location
Here is each kind of log, where it lives, and when Claude Code writes it.
| Log | Location | When it is written | How we checked |
|---|---|---|---|
| Debug log | ~/.claude/debug/<session-id>.txt | Only with --debug, /debug or DEBUG=1 | Tested |
| Newest debug log | ~/.claude/debug/latest | A link updated for each new debug session | Tested |
| Custom debug log | Any path you pass to --debug-file | Turns debug mode on by itself | Tested |
| Transcript | ~/.claude/projects/<project>/<session-id>.jsonl | Every session, all the time | Tested |
| Prompt history | ~/.claude/history.jsonl | Each prompt you type | Seen in claude purge output |
| Background sessions | ~/.claude/daemon.log | While the supervisor runs | From the official docs |
| Local bug reports | ~/.claude/feedback-bundles/ | When /bug can’t send to Anthropic | From the official docs |
What Claude Code Logs Are For
Most of the time Claude Code shows you only the friendly version of what happened. When an MCP server fails, a hook stays silent or startup feels slow, the screen rarely tells you why. The debug log is where Claude Code writes the full story, with timestamps and error text.
Transcripts are a different thing. They record the conversation itself: your prompts, Claude’s replies, tool calls and tool results. They are what claude --resume reads to bring a session back.
Debug logs explain how Claude Code behaved, while transcripts record the conversation itself.

How to Turn On Claude Code Debug Logging
There are four ways to switch debug mode on. They all write to the same kind of log file.
Option 1: Start with claude –debug
Run claude --debug from your project folder. Claude Code shows a grey banner that says debug mode is enabled and names the exact file it is writing to. A small yellow Debug badge also sits in the bottom right corner of the session.

You can narrow the log to certain categories. The official CLI reference gives --debug='mcp,startup' to include only those, and --debug='!mcp' to leave one out. The filter only works in the = form, so --debug mcp with a space turns on full debug mode without any filter.

Option 2: Write the log where you want with –debug-file
Run claude --debug-file ./logs/debug.txt to put the log inside your project. This flag turns on debug mode by itself, so you don’t need --debug as well. It is the easiest way to keep one bug’s log separate from everything else.

In our test, Claude Code also created a latest link next to the file, the same way it does in the default folder.
Option 3: Type /debug in a running session
If you forgot the flag, type /debug followed by a short description of the problem. The commands reference says it turns on debug logging from that point forward and asks Claude to read the log for you. Anything that happened before you typed it is not in the log.
Option 4: Set environment variables
Setting DEBUG=1 works like --debug. The docs say only 1, true, yes and on count, so a DEBUG=express:* you set for another tool won’t trigger it.
Two more variables shape the log. CLAUDE_CODE_DEBUG_LOGS_DIR changes the file path (despite its name, it is a file path, not a folder) and does not turn logging on by itself. CLAUDE_CODE_DEBUG_LOG_LEVEL sets the minimum level: verbose, debug (the default), info, warn or error.

Why –debug Shows Nothing in the Terminal
This confuses a lot of people. The hooks docs say plainly that the --debug flag doesn’t print to the terminal. Your session looks almost the same as normal.
We proved it with a demo hook that runs echo hook-ran after every file write. We asked Claude to create notes.txt, and the screen showed the write and Claude’s reply, but no sign of the hook.

If you want more detail on screen instead, --verbose is the flag for that. The CLI reference says it shows full turn-by-turn output for the session. It is a display setting, not a log file.
How to Read a Claude Code Debug Log
The log is plain text, one event per line. Each line starts with a UTC timestamp and a level such as [DEBUG], [WARN] or [ERROR]. Our short session with two prompts produced 645 lines, so you will want to search rather than scroll.
Search for the thing that broke
Our demo project had an MCP server called notes-demo that points to a file that doesn’t exist. Searching the log for its name and the word ERROR showed the real cause right away: Node couldn’t find the module, so the connection closed after 166 ms.

The same file showed the hook too. The line Hooks: PostToolUse:Write [echo hook-ran] finished with status 0 (70ms) tells you the event, the matcher, the command, the exit code and how long it took. If you are chasing a broken hook, our guide to hook errors explains what each exit code means.
Useful search patterns
grep ERROR ~/.claude/debug/latestlists every error in the newest log.grep 'MCP server' ~/.claude/debug/latestshows connection attempts and server stderr.grep 'Hooks:' ~/.claude/debug/latestlists each hook run with its duration.grep -i settings ~/.claude/debug/latesthelps when a setting isn’t taking effect.
Expect some noise. A real setup with many skills and plugins will log warnings about files that have nothing to do with your problem, so always search for the name of the server, hook or setting you care about.
Find the newest log fast
You don’t need to copy a long session ID. In our test, ~/.claude/debug/latest was a link pointing to the newest debug log.

Let Claude Read the Log With /debug
Reading logs yourself is useful, but /debug can do the first pass. We started a session with claude --debug=mcp and typed: “/debug why did the notes-demo MCP server fail to connect? Answer in 3 short lines.”
Claude asked permission to run one grep on its own log, then answered. It found the missing missing-server.js, the MODULE_NOT_FOUND error and the CONNECTION_CLOSED result, and told us to fix the path in .mcp.json and reconnect with /mcp.

One demo is one demo, and the answer is only as good as what the log captured. For deeper MCP problems, our walkthrough on reading MCP logs covers more server errors, and you can reload MCP servers once you’ve fixed the config.

Where Claude Code Transcripts Are Stored
Transcripts are always on. The sessions docs say each one is a JSONL file at ~/.claude/projects/<project>/<session-id>.jsonl. The project folder name is your working directory path with every non-letter, non-number character turned into a dash.

Each line in a transcript is one JSON record. You can count record types with jq -r .type, or search for a phrase with grep. If you want a readable copy instead, /export saves the current conversation as plain text.
How long logs are kept
Claude Code deletes old transcripts and debug logs on its own. The cutoff is the cleanupPeriodDays setting, which defaults to 30 days and can’t be lower than 1. Set it in settings.json if you need logs for longer or shorter.
Clean up with claude purge
To remove one project’s logs right away, use claude purge. Add --dry-run first to see the plan without deleting anything.

On our demo it found two debug logs, the transcripts folder, the project’s entry in ~/.claude.json and three prompts in history.jsonl. It also noted that purging only deletes data on your computer. If you want to change what Claude Code sends to Anthropic, our guide to turning off telemetry covers that.
Other Claude Code Logs Worth Knowing
claude logs <id>prints recent output from a background session.claude daemon logsfollows~/.claude/daemon.log, the background-session supervisor’s log, until you press Ctrl+C./doctorruns a setup checkup. Our doctor guide shows what it checks.claude --safe-modestarts with your customizations turned off, which helps you tell whether a plugin, hook or MCP server is the trigger.
These come from the official CLI reference. We did not run background sessions in this test.
How to Send Logs in a Bug Report
The simplest route is /bug. The docs say you choose how much session history to include and confirm on a consent screen before anything is sent. On a third-party provider, or without Anthropic sign-in, it saves a local archive in ~/.claude/feedback-bundles/ for you to forward.
If you post logs on GitHub or a forum instead, clean them first:
- Reproduce the problem in a fresh session started with
--debug-file ./bug.txt, so the log covers only that bug. - Copy only the relevant lines with
grep, not the whole file. - Replace your username and home folder path, for example
sed "s#$HOME#~#g". - Remove tokens, keys, email addresses and private file names.
- Add your version from
claude --versionand your operating system.
This matters for transcripts most of all. The docs warn that transcripts are not encrypted, and anything that passes through a tool, such as a .env file a command printed, can end up in them.
Try It Yourself
Make an empty folder, add a tiny file, and start Claude Code with claude --debug-file ./debug.txt. Then paste this prompt:
Create a file named hello.txt with one line: testing logs.
Then tell me the path of this session's debug log.Exit, then run wc -l debug.txt to count lines and grep Write debug.txt to find the file write. Finish with claude purge . --dry-run to see everything the session left behind.
Common Mistakes
- Waiting for debug text on screen. The
--debugflag writes to a file only. - Typing
--debug mcpwith a space. Use--debug=mcpor the filter is ignored. - Setting
CLAUDE_CODE_DEBUG_LOGS_DIRto a folder or without turning debug on. - Running
/debugafter the problem happened and expecting the log to show it. Reproduce it after turning logging on. - Pasting a full log or transcript in public without removing paths, names and secrets.
Pro Tips
- Use one
--debug-fileper bug so each log tells one story. - Set
CLAUDE_CODE_DEBUG_LOG_LEVEL=errorto cut noise, orverbosefor hook matcher detail. - Search by the exact name of your server, hook or setting before reading anything else.
- Check
/mcpand/hooksfirst. The log explains failures, but those screens confirm what loaded. - For a list of other messages, keep our page of common Claude Code errors handy.
Claude Code Logs Cheat Sheet

Frequently Asked Questions
Where are Claude Code logs on Mac?
Debug logs are in ~/.claude/debug/ and transcripts are in ~/.claude/projects/. That is the hidden .claude folder inside your home folder. On macOS you can open it with open ~/.claude.
Does Claude Code keep a log without –debug?
It always keeps transcripts of your conversations. Debug logs are only written while debug logging is on, through --debug, --debug-file, /debug or DEBUG=1.
What is the difference between –debug and –verbose?
--debug writes internal events to a log file. --verbose changes what you see on screen by showing full turn-by-turn output. Use --debug to diagnose problems.
Is it safe to delete Claude Code logs?
Yes, debug logs are only for troubleshooting. Deleting transcripts means you can no longer resume those sessions. claude purge with --dry-run shows exactly what would go before you remove anything.
Can I reset Claude Code if logs show a broken config?
Try claude --safe-mode first to confirm a customization is the cause. If you need a clean start, our guide to resetting Claude Code walks through it, and our Claude AI page covers the assistant itself.
Conclusion
Claude Code logs come in two main kinds: debug logs in ~/.claude/debug/, written only when you turn on --debug, --debug-file or /debug, and transcripts in ~/.claude/projects/, written for every session. Since debug output never appears on screen, open ~/.claude/debug/latest or your own --debug-file and search for the name of whatever broke, or let /debug read it for you. Clean old files with claude purge, strip paths and secrets before you share anything, and check the official debug your configuration guide when a setting still won’t load.


