brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: claude --debug can filter by category and write its log to a file you choose

Claude
~/tips/tip-claude-code-debug-flag-filter

claude --debug='mcp,startup'

Starts Claude Code with debug logging for only the categories you name, written to a file.

When an MCP server shows up with zero tools or a hook never fires, the debug log is where the answer lives. The full log is noisy, though. Claude Code can narrow it down.

claude --debug='mcp,startup'

That enables debug mode for the mcp and startup categories. A leading ! excludes one instead, so --debug='!mcp' logs everything except MCP. The catch is the quoting and the equals sign: the filter only binds in the = form. With a space instead, debug mode turns on without any filtering.

To send the log to a place you pick, use:

claude --debug-file /tmp/claude-debug.log

It implicitly enables debug mode, so you don’t need --debug as well, and it takes precedence over the CLAUDE_CODE_DEBUG_LOGS_DIR variable.

The troubleshooting docs give a concrete case. If a server shows as connected but lists zero tools and Reconnect in /mcp doesn’t help, run claude --debug=mcp and read the server’s stderr in the debug log at ~/.claude/debug/<session-id>.txt. For a hook that is saved but doesn’t fire, the same docs say to start with claude --debug and trigger the tool call to watch the hook evaluation.

Per-session debug logs are part of what Claude Code cleans up after cleanupPeriodDays, so they don’t pile up forever.

I’d start with a narrow filter and widen it only if the answer isn’t there. A log you can read in one screen beats one you have to grep.

Further reading: Claude Code docs: CLI reference, Claude Code docs: debug your configuration

More Claude tips /recap /focus /skill-doctor /autocompact 500k claude purge ~/work/my-repo --dry-run All Claude tips (83) All topics

Link