Skip to content
BENIBIX Learn

CLAUDE_PROJECT_DIR

AI⌨️ Claude CodeConfiguration

Also known as ${CLAUDE_PROJECT_DIR}

The path to the top folder of a project, for hook scripts.

Think of it like

It is like your home address. It works from any street.

Example

Lucy's hook broke each time Claude moved into a subfolder. She starts the path with this variable. Now it finds the script every time.

Why it matters

A relative path depends on where Claude is. This one does not.

Definition

CLAUDE_PROJECT_DIR is a variable that holds the top folder of the project, where the session began. Hooks put it at the start of a script's path, so they find their own scripts. That still works when Claude moves to a subfolder with cd. Claude Code also sets it for local MCP servers.

Example code

json
{
  "type": "command",
  "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check.sh"
}
Find the script from any folder.

Common mistake

Leaving the quotes off. A space in the folder path then breaks the command.

Key takeaways

  1. 1
    Project root. Where it started.
  2. 2
    For script paths. In hooks.
  3. 3
    Quote it. Spaces break it.

Compare