# DEBUG Variable

> Set to 1, it turns on debug logs, like --debug.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** DEBUG=1, CLAUDE_CODE_DEBUG_LOGS_DIR, CLAUDE_CODE_DEBUG_LOG_LEVEL

## Think of it like

It is like you turn on the black box on a plane.

## Definition

DEBUG set to 1 turns on debug mode, the same as --debug. Logs go to a file in your debug folder, one per session. Only 1, true, yes and on count. So a DEBUG value set for some other tool does not. Two helpers set the log file's path and how much it keeps.

## Example

Lucy's MCP server will not connect, and the screen says little. She starts with DEBUG=1 and reads the log to find the error.

## Example code

```bash
DEBUG=1 CLAUDE_CODE_DEBUG_LOG_LEVEL=verbose claude
```

Log everything for one session.

## Why it matters

The log shows steps the screen hides. It is the first place to look when something breaks.

## Common mistake

Setting only the logs folder and waiting for a file. The folder alone does not turn logging on.

## Three principles

- **1, true, yes, on.** Turn it on.
- **File per session.** In ~/.claude/debug.
- **Level and path.** Two helpers.

## Related terms

- [/debug Command](https://learn.benibix.com/term/ai/debug-command)
- [claude logs Command](https://learn.benibix.com/term/ai/claude-logs-command)
- [Debugging](https://learn.benibix.com/term/development/debugging)

---

Source: https://learn.benibix.com/term/ai/debug-variable
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
