Where Claude Code Logs Are and How to Use –debug

Where Claude Code Logs Are and How to Use –debug

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.

LogLocationWhen it is writtenHow we checked
Debug log~/.claude/debug/<session-id>.txtOnly with --debug, /debug or DEBUG=1Tested
Newest debug log~/.claude/debug/latestA link updated for each new debug sessionTested
Custom debug logAny path you pass to --debug-fileTurns debug mode on by itselfTested
Transcript~/.claude/projects/<project>/<session-id>.jsonlEvery session, all the timeTested
Prompt history~/.claude/history.jsonlEach prompt you typeSeen in claude purge output
Background sessions~/.claude/daemon.logWhile the supervisor runsFrom the official docs
Local bug reports~/.claude/feedback-bundles/When /bug can’t send to AnthropicFrom 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.

Folder tree of the Claude Code logs inside the .claude folder: debug, projects, history.jsonl, daemon.log and feedback-bundles
Where Claude Code keeps its debug logs, transcripts and history

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.

Claude Code started with --debug showing the Debug mode enabled banner with a path in the .claude debug folder
With plain –debug, the log goes to ~/.claude/debug/ and is named after the session ID

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.

Output of claude --help filtered to the debug, debug-file and verbose flags
claude –help lists -d as the short form of –debug

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.

Claude Code banner saying Debug mode enabled and logging to a debug.txt file inside the demo project
With –debug-file, the banner shows the path you chose

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.

Official Claude Code environment variables page with CLAUDE_CODE_DEBUG_LOGS_DIR and CLAUDE_CODE_DEBUG_LOG_LEVEL highlighted
The official env vars page explains the log path and log level variables

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.

Claude Code writing notes.txt in debug mode with no hook output or debug text visible on screen
The hook ran, but its output only went to the debug log

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.

grep output from a Claude Code debug log showing the notes-demo MCP server error and the PostToolUse hook success lines
Two grep commands find the MCP failure and the hook result in a 645-line log

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/latest lists every error in the newest log.
  • grep 'MCP server' ~/.claude/debug/latest shows connection attempts and server stderr.
  • grep 'Hooks:' ~/.claude/debug/latest lists each hook run with its duration.
  • grep -i settings ~/.claude/debug/latest helps 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.

Listing of the .claude debug folder showing session log files and the latest link pointing to the newest one
The latest link always points to the most recent debug session

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.

Claude Code /debug command answering why the notes-demo MCP server failed, after reading the session debug log
/debug read the session log and named the root cause in three lines

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.

Decision ladder for choosing a Claude Code log: --debug, /debug, transcript, claude logs, or /bug
Pick the right log for the problem in front of you

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.

Listing of the project transcripts folder with one jsonl file per session and the prompt text found inside
Our demo project had one .jsonl transcript per session, with the prompt stored as plain text

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.

claude purge dry run listing the debug logs, transcripts folder, config entry and history lines it would delete
The dry run lists the debug logs, transcripts and history lines for this project

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 logs follows ~/.claude/daemon.log, the background-session supervisor’s log, until you press Ctrl+C.
  • /doctor runs a setup checkup. Our doctor guide shows what it checks.
  • claude --safe-mode starts 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:

  1. Reproduce the problem in a fresh session started with --debug-file ./bug.txt, so the log covers only that bug.
  2. Copy only the relevant lines with grep, not the whole file.
  3. Replace your username and home folder path, for example sed "s#$HOME#~#g".
  4. Remove tokens, keys, email addresses and private file names.
  5. Add your version from claude --version and 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 --debug flag writes to a file only.
  • Typing --debug mcp with a space. Use --debug=mcp or the filter is ignored.
  • Setting CLAUDE_CODE_DEBUG_LOGS_DIR to a folder or without turning debug on.
  • Running /debug after 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-file per bug so each log tells one story.
  • Set CLAUDE_CODE_DEBUG_LOG_LEVEL=error to cut noise, or verbose for hook matcher detail.
  • Search by the exact name of your server, hook or setting before reading anything else.
  • Check /mcp and /hooks first. 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

Claude Code logs cheat sheet with commands to turn on debug logging and to find and read log files
Commands to turn on, find and read Claude Code logs

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.

Newsletter

New AI tools in your inbox

The best new tools and the AI news that matters, in one short email. Unsubscribe any time.

Free · No spam · Unsubscribe any time

✓ Looks like you’re subscribed

Loading Google’s sign-up form…

Looks like you’re already subscribed

Thanks for reading! New AI tools and the AI news that matters will land in your inbox.

Not subscribed yet? Refresh the page to load the sign-up form.

The sign-up form couldn’t load. If you use an ad or content blocker, allow news.google.com and reload the page.

Free instant check before you pay. Takes a few seconds.

Scroll to Top