# CLAUDE_PROJECT_DIR

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

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** ${CLAUDE_PROJECT_DIR}

## Think of it like

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

## 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

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.

## Example code

```json
{
  "type": "command",
  "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check.sh"
}
```

Find the script from any folder.

## Why it matters

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

## Common mistake

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

## Three principles

- **Project root.** Where it started.
- **For script paths.** In hooks.
- **Quote it.** Spaces break it.

## Related terms

- [CLAUDE_PLUGIN_ROOT](https://learn.benibix.com/term/ai/claude-plugin-root-variable)
- [Command Hook](https://learn.benibix.com/term/ai/command-hook)
- [Primary Working Directory](https://learn.benibix.com/term/ai/primary-working-directory)

## Told apart from

- [CLAUDE_PROJECT_DIR vs CLAUDE_PLUGIN_ROOT](https://learn.benibix.com/compare/claude-project-dir-variable-vs-claude-plugin-root-variable): People think both point at the folder you are working in. Only one does. CLAUDE_PROJECT_DIR is the root of your project, so a hook in your settings uses it to find its script. CLAUDE_PLUGIN_ROOT is the folder a plugin was put in, so a plugin's hook uses it to find its own files. That folder can change on an update, so a plugin keeps data that must last somewhere else.

---

Source: https://learn.benibix.com/term/ai/claude-project-dir-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-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
